{"record":{"id":"e5819c98ee4603e9","repo":"languagetool-org/languagetool","slug":"dist-to-big-maxeditdistance","errorCode":null,"errorMessage":"Dist to big: \" + maxEditDistance","messagePattern":"Dist to big: \" \\+ maxEditDistance","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/spelling/symspell/implementation/SymSpell.java","lineNumber":321,"sourceCode":"  public List<SuggestItem> lookup(String input, Verbosity verbosity) {\n    return lookup(input, verbosity, maxDictionaryEditDistance);\n  }\n\n  /// <summary>Find suggested spellings for a given input word.</summary>\n  /// <param name=\"input\">The word being spell checked.</param>\n  /// <param name=\"verbosity\">The value controlling the quantity/closeness of the returned suggestions.</param>\n  /// <param name=\"maxEditDistance\">The maximum edit distance between input and suggested words.</param>\n  /// <returns>A List of SymSpell.SuggestItem object representing suggested correct spellings for the input word,\n  /// sorted by edit distance, and secondarily by count frequency.</returns>\n  public List<SuggestItem> lookup(String input, Verbosity verbosity, int maxEditDistance) {\n    //verbosity=Top: the suggestion with the highest term frequency of the suggestions of smallest edit distance found\n    //verbosity=Closest: all suggestions of smallest edit distance found, the suggestions are ordered by term frequency\n    //verbosity=All: all suggestions <= maxEditDistance, the suggestions are ordered by edit distance, then by term frequency (slower, no early termination)\n\n    // maxEditDistance used in lookup can't be bigger than the maxDictionaryEditDistance\n    // used to construct the underlying dictionary structure.\n    if (maxEditDistance > maxDictionaryEditDistance) {\n      throw new IllegalArgumentException(\"Dist to big: \" + maxEditDistance);\n    }\n\n    List<SuggestItem> suggestions = new ArrayList<>();\n    int inputLen = input.length();\n\n    // early exit - word is too big to possibly match any words\n    if (inputLen - maxEditDistance > maxLength) {\n      return suggestions;\n    }\n\n    // deletes we've considered already\n    HashSet<String> consideredDeletes = new HashSet<>();\n    // suggestions we've considered already\n    HashSet<String> consideredSuggestions = new HashSet<>();\n    long suggestionCount;\n\n    // quick look for exact match\n    if (words.containsKey(input)) {","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/spelling/symspell/implementation/SymSpell.java#L303-L339","documentation":"Parameter guard in SymSpell.lookup: the caller requested suggestions with a maximum edit distance larger than the edit distance the dictionary was built with (maxDictionaryEditDistance). Since the delete-based index only covers the built distance, a larger distance cannot be honored and the request is rejected.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/rules/spelling/symspell/implementation/SymSpell.java:321 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call lookup with an edit distance less than or equal to the dictionary's max edit distance","Rebuild the SymSpell dictionary with a larger initial edit distance if a bigger lookup distance is required"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}