* remove trailing () before checking similarity to make sure we don't autoselect the wrong show if there are two shows with the same name but from different years, e.g. Doctor Who (2005)

This commit is contained in:
Reinhard Pointner 2011-10-15 07:53:54 +00:00
parent 90f5993e10
commit 5b917ef1d0
1 changed files with 7 additions and 1 deletions

View File

@ -65,7 +65,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
// find probable matches using name similarity > 0.9
for (SearchResult result : searchResults) {
if (metric.getSimilarity(query, result.getName()) > 0.9) {
if (metric.getSimilarity(normalize(query), normalize(result.getName())) > 0.9) {
probableMatches.add(result);
}
}
@ -107,6 +107,12 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
}
private String normalize(String value) {
// remove trailing braces, e.g. Doctor Who (2005) -> doctor who
return value.replaceAll("[(]([^)]*)[)]", "").trim().toLowerCase();
}
protected Set<Episode> fetchEpisodeSet(Collection<String> seriesNames, final Locale locale) throws Exception {
List<Callable<List<Episode>>> tasks = new ArrayList<Callable<List<Episode>>>();