languagetool-org/languagetool · error · RuntimeException
Could not tag and disambiguate '" + token + "'
Error message
Could not tag and disambiguate '" + token + "'
What it means
FrenchPartialPosTagFilter.tag tags a single token with the French tagger and disambiguates it, wrapping any IOException from tagging/disambiguation in a RuntimeException. The token could not be POS-tagged and disambiguated, usually because the underlying language data failed to load or read.
Source
Thrown at languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/FrenchPartialPosTagFilter.java:49
/**
* A {@link PartialPosTagFilter} for French that also runs the disambiguator. Note
* that the disambiguator is called with a single token, so only rules
* will apply that have a single {@code <match>} element.
*
* @since 3.1
*/
public class FrenchPartialPosTagFilter extends PartialPosTagFilter {
@Override
protected List<AnalyzedTokenReadings> tag(String token) {
try {
var frenchLanguage = French.getInstance();
List<AnalyzedTokenReadings> tags = frenchLanguage.getTagger().tag(Collections.singletonList(token));
AnalyzedTokenReadings[] atr = tags.toArray(new AnalyzedTokenReadings[tags.size()]);
AnalyzedSentence disambiguated = frenchLanguage.getDisambiguator().disambiguate(new AnalyzedSentence(atr));
return Arrays.asList(disambiguated.getTokens());
} catch (IOException e) {
throw new RuntimeException("Could not tag and disambiguate '" + token + "'", e);
}
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Verify the French language module (languagetool-language-modules/fr resources: french tags dictionaries) is present and intact on the classpath.
- Re-download/rebuild the LanguageTool distribution or fix the corrupted jar.
- Check the wrapped IOException cause for the real file/resource path that failed and restore it.
- Catch and log the RuntimeException at the rule-match level so one token failure does not abort the whole check run.
Example fix
// before
List<AnalyzedTokenReadings> tags = frenchLanguage.getTagger().tag(Collections.singletonList(token));
// after
try {
List<AnalyzedTokenReadings> tags = frenchLanguage.getTagger().tag(Collections.singletonList(token));
} catch (RuntimeException e) {
LOG.warn("POS tagging failed for token '" + token + "'", e);
return Collections.emptyList();
} Defensive patterns
Strategy: try-catch
Try / catch
try {
List<AnalyzedTokenReadings> toks = filter.tag(token);
} catch (RuntimeException e) {
LOG.error("Tagging failed for '" + token + "'", e.getCause());
// degrade gracefully: skip this rule match
} Prevention
- Ship the French language module resources (dictionaries) in your deployment.
- Verify jar integrity after builds/updates.
- Log the cause chain — the real reason is the wrapped IOException.
When it happens
Trigger: tag() calls French.getInstance().getTagger().tag(...) or getDisambiguator().disambiguate(...) and an IOException is raised — e.g. tagger dictionary files missing/corrupt on the classpath, or I/O failure while reading language resources — during acceptRuleMatch of a rule using this filter.
Common situations: Incomplete LanguageTool deployment (missing fr dictionary resources in languagetool-language-modules jar); custom builds without French data; low-level environment I/O problems (bad jar, permissions).
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 load coherency data from " + path
- Set only 'weekDay' and 'date' for " + DMYDateCheckFilter.cla
- Expected date in format 'dd-mm-yyyy': '" + dateString + "'
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/98d851a530feef20.
Report an issue: GitHub.