languagetool-org/languagetool · error
Found more than one spell rule:
Error message
Found more than one spell rule:
What it means
UnknownWordFinderForCsv.getSpellingCheckRule mirrors UnknownWordFinder: it expects exactly one dictionary-based spelling rule among active rules and throws a RuntimeException when a second one is encountered, because the CSV variant also needs a single well-defined speller rule.
Source
Thrown at languagetool-dev/src/main/java/org/languagetool/dev/UnknownWordFinderForCsv.java:52
* Print words from CSV that are unknown to the spell checker, sorted by number of occurrences.
*/
public class UnknownWordFinderForCsv {
private void run(File dir, JLanguageTool lt) throws IOException {
SpellingCheckRule spellerRule = getSpellingCheckRule(lt);
List<Path> files = Files.walk(dir.toPath()).filter(Files::isRegularFile).collect(Collectors.toList());
for (Path file : files) {
handle(file, spellerRule);
}
}
@NotNull
private SpellingCheckRule getSpellingCheckRule(JLanguageTool lt) {
SpellingCheckRule spellerRule = null;
for (Rule rule : lt.getAllActiveRules()) {
if (rule.isDictionaryBasedSpellingRule()) {
if (spellerRule != null) {
throw new RuntimeException("Found more than one spell rule: " + rule + ", " + spellerRule);
}
spellerRule = (SpellingCheckRule) rule;
}
}
if (spellerRule == null) {
throw new RuntimeException("No speller rule found for " + lt.getLanguage());
}
return spellerRule;
}
private void handle(Path f, SpellingCheckRule rule) throws IOException {
int i = 0;
if (f.toString().toLowerCase().endsWith(".csv")) {
List<String> lines = Files.readAllLines(f);
for (String line : lines) {
String[] parts = line.split(",");
String word = parts[0].replace("\"", "");
if (rule.isMisspelled(word)) {View on GitHub (pinned to 2e990059ce)
Solutions
- Disable all but one dictionary-based spelling rule before calling getSpellingCheckRule
- Run the tool for a language with a single active speller rule
- Modify the script to tolerate multiple speller rules by picking one explicitly
Example fix
// before SpellingCheckRule rule = getSpellingCheckRule(lt); // after lt.getAllActiveRules().stream().filter(Rule::isDictionaryBasedSpellingRule).skip(1).forEach(r -> lt.disableRule(r.getId())); SpellingCheckRule rule = getSpellingCheckRule(lt);
Defensive patterns
Strategy: validation
Validate before calling
long n = lt.getAllActiveRules().stream().filter(Rule::isDictionaryBasedSpellingRule).count();
if (n != 1) throw new IllegalStateException("Expected exactly 1 spelling rule, got " + n); Try / catch
try { new UnknownWordFinderForCsv(...).run(); } catch (RuntimeException e) { if (e.getMessage().startsWith("Found more than one spell rule")) { System.err.println("Disable extra spelling rules for this language"); } } Prevention
- Keep one active dictionary-based spelling rule per language
- Disable secondary speller rules before CSV scans
- Assert speller-rule counts in configuration tests
When it happens
Trigger: Running UnknownWordFinderForCsv with a JLanguageTool whose active rule set contains two or more dictionary-based spelling rules.
Common situations: Languages with multiple active spell checkers; extra spelling rules enabled via custom config; behavior changes after adding new spelling rules to a language module.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- No speller rule found for
- Found more than one spell rule:
- No speller rule found for
- No rules are active. Please make sure your rule ids (<option
- Could not activate rules
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/afe9f228af1470c6.
Report an issue: GitHub.