{"record":{"id":"95c23831d922cb77","repo":"languagetool-org/languagetool","slug":"could-not-tag-and-disambiguate-token-95c238","errorCode":null,"errorMessage":"Could not tag and disambiguate '<token>'","messagePattern":"Could not tag and disambiguate '<token>'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/NoDisambiguationPortuguesePartialPosTagFilter.java","lineNumber":46,"sourceCode":"import java.util.Collections;\nimport java.util.List;\n\n/**\n * A {@link PartialPosTagFilter} for Portuguese that does not run the disambiguator.\n * @since 3.8\n */\npublic class NoDisambiguationPortuguesePartialPosTagFilter extends PartialPosTagFilter {\n\n  private final Tagger tagger = Portuguese.getInstance().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[0]);\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":28,"sourceCodeEnd":50,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/NoDisambiguationPortuguesePartialPosTagFilter.java#L28-L50","documentation":"NoDisambiguationPortuguesePartialPosTagFilter.tag runs the Portuguese part-of-speech tagger on a single token and wraps any IOException into this RuntimeException. It means the morphological tagger (dictionary lookup) failed while analyzing the token inside a POS-tag filter used by a disambiguator rule.","triggerScenarios":"tagger.tag(List.of(token)) throws IOException — typically when the Portuguese tagger dictionary (.info/.dict binary resources) cannot be read, is missing/corrupt in the built module, or an I/O problem occurs loading resources from the classpath/jar.","commonSituations":"Running LanguageTool from a partially built or mispackaged jar where languagetool-language-modules/pt resources are absent; custom builds missing the Portuguese dictionary; classpath misconfiguration in embedded usage.","solutions":["Rebuild the pt language module so the tagger dictionary resources are packaged (mvn package) and confirm the jar contains the pt .dict/.info files","Check the wrapped IOException cause (getCause()) for the real resource-loading failure (file path, permission, corrupt dictionary)","If running from an IDE/embedded, ensure the pt module's src/main/resources are on the classpath"],"exampleFix":"// before\ncatch (IOException e) {\n  throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n}\n// after\ncatch (IOException e) {\n  // inspect e for missing pt dictionary resources; rebuild module if resources absent\n  throw new RuntimeException(\"Could not tag and disambiguate '\" + token + \"'\", e);\n}\n// root fix: rebuild so pt tagger dictionary is on classpath","handlingStrategy":"try-catch","validationCode":"// before relying on the filter, verify resources are loadable:\ntry (InputStream is = getClass().getResourceAsStream(\"/pt/portuguese.dict\")) {\n  if (is == null) throw new IllegalStateException(\"Portuguese tagger dictionary missing from classpath\");\n}","typeGuard":null,"tryCatchPattern":"try { List<AnalyzedTokenReadings> atr = filter.tag(token); } catch (RuntimeException e) { Throwable cause = e.getCause(); if (cause instanceof IOException io) log.error(\"Tagger dictionary I/O problem: {}\", io.getMessage()); throw new IllegalStateException(\"POS tagger unavailable — check pt dictionary resources\", e); }","preventionTips":["Verify the built jar contains the pt tagger dictionary resources before deployment","Always inspect getCause() — the RuntimeException wraps the real IOException","Use a full Maven build (mvn package) rather than partial classpath assembly for LanguageTool modules"],"tags":["java","nlp","postagger","io","classpath"],"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"}