Back to LanguageTool Homepage - Privacy - Imprint

[de] Don't shoot yourself in the foot when using getAdditionalTopSuggestions()

(Jan Schreiber) #1

I just wanted to make everybody on the German team aware that getAdditionalTopSuggestions() in must be used very carefully. These lines:

    } else if (word.endsWith("standart")) {
      return Collections.singletonList(word.replaceFirst("standart$", "standard"));
    } else if (word.endsWith("standarts")) {
      return Collections.singletonList(word.replaceFirst("standarts$", "standards"));
    } else if (word.endsWith("parties")) {
      return Collections.singletonList(word.replaceFirst("parties$", "partys"));
    } else if (word.endsWith("derbies")) {
      return Collections.singletonList(word.replaceFirst("derbies$", "derbys"));
    } else if (word.endsWith("stories")) {
      return Collections.singletonList(word.replaceFirst("stories$", "storys"));
    } else if (word.endsWith("tip")) {
      return Collections.singletonList(word.replaceFirst("tip$", "tipp"));
    } else if (word.endsWith("tips")) {
      return Collections.singletonList(word.replaceFirst("tips$", "tipps"));

add their suggestions no matter what. I think it is wiser if we check the suggestions first in some cases, similar to this:

    } else if (word.endsWith("oullie")) {
      String suggestion = word.replaceFirst("oullie$", "ouille");
      if (!hunspellDict.misspelled(suggestion)) {
        return Collections.singletonList(suggestion);

Even if the suggestions are actually correct words, it is extremely confusing for users if the spell checker suggests something that it does not accept as correct.