languagetool-org/languagetool · error
Cannot synthesize <token><exception>
Error message
Cannot synthesize <token><exception>
What it means
RegularIrregularParticipleFilter.acceptRuleMatch synthesizes the desired participle form of a verb using the Portuguese synthesizer. If synthesize(AnalyzedToken, postag, true) throws an IOException (typically the synthesizer dictionary could not be read or the requested form cannot be generated), it is rethrown as this IOException('Cannot synthesize <token><exception>').
Source
Thrown at languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/RegularIrregularParticipleFilter.java:74
for (AnalyzedToken at : atr) {
if (at.getPOSTag() != null && at.getPOSTag().startsWith("VMP")) {
selectedAT = at;
desiredPostag = at.getPOSTag();
}
}
// assente SC assentado SM
if (desiredPostag.endsWith("C")) {
desiredPostag = desiredPostag.substring(0,desiredPostag.length() - 1) + "[MC]";
} else {
desiredPostag = desiredPostag.substring(0,desiredPostag.length() - 1)
+ "["+ desiredPostag.substring(desiredPostag.length() - 1) + "C]";
}
String[] participles;
try {
participles = synth.synthesize(selectedAT, desiredPostag, true);
} catch (IOException e) {
throw new IOException("Cannot synthesize " + selectedAT.toString() + e);
}
if (participles != null && participles.length > 1) {
if (direction.equalsIgnoreCase("RegularToIrregular") && isRegular(atr.getToken())) {
if (!isRegular(participles[0])) {
replacement = participles[0];
} else if (!isRegular(participles[1])) {
replacement = participles[1];
}
} else if (direction.equalsIgnoreCase("IrregularToRegular") && !isRegular(atr.getToken())) {
if (isRegular(participles[0])) {
replacement = participles[0];
} else if (isRegular(participles[1])) {
replacement = participles[1];
}
}
if (replacement != null) {
String message = match.getMessage();
RuleMatch ruleMatch = new RuleMatch(match.getRule(), match.getSentence(), match.getFromPos(),View on GitHub (pinned to 2e990059ce)
Solutions
- Inspect the concatenated exception in the message to distinguish a missing-form vs dictionary-I/O problem; rebuild the pt module if resources are missing
- Extend the synthesizer's exception data (irregular participle list) for the verb/token shown in the message
- Guard the filter: if synthesize returns no usable forms, skip the match instead of propagating (or catch IOException and return the unmodified match)
Example fix
// before
try {
participles = synth.synthesize(selectedAT, desiredPostag, true);
} catch (IOException e) {
throw new IOException("Cannot synthesize " + selectedAT.toString() + e);
}
// after
try {
participles = synth.synthesize(selectedAT, desiredPostag, true);
} catch (IOException e) {
return Collections.singletonList(match); // skip suggestion instead of failing the rule
} Defensive patterns
Strategy: fallback
Validate before calling
// confirm the verb has irregular participle data before applying the rule:
try {
AnalyzedToken at = new AnalyzedToken(verb, postag, lemma);
String[] forms = synth.synthesize(at, desiredPostag, true);
if (forms == null || forms.length == 0) skip = true; // no synthesized participle
} catch (IOException e) { skip = true; } Try / catch
try { return super.acceptRuleMatch(match, propositions, args); } catch (IOException e) { log.warn("Participle synthesis failed: {}", e.getMessage()); return Collections.singletonList(match); /* leave text unchanged */ } Prevention
- Prefer skipping the suggestion over propagating synthesis failures in grammar filters
- Keep the pt synthesizer/exception dictionaries up to date in your build
- Log the token and POS tag from the message to extend irregular-verb data for recurring cases
When it happens
Trigger: Calling synthesize on an AnalyzedToken with a POS tag for which the Portuguese synthesis dictionary has no forms, or when the synthesis dictionary resource fails to load (IOException from the binary dictionary reader).
Common situations: Rule pair RegularToIrregular/IrregularToRegular applied to verbs missing from the synthesizer's exception dictionary; corrupted/missing pt dictionary in a custom build; unexpected POS tags produced upstream by the tagger.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Could not find day of week for '<dayStr>'
- Could not find month '<monthStr>'
- Could not find day of week for '<dayStr>'
- Could not find month '<monthStr>'
- Could not find day of week for '<dayStr>'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/0c954793e83bf11a.
Report an issue: GitHub.