コード例 #1
0
 public List<String> getSuggestions(String word) {
   final List<String> suggestions = new ArrayList<>();
   try {
     suggestions.addAll(speller.findReplacements(word));
     if (suggestions.isEmpty() && !word.toLowerCase(conversionLocale).equals(word)) {
       suggestions.addAll(speller.findReplacements(word.toLowerCase(conversionLocale)));
     }
     suggestions.addAll(speller.replaceRunOnWords(word));
   } catch (CharacterCodingException e) {
     throw new RuntimeException(e);
   }
   if (dictionary.metadata.isConvertingCase() && StringTools.startsWithUppercase(word)) {
     for (int i = 0; i < suggestions.size(); i++) {
       suggestions.set(i, StringTools.uppercaseFirstChar(suggestions.get(i)));
     }
   }
   return suggestions;
 }
コード例 #2
0
 public boolean isMisspelled(String word) {
   return word.length() > 0
       && !SpellingCheckRule.LANGUAGETOOL.equals(word)
       && !SpellingCheckRule.LANGUAGETOOL_FX.equals(word)
       && speller.isMisspelled(word);
 }