{"record":{"id":"6d893d5aee6438bb","repo":"languagetool-org/languagetool","slug":"could-not-tag-and-disambiguate-token-6d893d","errorCode":null,"errorMessage":"Could not tag and disambiguate '<token>'","messagePattern":"Could not tag and disambiguate '<token>'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/ru/src/main/java/org/languagetool/rules/ru/NoDisambiguationRussianPartialPosTagFilter.java","lineNumber":45,"sourceCode":"import java.util.*;\n\n/**\n * A {@link PartialPosTagFilter} for Russian that does not run the disambiguator.\n * @since 5.1\n * @see RussianPartialPosTagFilter\n */\npublic class NoDisambiguationRussianPartialPosTagFilter extends PartialPosTagFilter {\n\n  private final Tagger tagger = Languages.getLanguageForShortCode(\"ru\").getTagger();\n\n  @Override\n  protected List<AnalyzedTokenReadings> tag(String token) {\n    try {\n      List<AnalyzedTokenReadings> tags = tagger.tag(Collections.singletonList(token));\n      AnalyzedTokenReadings[] atr = tags.toArray(new AnalyzedTokenReadings[tags.size()]);\n      return Arrays.asList(atr);\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n    }\n  }\n}\n","sourceCodeStart":27,"sourceCodeEnd":49,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/ru/src/main/java/org/languagetool/rules/ru/NoDisambiguationRussianPartialPosTagFilter.java#L27-L49","documentation":"NoDisambiguationRussianPartialPosTagFilter.tag() calls the Russian base-form tagger (BaseTagger.tag) on a single token; if the tagger throws IOException (dictionary/resource read failure), the method wraps it in a RuntimeException with this message. The filter cannot produce part-of-speech readings for the token, so rule evaluation fails for that match.","triggerScenarios":"An IOException from tagger.tag() — typically the Russian POS dictionary/lookup resource (e.g. the hunspell/dict files under languagetool-language-modules/ru resources) missing or unreadable at runtime; also occurs when running LanguageTool from a build whose ru module resources were not packaged, or an underlying stream error while loading tagger data lazily on first use.","commonSituations":"Running a partial/custom build that omitted the ru tagger dictionaries; deploying only some jars so resource files are not on the classpath; file-permission or corrupt-jar issues in an extracted distribution; first token tagged triggers lazy dictionary load which fails.","solutions":["Verify the Russian tagger dictionary resources exist in the ru module jar / distribution (check languagetool-language-modules/ru/src/main/resources) and rebuild with 'mvn package' if missing","Check the wrapped IOException (the cause in the stack trace) for the exact missing resource path and restore it to the classpath","Reinstall or re-extract the full LanguageTool distribution; ensure no jars were excluded and files are readable by the runtime user","If you maintain a fork, pre-validate dictionary availability at startup instead of failing per-token inside tag()"],"exampleFix":"// before\n} catch (IOException e) {\n  throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n}\n// after\n} catch (IOException e) {\n  LOGGER.error(\"Tagger resource lookup failed for token '{}': {}\", token, e.getMessage(), e);\n  return Collections.singletonList(new AnalyzedTokenReadings(token, 0));\n}","handlingStrategy":"try-catch","validationCode":"// before rule evaluation, verify the ru tagger dictionary is loadable\nURL dict = getClass().getResource(\"/ru/russian.dict\");\nif (dict == null) {\n  throw new IllegalStateException(\"Russian tagger dictionary missing from classpath — rebuild/extract the full distribution\");\n}","typeGuard":"boolean taggerResourcesAvailable() {\n  try (InputStream in = getClass().getResourceAsStream(\"/ru/russian.dict\")) {\n    return in != null;\n  } catch (IOException e) {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  analyzed = posFilter.tag(token);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause();\n  if (cause instanceof IOException) {\n    log.error(\"Tagger dictionary unreadable ({}): check ru module resources/classpath\", cause.getMessage());\n    return new AnalyzedTokenReadings(token, 0); // untagged reading, skip POS rules\n  }\n  throw e;\n}","preventionTips":["Ship and verify the complete ru language module (tagger dictionaries) in your deployment","Smoke-test tagging one known Russian word at application startup to fail fast on missing resources","Keep LT_VERSION and all language module jars from the same build","Check file permissions and jar integrity when running from an extracted distribution","Read e.getCause() first — the real problem is the wrapped IOException, not the token"],"tags":["java","russian","nlp","postagging","ioexception","languagetool"],"backgroundTag":"file-read-failed","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}