/** * Return the best score for a title when compared to the search string. It uses 2 passes to find the best match. the first pass uses the matchTitle * as is, and the second pass uses the matchTitle will non search characters removed. * * @param searchTitle * the search title * @param matchTitle * the match title * @return the best out of the 2 scored attempts */ public static float calculateScore(String searchTitle, String matchTitle) { float score1 = Similarity.compareStrings(searchTitle, matchTitle); float score2 = Similarity.compareStrings(searchTitle, removeNonSearchCharacters(matchTitle)); float score3 = 0; if (searchTitle != null && searchTitle.matches(".* \\d{4}$")) { // ends with space+year score3 = Similarity.compareStrings(searchTitle.replaceFirst(" \\d{4}$", ""), matchTitle); } float score = Math.max(score1, Math.max(score3, score2)); LOGGER.debug(String.format("Similarity Score: [%s][%s]=[%s]", searchTitle, matchTitle, score)); return score; }
for (Entry<String, List<AniDBShow>> entry : showsForLookup.entrySet()) { String title = entry.getKey(); float score = Similarity.compareStrings(title, searchString); if (score > 0.4) { for (AniDBShow show : entry.getValue()) {
for (Info.MovieInfo movieInfo : info.getMovieInfo()) { float score = 0.8f * Similarity.compareStrings(options.getQuery(), movieInfo.movieTitle); SubtitleSearchResult result = new SubtitleSearchResult(providerInfo.getId(), score); result.setId(movieInfo.id);