mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 09:18:51 -05:00
* improve movie auto-selection
This commit is contained in:
parent
9596ffffe7
commit
6e732e8987
@ -56,6 +56,7 @@ import net.sourceforge.filebot.similarity.SequenceMatchSimilarity;
|
||||
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
||||
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||
import net.sourceforge.filebot.similarity.StringEqualsMetric;
|
||||
import net.sourceforge.filebot.vfs.FileInfo;
|
||||
import net.sourceforge.filebot.web.Date;
|
||||
import net.sourceforge.filebot.web.Episode;
|
||||
@ -654,7 +655,13 @@ public class MediaDetection {
|
||||
}
|
||||
|
||||
public static SimilarityMetric getMovieMatchMetric() {
|
||||
return new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric(), new SequenceMatchSimilarity(0, true), new NumericSimilarityMetric() {
|
||||
return new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric(), new SequenceMatchSimilarity(0, true), new StringEqualsMetric() {
|
||||
|
||||
@Override
|
||||
protected String normalize(Object object) {
|
||||
return super.normalize(removeTrailingBrackets(object.toString()));
|
||||
}
|
||||
}, new NumericSimilarityMetric() {
|
||||
|
||||
private Pattern year = Pattern.compile("\\b\\d{4}\\b");
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
|
||||
package net.sourceforge.filebot.similarity;
|
||||
|
||||
|
||||
public class MetricAvg implements SimilarityMetric {
|
||||
|
||||
|
||||
private final SimilarityMetric[] metrics;
|
||||
|
||||
|
||||
|
||||
public MetricAvg(SimilarityMetric... metrics) {
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SimilarityMetric[] getMetrics() {
|
||||
return metrics.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSimilarity(Object o1, Object o2) {
|
||||
float f = 0;
|
||||
@ -20,5 +20,5 @@ public class MetricAvg implements SimilarityMetric {
|
||||
}
|
||||
return f / metrics.length;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,23 @@
|
||||
|
||||
package net.sourceforge.filebot.similarity;
|
||||
|
||||
|
||||
public class StringEqualsMetric implements SimilarityMetric {
|
||||
|
||||
|
||||
@Override
|
||||
public float getSimilarity(Object o1, Object o2) {
|
||||
if (o1 == null || o2 == null)
|
||||
return 0;
|
||||
|
||||
String s1 = o1.toString();
|
||||
String s2 = o2.toString();
|
||||
|
||||
|
||||
String s1 = normalize(o1);
|
||||
String s2 = normalize(o2);
|
||||
|
||||
if (s1.isEmpty() || s2.isEmpty())
|
||||
return 0;
|
||||
|
||||
return s1.equalsIgnoreCase(s2) ? 1 : 0;
|
||||
|
||||
return s1.equals(s2) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
protected String normalize(Object object) {
|
||||
return object.toString().trim().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,18 @@ import static net.sourceforge.filebot.similarity.Normalization.*;
|
||||
|
||||
public class SubstringMetric implements SimilarityMetric {
|
||||
|
||||
private boolean o1c2;
|
||||
private boolean o2c1;
|
||||
|
||||
public SubstringMetric() {
|
||||
this(true, true);
|
||||
}
|
||||
|
||||
public SubstringMetric(boolean o2c1, boolean o1c2) {
|
||||
this.o1c2 = o1c2;
|
||||
this.o2c1 = o2c1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSimilarity(Object o1, Object o2) {
|
||||
String s1 = normalize(o1);
|
||||
@ -14,7 +26,7 @@ public class SubstringMetric implements SimilarityMetric {
|
||||
if (s2 == null || s2.isEmpty())
|
||||
return 0;
|
||||
|
||||
return s1.contains(s2) || s2.contains(s1) ? 1 : 0;
|
||||
return (o1c2 && s1.contains(s2)) || (o2c1 && s2.contains(s1)) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected String normalize(Object object) {
|
||||
|
Loading…
Reference in New Issue
Block a user