languagetool-org/languagetool · error · RuntimeException

Could not tag '" + term + "'

Error message

Could not tag '" + term + "'

What it means

getTranslationsForBaseforms first tags the input term with the English tagger, then looks up translations. If the tagging step throws IOException (tagger resource/IO failure), it is wrapped in a RuntimeException with the message 'Could not tag <term>', preserving the cause.

Source

Thrown at languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/translation/BeoLingusTranslator.java:220

    }
    List<TranslationEntry> sortedList = new ArrayList<>(entriesSet);
    Collections.sort(sortedList, (t1, t2) -> Integer.compare(t2.getItemCount(), t1.getItemCount()));
    return sortedList;
  }

  @NotNull
  private List<TranslationEntry> getTranslationsForBaseforms(String term, Map<String, List<TranslationEntry>> map) {
    List<TranslationEntry> result = new ArrayList<>();
    try {
      List<AnalyzedTokenReadings> readings = tagger.tag(Collections.singletonList(term));
      readings.addAll(tagger.tag(Collections.singletonList(StringTools.uppercaseFirstChar(term))));  // user can spell German noun lowercase here
      for (AnalyzedTokenReadings reading : readings) {
        List<AnalyzedToken> aTokens = reading.getReadings();
        addResultsForTokens(map, aTokens, result);
      }
      return result;
    } catch (IOException e) {
      throw new RuntimeException("Could not tag '" + term + "'", e);
    }
  }

  private void addResultsForTokens(Map<String, List<TranslationEntry>> map, List<AnalyzedToken> aTokens, List<TranslationEntry> result) {
    for (AnalyzedToken aToken : aTokens) {
      String lemma = aToken.getLemma();
      if (lemma != null) {
        List<TranslationEntry> tmp = map.get(lemma.toLowerCase());
        if (tmp != null) {
          for (TranslationEntry tmpEntry : tmp) {
            if (!result.contains(tmpEntry)) {
              TranslationEntry entry = cleanTranslationEntry(tmpEntry, aToken);
              if (entry != null) {
                result.add(entry);
              }
            }
          }
        }

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Check the wrapped IOException cause to identify which tagger resource failed to load.
  2. Rebuild/repair the English language module so tagger dictionaries are on the classpath.
  3. Ensure the term being tagged is valid non-empty input the tagger can process.
Defensive patterns

Strategy: try-catch

Validate before calling

if (term == null || term.isBlank()) return Collections.emptyList();

Try / catch

try {
  List<TranslationEntry> r = translator.getTranslationsForBaseforms(term);
} catch (RuntimeException e) {
  if (e.getCause() instanceof IOException io) { /* handle missing tagger resources */ }
}

Prevention

When it happens

Trigger: Calling translationsForBaseforms (via getTranslationsForBaseforms) when the underlying tagger's tag() call throws IOException — typically missing or unreadable tagger dictionary resources.

Common situations: Running with a broken/incomplete languagetool-language-modules-en build where tagging data is missing; resource loading failures in packaged jars; corrupted language module installation.

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