* fix sever FileSizeMetric bug
* don't use error highlighting if FileSize/FileName matches
This commit is contained in:
parent
d00d8fc329
commit
b8bf8eee77
|
@ -13,7 +13,7 @@ public class FileSizeMetric implements SimilarityMetric {
|
|||
if (l1 < 0)
|
||||
return 0;
|
||||
|
||||
long l2 = getLength(o1);
|
||||
long l2 = getLength(o2);
|
||||
if (l2 < 0)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
package net.sourceforge.filebot.similarity;
|
||||
|
||||
|
||||
public class MetricMin implements SimilarityMetric {
|
||||
|
||||
private final SimilarityMetric metric;
|
||||
private final float minValue;
|
||||
|
||||
|
||||
public MetricMin(SimilarityMetric metric, float minValue) {
|
||||
this.metric = metric;
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getSimilarity(Object o1, Object o2) {
|
||||
return Math.max(metric.getSimilarity(o1, o2), minValue);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,9 @@ import javax.swing.border.EmptyBorder;
|
|||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.similarity.Match;
|
||||
import net.sourceforge.filebot.similarity.MetricCascade;
|
||||
import net.sourceforge.filebot.similarity.MetricMin;
|
||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||
import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture;
|
||||
import net.sourceforge.filebot.web.Episode;
|
||||
import net.sourceforge.tuned.FileUtilities;
|
||||
|
@ -128,7 +131,8 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
|
|||
return (f + 1) / 2; // normalize -1..1 to 0..1
|
||||
}
|
||||
|
||||
float f = EpisodeIdentifier.getSimilarity(match.getValue(), match.getCandidate());
|
||||
SimilarityMetric fsm = new MetricCascade(new MetricMin(FileSize, 0), FileName, EpisodeIdentifier);
|
||||
float f = fsm.getSimilarity(match.getValue(), match.getCandidate());
|
||||
if (f != 0) {
|
||||
return (Math.max(f, 0)); // normalize -1..1 and boost by 0.25 (because file <-> file matches are not necessarily about Episodes)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue