* 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.SeriesNameMatcher;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||||
|
import net.sourceforge.filebot.similarity.StringEqualsMetric;
|
||||||
import net.sourceforge.filebot.vfs.FileInfo;
|
import net.sourceforge.filebot.vfs.FileInfo;
|
||||||
import net.sourceforge.filebot.web.Date;
|
import net.sourceforge.filebot.web.Date;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
|
@ -654,7 +655,13 @@ public class MediaDetection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimilarityMetric getMovieMatchMetric() {
|
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");
|
private Pattern year = Pattern.compile("\\b\\d{4}\\b");
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.similarity;
|
package net.sourceforge.filebot.similarity;
|
||||||
|
|
||||||
|
|
||||||
public class MetricAvg implements SimilarityMetric {
|
public class MetricAvg implements SimilarityMetric {
|
||||||
|
|
||||||
private final SimilarityMetric[] metrics;
|
private final SimilarityMetric[] metrics;
|
||||||
|
|
||||||
|
|
||||||
public MetricAvg(SimilarityMetric... metrics) {
|
public MetricAvg(SimilarityMetric... metrics) {
|
||||||
this.metrics = metrics;
|
this.metrics = metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimilarityMetric[] getMetrics() {
|
||||||
|
return metrics.clone();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.similarity;
|
package net.sourceforge.filebot.similarity;
|
||||||
|
|
||||||
|
|
||||||
public class StringEqualsMetric implements SimilarityMetric {
|
public class StringEqualsMetric implements SimilarityMetric {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,13 +7,17 @@ public class StringEqualsMetric implements SimilarityMetric {
|
||||||
if (o1 == null || o2 == null)
|
if (o1 == null || o2 == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
String s1 = o1.toString();
|
String s1 = normalize(o1);
|
||||||
String s2 = o2.toString();
|
String s2 = normalize(o2);
|
||||||
|
|
||||||
if (s1.isEmpty() || s2.isEmpty())
|
if (s1.isEmpty() || s2.isEmpty())
|
||||||
return 0;
|
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 {
|
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
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
String s1 = normalize(o1);
|
String s1 = normalize(o1);
|
||||||
|
@ -14,7 +26,7 @@ public class SubstringMetric implements SimilarityMetric {
|
||||||
if (s2 == null || s2.isEmpty())
|
if (s2 == null || s2.isEmpty())
|
||||||
return 0;
|
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) {
|
protected String normalize(Object object) {
|
||||||
|
|
Loading…
Reference in New Issue