languagetool-org/languagetool · error · IllegalArgumentException
AdvancedSynthesizerFilter: Index out of bounds in ${match.ge
Error message
AdvancedSynthesizerFilter: Index out of bounds in ${match.getRule().getFullId()}, value: ${lemmaFromStr} What it means
Same filter, same validation, but for the 'lemmaFrom' argument: acceptRuleMatch() requires lemma_from (absolute or marker-based) to fall within 1..patternTokens.length, because the token at that index supplies the lemma for synthesis. Out of range means the rule references a nonexistent token.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/AbstractAdvancedSynthesizerFilter.java:90
}
if (postagFrom < 1 || postagFrom > patternTokens.length) {
throw new IllegalArgumentException("AdvancedSynthesizerFilter: Index out of bounds in "
+ match.getRule().getFullId() + ", value: " + postagFromStr);
}
int lemmaFrom = 0;
if (lemmaFromStr.startsWith("marker")) {
while (lemmaFrom < patternTokens.length && patternTokens[lemmaFrom].getStartPos() < match.getFromPos()) {
lemmaFrom++;
}
lemmaFrom++;
if (lemmaFromStr.length()>6) {
lemmaFrom += Integer.parseInt(lemmaFromStr.replace("marker", ""));
}
} else {
lemmaFrom = Integer.parseInt(lemmaFromStr);
}
if (lemmaFrom < 1 || lemmaFrom > patternTokens.length) {
throw new IllegalArgumentException("AdvancedSynthesizerFilter: Index out of bounds in "
+ match.getRule().getFullId() + ", value: " + lemmaFromStr);
}
String postagReplace = getOptional("postagReplace", arguments);
String desiredLemma = getAnalyzedToken(patternTokens[lemmaFrom - 1], lemmaSelect).getLemma();
String originalPostag = getAnalyzedToken(patternTokens[lemmaFrom - 1], lemmaSelect).getPOSTag();
String desiredPostag = getAnalyzedToken(patternTokens[postagFrom - 1], postagSelect).getPOSTag();
if (!newLemma.isEmpty()) {
if (newLemma.startsWith("_")) {
desiredLemma = getNewLemma(desiredLemma, newLemma);
} else {
desiredLemma = newLemma;
}
}
if (desiredLemma == null) {
return null;
}View on GitHub (pinned to 2e990059ce)
Solutions
- Correct lemma_from in the rule XML to a valid 1-based token index in the pattern.
- After changing a pattern, revalidate all filter argument indices.
- Verify marker arithmetic stays within the matched token count.
- Run the rule's test sentences to exercise acceptRuleMatch and confirm the fix.
Example fix
// before (3-token pattern, lemma_from:7) <filter class="...AdvancedSynthesizerFilter" args="lemma_from:7 postag_from:2"/> // after <filter class="...AdvancedSynthesizerFilter" args="lemma_from:2 postag_from:2"/>
Defensive patterns
Strategy: validation
Validate before calling
int lemmaFrom = Integer.parseInt(args.get("lemma_from").replace("marker", ""));
if (lemmaFrom < 1 || lemmaFrom > patternTokens.length)
throw new RuleFormatException("lemma_from out of range"); Prevention
- Validate lemma_from against the actual pattern token count
- Avoid copy-pasting filter args between rules with different patterns
- Add rule test cases that exercise the filter
When it happens
Trigger: A rule's lemma_from value (e.g. lemma_from="3" or marker arithmetic) resolves to <1 or beyond the number of matched pattern tokens; patternTokens[lemmaFrom-1] would otherwise be accessed.
Common situations: Rule pattern edited/shortened without updating lemma_from; copy-paste of filter args between rules with different token counts; off-by-one (1-based indices).
Related errors
- AdvancedSynthesizerFilter: Index out of bounds in ${match.ge
- AdvancedSynthesizerFilter: undefined POS tag for rule ${matc
- Cannot synthesize <token><exception>
- Only 3grams and 4grams are supported
- Set only 'weekDay' and 'date' for " + YMDDateCheckFilter.cla
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/1a2a14c49081dad0.
Report an issue: GitHub.