From bc14bf6fc0dfd131fe124c18aa81cb8a261e4ca0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 18 Jul 2012 10:45:47 +0000 Subject: [PATCH] * 1/3 emphasis on numberic patterns when sorting by similarity in order to help match movies by name and year --- .../sourceforge/filebot/media/MediaDetection.java | 12 ++++++++++-- .../filebot/ui/rename/MovieHashMatcher.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index b11bcc1d..aa72faae 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -391,8 +391,14 @@ public class MediaDetection { public static List sortBySimilarity(Collection options, Collection terms) throws IOException { - SimilarityMetric metric = new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric()); List 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 sorted = new ArrayList(options); 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 { return releaseInfo.cleanRelease(singleton(name), true).iterator().next(); } catch (NoSuchElementException e) { return ""; // default value in case all tokens are stripped away + } catch (IOException e) { + throw new RuntimeException(e); } } diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index 42401743..fe7b1229 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -318,7 +318,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { // add repeat button JCheckBox checkBox = new JCheckBox(); - checkBox.setToolTipText("Auto-Repeat"); + checkBox.setToolTipText("Select / Ignore for all"); checkBox.setCursor(getPredefinedCursor(HAND_CURSOR)); checkBox.setIcon(ResourceManager.getIcon("button.repeat")); checkBox.setSelectedIcon(ResourceManager.getIcon("button.repeat.selected"));