diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index 7dc5e63c..68cc9852 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -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 } diff --git a/source/net/sourceforge/filebot/cli/StrictMetric.java b/source/net/sourceforge/filebot/cli/StrictMetric.java index a05c68fe..3a0f17ee 100644 --- a/source/net/sourceforge/filebot/cli/StrictMetric.java +++ b/source/net/sourceforge/filebot/cli/StrictMetric.java @@ -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 diff --git a/source/net/sourceforge/filebot/similarity/MetricCascade.java b/source/net/sourceforge/filebot/similarity/MetricCascade.java index 4c1647d2..20962f55 100644 --- a/source/net/sourceforge/filebot/similarity/MetricCascade.java +++ b/source/net/sourceforge/filebot/similarity/MetricCascade.java @@ -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; } diff --git a/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java b/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java index b20a5b5b..53b6dc5d 100644 --- a/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java +++ b/source/net/sourceforge/filebot/ui/rename/MatchSimilarityMetric.java @@ -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 }; } } diff --git a/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java b/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java index 63034de9..20d86ba9 100644 --- a/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java +++ b/test/net/sourceforge/filebot/ui/rename/MatchSimilarityMetricTest.java @@ -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> m = new Matcher(files, episodes, true, metrics).match(); assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName());