* fix issue with processing two shows with the same name, e.g. SMASH and Smash
This commit is contained in:
parent
17aa158a72
commit
1f713a3e5a
|
@ -863,7 +863,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
|
|
||||||
public List<SearchResult> findProbableMatches(final String query, Collection<? extends SearchResult> searchResults, boolean strict) {
|
public List<SearchResult> findProbableMatches(final String query, Collection<? extends SearchResult> searchResults, boolean strict) {
|
||||||
// auto-select most probable search result
|
// auto-select most probable search result
|
||||||
Map<String, SearchResult> probableMatches = new LinkedHashMap<String, SearchResult>();
|
List<SearchResult> probableMatches = new ArrayList<SearchResult>();
|
||||||
|
|
||||||
// use name similarity metric
|
// use name similarity metric
|
||||||
final SimilarityMetric metric = new NameSimilarityMetric();
|
final SimilarityMetric metric = new NameSimilarityMetric();
|
||||||
|
@ -872,18 +872,17 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
for (SearchResult result : searchResults) {
|
for (SearchResult result : searchResults) {
|
||||||
float f = (query == null) ? 1 : metric.getSimilarity(query, result.getName());
|
float f = (query == null) ? 1 : metric.getSimilarity(query, result.getName());
|
||||||
if (f >= (strict && searchResults.size() > 1 ? 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())) {
|
if (!probableMatches.contains(result)) {
|
||||||
probableMatches.put(result.toString().toLowerCase(), result);
|
probableMatches.add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort results by similarity to query
|
// sort results by similarity to query
|
||||||
List<SearchResult> results = new ArrayList<SearchResult>(probableMatches.values());
|
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
sort(results, new SimilarityComparator(query));
|
sort(probableMatches, new SimilarityComparator(query));
|
||||||
}
|
}
|
||||||
return results;
|
return probableMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue