languagetool-org/languagetool · critical
Could not tag and disambiguate '<token>'
Error message
Could not tag and disambiguate '<token>'
What it means
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.
Source
Thrown at languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/NoDisambiguationPortuguesePartialPosTagFilter.java:46
import java.util.Collections;
import java.util.List;
/**
* A {@link PartialPosTagFilter} for Portuguese that does not run the disambiguator.
* @since 3.8
*/
public class NoDisambiguationPortuguesePartialPosTagFilter extends PartialPosTagFilter {
private final Tagger tagger = Portuguese.getInstance().getTagger();
@Override
protected List<AnalyzedTokenReadings> tag(String token) {
try {
List<AnalyzedTokenReadings> tags = tagger.tag(Collections.singletonList(token));
AnalyzedTokenReadings[] atr = tags.toArray(new AnalyzedTokenReadings[0]);
return Arrays.asList(atr);
} catch (IOException e) {
throw new RuntimeException("Could not tag and disambiguate '" + token + "'", e);
}
}
}
View on GitHub (pinned to 2e990059ce)
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
Example fix
// before
catch (IOException e) {
throw new RuntimeException("Could not tag and disambiguate '" + token + "'", e);
}
// after
catch (IOException e) {
// inspect e for missing pt dictionary resources; rebuild module if resources absent
throw new RuntimeException("Could not tag and disambiguate '" + token + "'", e);
}
// root fix: rebuild so pt tagger dictionary is on classpath Defensive patterns
Strategy: try-catch
Validate before calling
// before relying on the filter, verify resources are loadable:
try (InputStream is = getClass().getResourceAsStream("/pt/portuguese.dict")) {
if (is == null) throw new IllegalStateException("Portuguese tagger dictionary missing from classpath");
} Try / catch
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); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- Cannot synthesize <token><exception>
- Could not load coherency data from " + path
- Cannot load or parse input stream of '${filename}'
- Error analyzing sentence: '${sentence}'
- Could not find filter class: '${className}' - make sure to u
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/95c23831d922cb77.
Report an issue: GitHub.