/** * Just gets the Suggestion with the highest Certainty. In case there are more suggestions with * certainty 100, it passes the first highest one. * * @param anomaly * the anomaly. * @return the best suggestion. */ private String getBestSuggestion(SpellingAnomaly anomaly) { Float bestCertainty = 0.0f; String bestReplacement = ""; for (int i = 0; i < anomaly.getSuggestions().size(); i++) { Float currentCertainty = anomaly.getSuggestions(i).getCertainty(); String currentReplacement = anomaly.getSuggestions(i).getReplacement(); if (currentCertainty > bestCertainty) { bestCertainty = currentCertainty; bestReplacement = currentReplacement; } if (bestCertainty == 100) { break; } } return bestReplacement; } }
SuggestedAction action = (SuggestedAction) suggestedActions.get(i); List<String> changedWords = getChangedWords(action.getReplacement(), tokenStrings, getCandidatePosition(anomaly, tokens));
SuggestedAction action = (SuggestedAction) suggestedActions.get(i); List<String> changedWords = getChangedWords(action.getReplacement(), tokenStrings, getCandidatePosition(anomaly, tokens));