languagetool-org/languagetool · error · SAXException
rule error. Cannot replace or filter more than one token at
Error message
rule error. Cannot replace or filter more than one token at a time." + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + ".
What it means
Guard for REPLACE/FILTER disambiguation actions: these actions operate on exactly one token, but the rule's pattern (after marker start/end corrections) matched more than one token. Fires at rule-group end while parsing the XML when a single-token action is paired with a multi-token match span.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:350
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;
filterClassName = null;
filterArgs = null;
inRule = false;
break;
case EXCEPTION:
finalizeExceptions();
break;
case AND:View on GitHub (pinned to 2e990059ce)
Solutions
- Reduce the pattern or marker span so exactly one token is matched for REPLACE/FILTER actions
- Split the rule so each single-token action has its own rule
- Use an action that supports multiple tokens if multi-token handling is intended
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:350 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/ed6a15c27dfbb614.
Report an issue: GitHub.