mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -05:00
* refactor & simplify
This commit is contained in:
parent
b6c2cafeb0
commit
87ffd27e85
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user