From 2217eed53746cfa5f6ff4b98f4c71b62bb4fabd7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 10 Jul 2012 04:50:32 +0000 Subject: [PATCH] * allow non-strict threshold in strict mode when there is only one possible option --- source/net/sourceforge/filebot/cli/CmdlineOperations.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index a0143fea..68625457 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -745,17 +745,17 @@ public class CmdlineOperations implements CmdlineInterface { } - public List findProbableMatches(final String query, Iterable searchResults, boolean strict) { + public List findProbableMatches(final String query, Collection searchResults, boolean strict) { // auto-select most probable search result Map probableMatches = new LinkedHashMap(); // use name similarity metric final SimilarityMetric metric = new NameSimilarityMetric(); - // find probable matches using name similarity > 0.9 (or > 0.8 in non-strict mode) + // find probable matches using name similarity > 0.85 (or > 0.75 in non-strict mode) for (SearchResult result : searchResults) { float f = (query == null) ? 1 : metric.getSimilarity(query, result.getName()); - if (f >= (strict ? 0.85 : 0.75) || ((f >= 0.5 || !strict) && result.getName().toLowerCase().startsWith(query.toLowerCase()))) { + if (f >= (strict && searchResults.size() > 1 ? 0.85 : 0.75) || ((f >= 0.5 || !strict) && result.getName().toLowerCase().startsWith(query.toLowerCase()))) { if (!probableMatches.containsKey(result.toString().toLowerCase())) { probableMatches.put(result.toString().toLowerCase(), result); }