* when in doubt, just pick the top 5 most likely hits => never fail in -non-strict mode

This commit is contained in:
Reinhard Pointner 2014-03-27 07:40:30 +00:00
parent af98e0b048
commit bd482562e0
1 changed files with 4 additions and 6 deletions

View File

@ -860,6 +860,7 @@ public class CmdlineOperations implements CmdlineInterface {
return probableMatches;
}
@SuppressWarnings("unchecked")
public List<SearchResult> selectSearchResult(String query, Collection<? extends SearchResult> searchResults, boolean strict) throws Exception {
List<SearchResult> probableMatches = findProbableMatches(query, searchResults, strict);
@ -871,13 +872,10 @@ public class CmdlineOperations implements CmdlineInterface {
if (strict) {
throw new Exception("Multiple options: Force auto-select requires non-strict matching: " + searchResults);
} else {
if (searchResults.size() > 5) {
throw new Exception("Unable to auto-select search result: " + searchResults);
} else {
return new ArrayList<SearchResult>(searchResults);
}
}
// just pick the best 5 matches
probableMatches = (List<SearchResult>) sortBySimilarity(searchResults, singleton(query), getSeriesMatchMetric(), false);
}
// return first and only value