languagetool-org/languagetool · error · IllegalArgumentException
Dist to big: " + maxEditDistance
Error message
Dist to big: " + maxEditDistance
What it means
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.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/spelling/symspell/implementation/SymSpell.java:321
public List<SuggestItem> lookup(String input, Verbosity verbosity) {
return lookup(input, verbosity, maxDictionaryEditDistance);
}
/// <summary>Find suggested spellings for a given input word.</summary>
/// <param name="input">The word being spell checked.</param>
/// <param name="verbosity">The value controlling the quantity/closeness of the returned suggestions.</param>
/// <param name="maxEditDistance">The maximum edit distance between input and suggested words.</param>
/// <returns>A List of SymSpell.SuggestItem object representing suggested correct spellings for the input word,
/// sorted by edit distance, and secondarily by count frequency.</returns>
public List<SuggestItem> lookup(String input, Verbosity verbosity, int maxEditDistance) {
//verbosity=Top: the suggestion with the highest term frequency of the suggestions of smallest edit distance found
//verbosity=Closest: all suggestions of smallest edit distance found, the suggestions are ordered by term frequency
//verbosity=All: all suggestions <= maxEditDistance, the suggestions are ordered by edit distance, then by term frequency (slower, no early termination)
// maxEditDistance used in lookup can't be bigger than the maxDictionaryEditDistance
// used to construct the underlying dictionary structure.
if (maxEditDistance > maxDictionaryEditDistance) {
throw new IllegalArgumentException("Dist to big: " + maxEditDistance);
}
List<SuggestItem> suggestions = new ArrayList<>();
int inputLen = input.length();
// early exit - word is too big to possibly match any words
if (inputLen - maxEditDistance > maxLength) {
return suggestions;
}
// deletes we've considered already
HashSet<String> consideredDeletes = new HashSet<>();
// suggestions we've considered already
HashSet<String> consideredSuggestions = new HashSet<>();
long suggestionCount;
// quick look for exact match
if (words.containsKey(input)) {View on GitHub (pinned to 2e990059ce)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/rules/spelling/symspell/implementation/SymSpell.java:321 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/e5819c98ee4603e9.
Report an issue: GitHub.