languagetool-org/languagetool · error · SAXException
" + language.getName() + " rule error. The number of interpr
Error message
" + language.getName() + " rule error. The number of interpretations specified with wd: " + newWdList.size() + " must be equal to the number of matched tokens (" + matchedTokenCount + ")" + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + ". What it means
Consistency check when finishing a disambiguation rule: for actions that interpret matched tokens, the wd elements must correspond one-to-one with the tokens matched by the pattern (marker-adjusted count). Fires when a rule XML declares more or fewer wd interpretations than the pattern has tokens, at line/column of the rule group end.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:314
endPositionCorrection = endPos - tokenCountForMarker;
if (startPos != -1 && endPos != -1) {
rule.setStartPositionCorrection(startPos);
rule.setEndPositionCorrection(endPositionCorrection);
} else {
startPos = 0;
endPos = tokenCountForMarker;
}
rule.setSubId(inRuleGroup ? StringInterner.intern(Integer.toString(subId)) : "1");
int matchedTokenCount = endPos - startPos;
if (newWdList != null) {
if (disambigAction == DisambiguationPatternRule.DisambiguatorAction.ADDCHUNK ||
disambigAction == DisambiguationPatternRule.DisambiguatorAction.ADD || disambigAction == DisambiguationPatternRule.DisambiguatorAction.REMOVE
|| disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE) {
if ((!newWdList.isEmpty() && disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE)
&& newWdList.size() != matchedTokenCount) {
throw new SAXException(
language.getName() + " rule error. The number of interpretations specified with wd: "
+ newWdList.size()
+ " must be equal to the number of matched tokens (" + matchedTokenCount + ")"
+ "\n Line: " + pLocator.getLineNumber() + ", column: "
+ pLocator.getColumnNumber() + ".");
}
rule.setNewInterpretations(newWdList.toArray(new AnalyzedToken[0]));
}
newWdList.clear();
}
caseSensitive = false;
if (disambExamples != null) {
rule.setExamples(disambExamples);
}
if (untouchedExamples != null) {
rule.setUntouchedExamples(untouchedExamples);
}
setRuleFilter(filterClassName, filterArgs, rule);View on GitHub (pinned to 2e990059ce)
Solutions
- Adjust the number of wd elements in the rule to match the number of pattern tokens
- Fix the pattern length or marker span so matchedTokenCount equals the wd list size
- Split the rule if different token counts need different interpretations
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:314 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/0c8752e8aa97e944.
Report an issue: GitHub.