1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04: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() {
return EpisodeMetrics.verificationMetric();
}
public static SimilarityMetric sanityMetric() {
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
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()) {
if (sanity.getSimilarity(it.getValue(), it.getCandidate()) >= minSanitySimilarity) {
subtitleByVideo.put(it.getValue(), it.getCandidate());
}
subtitleByVideo.put(it.getValue(), it.getCandidate());
}
return subtitleByVideo;
@ -237,8 +232,16 @@ public final class SubtitleUtilities {
}
try {
return matchSubtitles(singleton(file), subtitles).entrySet().iterator().next().getValue();
} catch (NoSuchElementException e) {
// add other possible matches to the options
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;
} catch (InterruptedException e) {
throw new RuntimeException(e);

View File

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