* 1/3 emphasis on numberic patterns when sorting by similarity in order to help match movies by name and year

This commit is contained in:
Reinhard Pointner 2012-07-18 10:45:47 +00:00
parent 0a4b68f289
commit bc14bf6fc0
2 changed files with 11 additions and 3 deletions

View File

@ -391,8 +391,14 @@ public class MediaDetection {
public static <T> List<T> sortBySimilarity(Collection<T> options, Collection<String> terms) throws IOException { public static <T> List<T> sortBySimilarity(Collection<T> options, Collection<String> terms) throws IOException {
SimilarityMetric metric = new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric());
List<String> paragon = stripReleaseInfo(terms, true); List<String> paragon = stripReleaseInfo(terms, true);
SimilarityMetric metric = new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric(), new NameSimilarityMetric() {
@Override
protected String normalize(Object object) {
return super.normalize(stripReleaseInfo(object.toString()).replaceAll("\\D+", " ")); // similarity of number patterns
}
});
List<T> sorted = new ArrayList<T>(options); List<T> sorted = new ArrayList<T>(options);
sort(sorted, new SimilarityComparator(metric, paragon.toArray())); sort(sorted, new SimilarityComparator(metric, paragon.toArray()));
@ -537,11 +543,13 @@ public class MediaDetection {
} }
public static String stripReleaseInfo(String name) throws IOException { public static String stripReleaseInfo(String name) {
try { try {
return releaseInfo.cleanRelease(singleton(name), true).iterator().next(); return releaseInfo.cleanRelease(singleton(name), true).iterator().next();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
return ""; // default value in case all tokens are stripped away return ""; // default value in case all tokens are stripped away
} catch (IOException e) {
throw new RuntimeException(e);
} }
} }

View File

@ -318,7 +318,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// add repeat button // add repeat button
JCheckBox checkBox = new JCheckBox(); JCheckBox checkBox = new JCheckBox();
checkBox.setToolTipText("Auto-Repeat"); checkBox.setToolTipText("Select / Ignore for all");
checkBox.setCursor(getPredefinedCursor(HAND_CURSOR)); checkBox.setCursor(getPredefinedCursor(HAND_CURSOR));
checkBox.setIcon(ResourceManager.getIcon("button.repeat")); checkBox.setIcon(ResourceManager.getIcon("button.repeat"));
checkBox.setSelectedIcon(ResourceManager.getIcon("button.repeat.selected")); checkBox.setSelectedIcon(ResourceManager.getIcon("button.repeat.selected"));