diff --git a/source/net/sourceforge/filebot/similarity/Matcher.java b/source/net/sourceforge/filebot/similarity/Matcher.java index 8f436144..9c0ba2a5 100644 --- a/source/net/sourceforge/filebot/similarity/Matcher.java +++ b/source/net/sourceforge/filebot/similarity/Matcher.java @@ -23,15 +23,17 @@ public class Matcher { private final List values; private final List candidates; + private final boolean strict; private final SimilarityMetric[] metrics; private final DisjointMatchCollection disjointMatchCollection; - public Matcher(Collection values, Collection candidates, SimilarityMetric[] metrics) { + public Matcher(Collection values, Collection candidates, boolean strict, SimilarityMetric[] metrics) { this.values = new LinkedList(values); this.candidates = new LinkedList(candidates); + this.strict = strict; this.metrics = metrics.clone(); this.disjointMatchCollection = new DisjointMatchCollection(); @@ -88,8 +90,12 @@ public class Matcher { protected void deepMatch(Collection> possibleMatches, int level) throws InterruptedException { if (level >= metrics.length || possibleMatches.isEmpty()) { + // add the first possible match if non-strict, otherwise ignore ambiguous matches + if (!strict) { + disjointMatchCollection.addAll(possibleMatches); + } + // no further refinement possible - disjointMatchCollection.addAll(possibleMatches); return; } diff --git a/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java b/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java index 7051ba71..9b380963 100644 --- a/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java +++ b/source/net/sourceforge/filebot/ui/panel/rename/MatchAction.java @@ -98,7 +98,7 @@ class MatchAction extends AbstractAction { public BackgroundMatcher(MatchModel model, SimilarityMetric[] metrics) { // match names against files - this.matcher = new Matcher(model.values(), model.candidates(), metrics); + this.matcher = new Matcher(model.values(), model.candidates(), false, metrics); }