languagetool-org/languagetool · error

Could not tag and disambiguate '<token>'

Error message

Could not tag and disambiguate '<token>'

What it means

IrishPartialPosTagFilter.tag wraps the Irish tagger/disambiguator calls; if either throws an IOException (dictionary read failure, resource loading problem), it is rethrown as this RuntimeException naming the token being processed. It means a single token could not be analyzed during partial POS filtering.

Source

Thrown at languagetool-language-modules/ga/src/main/java/org/languagetool/rules/ga/IrishPartialPosTagFilter.java:52

 * will apply that have a single {@code <match>} element.
 * <b>Warning: Do not use this in disambiguation.xml, it would cause an endless loop,
 * use {@link NoDisambiguationIrishPartialPosTagFilter} instead.</b> 
 *
 * @since 2.8
 * @see NoDisambiguationIrishPartialPosTagFilter
 */
public class IrishPartialPosTagFilter extends PartialPosTagFilter {

  @Override
  protected List<AnalyzedTokenReadings> tag(String token) {
    try {
      var irishLanguage = Irish.getInstance();
      List<AnalyzedTokenReadings> tags = irishLanguage.getTagger().tag(Collections.singletonList(token));
      AnalyzedTokenReadings[] atr = tags.toArray(new AnalyzedTokenReadings[tags.size()]);
      AnalyzedSentence disambiguated = irishLanguage.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. Check the cause (IOException) for the missing resource path and restore the Irish tagger/dictionary resources on the classpath.
  2. Reinstall or redownload the full languagetool-language-modules/ga artifact.
  3. Verify resource files are readable by the process user.
  4. If building a custom distribution, ensure the tagger's resource files are included in the jar and loaded via the classloader, not the filesystem.

Example fix

// before (stripped jar)
jar without src/main/resources/org/languagetool/tagger/ga/*
// after
include all irish tagger/disambiguator resources in the build (maven-resources or shade config)
Defensive patterns

Strategy: try-catch

Validate before calling

// verify resources once at startup
try (InputStream in = getClass().getResourceAsStream("/org/languagetool/tagger/ga/irish.dict")) {
  if (in == null) throw new IllegalStateException("Irish tagger resources missing from classpath");
}

Try / catch

try { return filter.tag(token); } catch (RuntimeException e) { log.error("Tagging failed for '" + token + "'", e.getCause()); return Collections.emptyList(); }

Prevention

When it happens

Trigger: irishLanguage.getTagger().tag(...) or getDisambiguator().disambiguate(...) throws IOException while processing a token — typically missing/corrupt Irish tagging resources on the classpath or an I/O error reading dictionary files.

Common situations: Incomplete LanguageTool installation missing Irish dictionaries; fat-jar packaging that dropped resource files; read-permission problems on installed resources; running with a stripped classpath.

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/7c584a165e0dcd00. Report an issue: GitHub.