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

  1. Verify the French language module (languagetool-language-modules/fr resources: french tags dictionaries) is present and intact on the classpath.
  2. Re-download/rebuild the LanguageTool distribution or fix the corrupted jar.
  3. Check the wrapped IOException cause for the real file/resource path that failed and restore it.
  4. 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

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


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/98d851a530feef20. Report an issue: GitHub.