languagetool-org/languagetool · error · RuntimeException
Error trying to synthesize POS tag " + posTag + " (posTagReg
Error message
Error trying to synthesize POS tag " + posTag + " (posTagRegExp: true) from token " + token.getToken()
What it means
Wrapper exception in BaseSynthesizer.synthesize for the posTagRegExp=true code path: treating the POS tag as a regular expression and synthesizing matching word forms failed unexpectedly, and the error is rethrown with the offending tag and token attached. The inputs at fault are the POS-tag pattern and the analyzed token passed by the calling rule.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/synthesis/BaseSynthesizer.java:261
}
if (posTag.equals(SPELLNUMBER_FEMININE_TAG)) {
return new String[] {getSpelledNumber("feminine " + token.getToken())};
}
if (posTag.equals(SPELLNUMBER_ROMAN_TAG)) {
return new String[] {getRomanNumber(token.getToken())};
}
List<String> wordForms = lookup(token.getLemma(), posTag);
return removeExceptions(wordForms.toArray(new String[0]));
}
@Override
public String[] synthesize(AnalyzedToken token, String posTag, boolean posTagRegExp) throws IOException {
if (posTagRegExp) {
try {
Pattern p = Pattern.compile(posTag);
return synthesizeForPosTags(token.getLemma(), tag -> p.matcher(tag).matches());
} catch (PatternSyntaxException e) {
throw new RuntimeException("Error trying to synthesize POS tag " + posTag +
" (posTagRegExp: true) from token " + token.getToken(), e);
}
}
return removeExceptions(synthesize(token, posTag));
}
/**
* Synthesize forms for the given lemma and for all POS tags satisfying the given predicate.
* @since 5.3
*/
public String[] synthesizeForPosTags(String lemma, Predicate<String> acceptTag) throws IOException {
initPossibleTags();
List<String> results = new ArrayList<>();
for (String tag : possibleTags) {
if (acceptTag.test(tag)) {
results.addAll(lookup(lemma, tag));
}
}View on GitHub (pinned to 2e990059ce)
Solutions
- Inspect the chained cause to find the underlying failure (often an invalid regex in the POS tag)
- Simplify the POS-tag regular expression to isolate the failing construct
- Test the tag pattern against the synthesizer's list of possible tags to confirm it matches something
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/synthesis/BaseSynthesizer.java:261 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/c5da20e32028f69c.
Report an issue: GitHub.