languagetool-org/languagetool · error · ErrorRateTooHighException
Text checking was stopped due to too many errors (more than
Error message
Text checking was stopped due to too many errors (more than %.0f%% of words seem to have an error). Are you sure you have set the correct text language? Language set: ${language.getName()}, text length: ${annotatedText.getPlainText().length()} What it means
JLanguageTool aborts checking when the ratio of detected errors to words exceeds maxErrorsPerWordRate (after 25+ words), indicating the wrong language was likely selected. It throws ErrorRateTooHighException after logging the per-sentence error-rate progression.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/JLanguageTool.java:2245
if (!ignoreRanges.contains(ignoreRange)) {
ignoreRanges.add(ignoreRange);
}
extendedSentenceRange.updateLanguageConfidenceRates(elem.getNewLanguageMatches());
}
ruleMatches.add(thisMatch);
if (listener != null) {
listener.matchFound(thisMatch);
}
}
}
float errorsPerWord = ruleMatches.size() / (float) wordCounter;
if (tmpErrorsPerWord < errorsPerWord) {
errorRateLog.add("With sentence: " + (i + 1) + " (of " + sentencesSize + ") the text error rate increased by: " + (errorsPerWord - tmpErrorsPerWord) + " from: " + tmpErrorsPerWord + " to total: " + errorsPerWord);
tmpErrorsPerWord = errorsPerWord;
}
if (maxErrorsPerWordRate > 0 && errorsPerWord > maxErrorsPerWordRate && wordCounter > 25) {
errorRateLog.forEach(e -> logger.info(LoggingTools.BAD_REQUEST, e));
throw new ErrorRateTooHighException("Text checking was stopped due to too many errors (more than " + String.format("%.0f", maxErrorsPerWordRate * 100) +
"% of words seem to have an error). Are you sure you have set the correct text language? Language set: " + JLanguageTool.this.language.getName() +
", text length: " + annotatedText.getPlainText().length());
// ", text length: " + annotatedText.getPlainText().length() + ", common word count: " + commonWords.getKnownWordsPerLanguage(annotatedText.getPlainText()));
}
} catch (ErrorRateTooHighException e) {
throw e;
} catch (StackOverflowError e) {
System.out.println("Could not check sentence due to StackOverflowError (language: " + language + "): <sentcontent>"
+ StringUtils.abbreviate(sentence.analyzed.toTextString(), 10_000) + "</sentcontent>");
throw e;
} catch (Exception e) {
throw new RuntimeException("Could not check sentence (language: " + language + "): <sentcontent>"
+ StringUtils.abbreviate(sentence.analyzed.toTextString(), 500) + "</sentcontent>", e);
}
}
return new CheckResults(ruleMatches, ignoreRanges, extendedSentenceRanges);
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Detect the correct language first (e.g. LanguageDetector or the /v2/detect endpoint) and re-run check() with it
- Raise or disable the threshold via setMaxErrorsPerWordRate(float) if high error rates are expected
- Catch ErrorRateTooHighException and return a 'wrong language?' hint to the user
Example fix
// before
lt = new JLanguageTool(Languages.getLanguageForShortCode("de"));
lt.check(englishText); // ErrorRateTooHighException
// after
Language detected = detectLanguage(englishText);
lt = new JLanguageTool(detected);
lt.check(englishText); Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check approximate error rate
List<RuleMatch> probe = lt.check(text.substring(0, Math.min(text.length(), 500)));
if (((double) probe.size() / text.split("\\s+").length) > 0.5) { /* suspect wrong language */ } Try / catch
try { lt.check(text); } catch (ErrorRateTooHighException e) { log.warn("Wrong language? {}", e.getMessage()); Language detected = detector.detect(text); lt = new JLanguageTool(detected); /* retry */ } Prevention
- Run language detection before checking user-submitted text
- Configure a sensible maxErrorsPerWordRate and document it for API users
- Treat this exception as a 'wrong language' signal, not a bug — surface it to clients
When it happens
Trigger: Running check() on text where more than the configured maxErrorsPerWordRate fraction of words (over a 25-word minimum) produce matches — typically text in a language different from the configured Language.
Common situations: Server setups where clients submit text with a wrong/mismatched language code; checking non-natural text (code, random characters) with the wrong language model; misconfigured default language on the API.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- WrongParameterNumberException
- ErrorRateTooHigh is reached by a single sentence after rule:
- listUnknownWords is set to false, unknown words not stored
- Unknown mode: <mode>
- '${langCode}' is not a language code known to LanguageTool.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/29a024e2ff681fa5.
Report an issue: GitHub.