* improved new funnel/balance episode matching logic

This commit is contained in:
Reinhard Pointner 2011-11-22 18:26:50 +00:00
parent 33d0f25fa7
commit 6171dac38f
5 changed files with 23 additions and 10 deletions

View File

@ -147,7 +147,7 @@ public class CmdlineOperations implements CmdlineInterface {
// similarity metrics for matching
SimilarityMetric[] sequence;
if (strict) {
sequence = new SimilarityMetric[] { StrictMetric.EpisodeIdentifier, StrictMetric.Title, StrictMetric.Name }; // use SEI for matching and SN for excluding false positives
sequence = new SimilarityMetric[] { StrictMetric.EpisodeIdentifier, StrictMetric.SubstringFields, StrictMetric.Name }; // use SEI for matching and SN for excluding false positives
} else {
sequence = MatchSimilarityMetric.defaultSequence(false); // same as in GUI
}

View File

@ -10,8 +10,8 @@ import net.sourceforge.filebot.ui.rename.MatchSimilarityMetric;
public enum StrictMetric implements SimilarityMetric {
EpisodeIdentifier(MatchSimilarityMetric.StrictEpisodeIdentifier, 1), // only allow 0 or 1
Title(MatchSimilarityMetric.SubstringFields, 2), // allow 0 or .5 or 1
EpisodeIdentifier(MatchSimilarityMetric.EpisodeIdentifier, 1), // only allow 0 or 1
SubstringFields(MatchSimilarityMetric.SubstringFields, 2), // allow 0 or .5 or 1
Name(MatchSimilarityMetric.Name, 2); // allow 0 or .5 or 1
// inner metric

View File

@ -21,7 +21,7 @@ public class MetricCascade implements SimilarityMetric {
for (SimilarityMetric metric : cascade) {
f = max(f, metric.getSimilarity(o1, o2));
// is match, ignore remaining metrics
// perfect match, ignore remaining metrics
if (f >= 1) {
return f;
}

View File

@ -111,9 +111,22 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
}
}),
// Match by combining season/episode, episode airdate and movie/episode title
GeneralEpisodeIdentifier(new MetricCascade(SeasonEpisode, AirDate, Title)),
StrictEpisodeIdentifier(new MetricCascade(SeasonEpisode, AirDate)),
// Match by SxE and airdate
EpisodeIdentifier(new MetricCascade(SeasonEpisode, AirDate)),
// Advanced episode<->file matching
EpisodeFunnel(new MetricCascade(SeasonEpisode, AirDate, Title)),
EpisodeBalancer(new SimilarityMetric() {
@Override
public float getSimilarity(Object o1, Object o2) {
float sxe = EpisodeIdentifier.getSimilarity(o1, o2);
float title = Title.getSimilarity(o1, o2);
// 1:SxE && Title, 2:SxE
return (sxe * title) + (sxe / 10f);
}
}),
// Match series title and episode title against folder structure and file name
SubstringFields(new SubstringMetric() {
@ -259,9 +272,9 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
// 4. pass: match by generic name similarity (slow, but most matches will have been determined in second pass)
// 5. pass: match by generic numeric similarity
if (includeFileMetrics) {
return new SimilarityMetric[] { FileSize, GeneralEpisodeIdentifier, StrictEpisodeIdentifier, SubstringFields, Name, Numeric };
return new SimilarityMetric[] { FileSize, EpisodeFunnel, EpisodeBalancer, SubstringFields, Name, Numeric };
} else {
return new SimilarityMetric[] { GeneralEpisodeIdentifier, StrictEpisodeIdentifier, SubstringFields, Name, Numeric };
return new SimilarityMetric[] { EpisodeFunnel, EpisodeBalancer, SubstringFields, Name, Numeric };
}
}

View File

@ -60,7 +60,7 @@ public class MatchSimilarityMetricTest {
episodes.add(new Episode("Veronica Mars", null, 1, 19, "Hot Dogs"));
episodes.add(new Episode("Greek", null, 1, 19, "No Campus for Old Rules"));
SimilarityMetric[] metrics = new SimilarityMetric[] { GeneralEpisodeIdentifier, SubstringFields };
SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, SubstringFields };
List<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, true, metrics).match();
assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName());