{"record":{"id":"1edd17e48ef182f2","repo":"languagetool-org/languagetool","slug":"could-not-tag-and-disambiguate-token-1edd17","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/RussianPartialPosTagFilter.java","lineNumber":49,"sourceCode":"/**\n * A {@link PartialPosTagFilter} for Russian that also runs the disambiguator. Note\n * that the disambiguator is called with a single token, so only rules\n * will apply that have a single {@code <match>} element.\n *\n * @since 3.6\n */\npublic class RussianPartialPosTagFilter extends PartialPosTagFilter {\n\n  @Override\n  protected List<AnalyzedTokenReadings> tag(String token) {\n    try {\n      var russianLanguage = Russian.getInstance();\n      List<AnalyzedTokenReadings> tags = russianLanguage.getTagger().tag(Collections.singletonList(token));\n      AnalyzedTokenReadings[] atr = tags.toArray(new AnalyzedTokenReadings[tags.size()]);\n      AnalyzedSentence disambiguated = russianLanguage.getDisambiguator().disambiguate(new AnalyzedSentence(atr));\n      return Arrays.asList(disambiguated.getTokens());\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n    }\n  }\n}\n","sourceCodeStart":31,"sourceCodeEnd":53,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/ru/src/main/java/org/languagetool/rules/ru/RussianPartialPosTagFilter.java#L31-L53","documentation":"RussianPartialPosTagFilter.tag() tags a single token with the Russian tagger and runs the disambiguator; if any step throws an IOException (typically while loading dictionaries or tagger resources), it is wrapped in this unchecked RuntimeException. It indicates the POS-tagging/disambiguation pipeline failed for the given token, not that the token is linguistically invalid.","triggerScenarios":"Calling tag(String) on RussianPartialPosTagFilter when the underlying Russian tagger or disambiguator throws IOException — e.g. dictionary resource files missing or unreadable, malformed user dictionaries, or I/O errors reading language module resources.","commonSituations":"Running LanguageTool in a packaged/deployed environment where Russian dictionary resources were not included in the classpath; corrupted or partially extracted .jar files; custom-user-directory configurations pointing to missing dictionary paths.","solutions":["Verify the Russian language module (languagetool-language-modules/ru) and its dictionary resources are on the classpath and intact.","Inspect the wrapped IOException cause (getCause()) to find the real resource/IO failure.","If a custom dictionary path is configured, confirm the files exist and are readable by the process.","Rebuild/redeploy the jar if resources were stripped by build packaging rules."],"exampleFix":"// before: IOException bubbles as bare RuntimeException\ncatch (IOException e) {\n  throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n}\n// after: fail fast with a clear resource check before tagging\nvar russianLanguage = Russian.getInstance();\nObjects.requireNonNull(token, \"token must not be null\");\ntry {\n  List<AnalyzedTokenReadings> tags = russianLanguage.getTagger().tag(Collections.singletonList(token));\n  ...\n} catch (IOException e) {\n  throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"': dictionary resources missing or unreadable\", e);\n}","handlingStrategy":"try-catch","validationCode":"boolean resourcesAvailable = getClass().getResource(\"/org/languagetool/resource/ru/\") != null;\nif (!resourcesAvailable) { throw new IllegalStateException(\"Russian dictionary resources missing from classpath\"); }","typeGuard":null,"tryCatchPattern":"try {\n  List<AnalyzedTokenReadings> result = filter.tag(token);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause(); // IOException from tagger/disambiguator\n  logger.warn(\"Tagging failed for token '{}': {}\", token, cause != null ? cause.getMessage() : e.getMessage());\n  // fall back to untagged token or skip the rule\n}","preventionTips":["Ensure the ru language module and its dictionary resources are packaged in your deployment.","Always inspect getCause() — the RuntimeException wraps the real IOException.","Test tagging at application startup to fail fast on missing resources."],"tags":["java","nlp","postagging","io-error","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"}