languagetool-org/languagetool · error · SAXException
rule error. The number unified tokens: " + uniCounter + " m
Error message
rule error. The number unified tokens: " + uniCounter + " must be equal to the number of matched tokens: " + matchedTokenCount + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + ".
What it means
Consistency check for UNIFY disambiguation rules: the number of unify elements collected for the rule must equal the number of tokens matched by the pattern, since unification applies per matched token. Fires at parse time when the rule XML declares mismatched unify features versus its pattern length.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:342
}
caseSensitive = false;
if (disambExamples != null) {
rule.setExamples(disambExamples);
}
if (untouchedExamples != null) {
rule.setUntouchedExamples(untouchedExamples);
}
setRuleFilter(filterClassName, filterArgs, rule);
if (!rulegroupAntiPatterns.isEmpty()) {
rule.setAntiPatterns(rulegroupAntiPatterns);
}
if (!ruleAntiPatterns.isEmpty()) {
rule.setAntiPatterns(ruleAntiPatterns);
ruleAntiPatterns.clear();
}
rules.add(rule);
if (disambigAction == DisambiguationPatternRule.DisambiguatorAction.UNIFY && matchedTokenCount != uniCounter) {
throw new SAXException(language.getName() + " rule error. The number unified tokens: "
+ uniCounter + " must be equal to the number of matched tokens: " + matchedTokenCount
+ "\n Line: " + pLocator.getLineNumber() + ", column: "
+ pLocator.getColumnNumber() + ".");
}
boolean singleTokenCorrection = endPos - startPos > 1;
if ((!singleTokenCorrection && (disambigAction == DisambiguationPatternRule.DisambiguatorAction.FILTER || disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE))
&& (matchedTokenCount > 1)) {
throw new SAXException(
language.getName() + " rule error. Cannot replace or filter more than one token at a time."
+ "\n Line: " + pLocator.getLineNumber() + ", column: "
+ pLocator.getColumnNumber() + ".");
}
patternTokens.clear();
posSelector = null;
disambExamples = null;
untouchedExamples = null;
startPos = -1;
endPos = -1;View on GitHub (pinned to 2e990059ce)
Solutions
- Add or remove unify elements so their count equals the number of matched pattern tokens
- Adjust the pattern (or marker corrections) so matchedTokenCount matches uniCounter
- Switch to a different action if per-token unification is not intended
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:342 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/dd22712776922e1f.
Report an issue: GitHub.