1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 20:05:04 -05:00

* refactor & simplify

This commit is contained in:
Reinhard Pointner 2015-05-25 15:14:00 +00:00
parent b6c2cafeb0
commit 87ffd27e85
3 changed files with 12 additions and 14 deletions

View File

@ -180,10 +180,6 @@ public enum SubtitleMetrics implements SimilarityMetric {
} }
public static SimilarityMetric verificationMetric() { public static SimilarityMetric verificationMetric() {
return EpisodeMetrics.verificationMetric();
}
public static SimilarityMetric sanityMetric() {
return new MetricCascade(AbsoluteSeasonEpisode, AirDate, new MetricAvg(NameSubstringSequence, Name), getMovieMatchMetric(), OriginalFileName); return new MetricCascade(AbsoluteSeasonEpisode, AirDate, new MetricAvg(NameSubstringSequence, Name), getMovieMatchMetric(), OriginalFileName);
} }

View File

@ -185,13 +185,8 @@ public final class SubtitleUtilities {
// first match everything as best as possible, then filter possibly bad matches // first match everything as best as possible, then filter possibly bad matches
Matcher<File, SubtitleDescriptor> matcher = new Matcher<File, SubtitleDescriptor>(files, subtitles, false, metrics); Matcher<File, SubtitleDescriptor> matcher = new Matcher<File, SubtitleDescriptor>(files, subtitles, false, metrics);
SimilarityMetric sanity = SubtitleMetrics.sanityMetric();
float minSanitySimilarity = 0.1f;
for (Match<File, SubtitleDescriptor> it : matcher.match()) { for (Match<File, SubtitleDescriptor> it : matcher.match()) {
if (sanity.getSimilarity(it.getValue(), it.getCandidate()) >= minSanitySimilarity) { subtitleByVideo.put(it.getValue(), it.getCandidate());
subtitleByVideo.put(it.getValue(), it.getCandidate());
}
} }
return subtitleByVideo; return subtitleByVideo;
@ -237,8 +232,16 @@ public final class SubtitleUtilities {
} }
try { try {
return matchSubtitles(singleton(file), subtitles).entrySet().iterator().next().getValue(); // add other possible matches to the options
} catch (NoSuchElementException e) { SimilarityMetric sanity = SubtitleMetrics.verificationMetric();
float minMatchSimilarity = strict ? 0.8f : 0.2f;
// first match everything as best as possible, then filter possibly bad matches
for (Entry<File, SubtitleDescriptor> it : matchSubtitles(singleton(file), subtitles).entrySet()) {
if (sanity.getSimilarity(it.getKey(), it.getValue()) >= minMatchSimilarity) {
return it.getValue();
}
}
return null; return null;
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@ -945,8 +945,7 @@ class SubtitleAutoMatchDialog extends JDialog {
@Override @Override
public float getMatchProbabilty(File videoFile, SubtitleDescriptor descriptor) { public float getMatchProbabilty(File videoFile, SubtitleDescriptor descriptor) {
SimilarityMetric metric = SubtitleMetrics.sanityMetric(); return SubtitleMetrics.verificationMetric().getSimilarity(videoFile, descriptor);
return 0.9f * metric.getSimilarity(videoFile, descriptor);
} }
} }