languagetool-org/languagetool · error
Language
Error message
Language
What it means
ConfusionRuleEvaluator's constructor asks the language for its language-model-based rules via language.getRelevantLanguageModelRules(...). If that returns null, the language has no language model support at all, so evaluation of confusion rules is impossible and the constructor throws 'Language X doesn't seem to support a language model'.
Source
Thrown at languagetool-dev/src/main/java/org/languagetool/dev/bigdata/ConfusionRuleEvaluator.java:74
private static final List<Long> EVAL_FACTORS = Arrays.asList(10L, 100L, 1_000L, 10_000L, 100_000L, 1_000_000L, 10_000_000L);
private static final int MAX_SENTENCES = 1000;
private final Language language;
private final boolean caseSensitive;
private final boolean bothDirections; // replace A by B and vice versa?
private final ConfusionProbabilityRule rule;
private final Map<Long, RuleEvalValues> evalValues = new HashMap<>();
private boolean verbose = true;
ConfusionRuleEvaluator(Language language, LanguageModel languageModel, boolean caseSensitive, boolean bothDirections) {
this.language = language;
this.caseSensitive = caseSensitive;
this.bothDirections = bothDirections;
try {
List<Rule> rules = language.getRelevantLanguageModelRules(JLanguageTool.getMessageBundle(), languageModel, null);
if (rules == null) {
throw new RuntimeException("Language " + language + " doesn't seem to support a language model");
}
ConfusionProbabilityRule foundRule = null;
for (Rule rule : rules) {
if (rule.getId().equals(ConfusionProbabilityRule.RULE_ID)) {
foundRule = (ConfusionProbabilityRule)rule;
break;
}
}
if (foundRule == null) {
throw new RuntimeException("Language " + language + " has no language model rule with id " + ConfusionProbabilityRule.RULE_ID);
} else {
this.rule = foundRule;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Use a language that supports language model rules (e.g. English, German, French) — check the module implements getRelevantLanguageModelRules with a non-null list.
- Configure the language model: pass the model directory via JLanguageTool.withLanguageModel(new LanguageModel(dir)) or the -lm command line option before constructing the evaluator.
- Verify the language module jar is on the classpath so the full language implementation (not a stub) is loaded.
- Guard the evaluator construction: check getRelevantLanguageModelRules != null beforehand and skip unsupported languages.
Example fix
// before
ConfusionRuleEvaluator evaluator = new ConfusionRuleEvaluator(language, languageModel, caseSensitive, bothDirections);
// after
List<Rule> lmRules = language.getRelevantLanguageModelRules(JLanguageTool.getMessageBundle(), languageModel, null);
if (lmRules == null) {
System.err.println("Skipping " + language + ": no language model support");
return;
}
ConfusionRuleEvaluator evaluator = new ConfusionRuleEvaluator(language, languageModel, caseSensitive, bothDirections); Defensive patterns
Strategy: try-catch
Validate before calling
List<Rule> lmRules = language.getRelevantLanguageModelRules(JLanguageTool.getMessageBundle(), languageModel, null);
if (lmRules == null || lmRules.isEmpty()) {
throw new UnsupportedOperationException(language + " has no language model rules; pass a supported language and configure -lm");
} Try / catch
try {
evaluator = new ConfusionRuleEvaluator(language, languageModel, caseSensitive, bothDirections);
} catch (RuntimeException e) {
if (e.getMessage().contains("doesn't seem to support a language model")) {
System.err.println("Skipping " + language + " (no LM support); supply -lm <modelDir> or a supported language");
}
} Prevention
- Only evaluate confusion rules for languages known to implement language model rules
- Always configure the language model directory (JLanguageTool.withLanguageModel / -lm) before use
- Check getRelevantLanguageModelRules() != null as a precondition in batch scripts
- Keep the full language module jar on the classpath (no stub/demo Language objects)
When it happens
Trigger: Constructing ConfusionRuleEvaluator with a Language whose getRelevantLanguageModelRules returns null — i.e. the language module does not implement language model rules (most languages), or the rules cannot be created because no language model was wired in.
Common situations: Running confusion-rule evaluation for a language like a small-language module that has no ConfusionProbabilityRule implementation; passing a demo/test Language object instead of a full module language; forgetting to configure the language model directory so the relevant rules are not registered.
Related errors
- List of language models is empty
- suppressMisspelledMatch must be a valid regex
- suppressMisspelledSuggestions must be a valid regex
- Missing key '${key}'
- Got no rule match:
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/dc963f538ee31cfd.
Report an issue: GitHub.