{"record":{"id":"dd22712776922e1f","repo":"languagetool-org/languagetool","slug":"rule-error-the-number-unified-tokens-unicou","errorCode":null,"errorMessage":" rule error. The number unified tokens: \" + uniCounter + \" must be equal to the number of matched tokens: \" + matchedTokenCount + \"\\n Line: \" + pLocator.getLineNumber() + \", column: \" + pLocator.getColumnNumber() + \".","messagePattern":" rule error\\. The number unified tokens: \" \\+ uniCounter \\+ \" must be equal to the number of matched tokens: \" \\+ matchedTokenCount \\+ \"\\\\n Line: \" \\+ pLocator\\.getLineNumber\\(\\) \\+ \", column: \" \\+ pLocator\\.getColumnNumber\\(\\) \\+ \"\\.","errorType":"exception","errorClass":"SAXException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java","lineNumber":342,"sourceCode":"        }\n        caseSensitive = false;\n        if (disambExamples != null) {\n          rule.setExamples(disambExamples);\n        }\n        if (untouchedExamples != null) {\n          rule.setUntouchedExamples(untouchedExamples);\n        }\n        setRuleFilter(filterClassName, filterArgs, rule);\n        if (!rulegroupAntiPatterns.isEmpty()) {\n          rule.setAntiPatterns(rulegroupAntiPatterns);\n        }\n        if (!ruleAntiPatterns.isEmpty()) {\n          rule.setAntiPatterns(ruleAntiPatterns);\n          ruleAntiPatterns.clear();\n        }\n        rules.add(rule);\n        if (disambigAction == DisambiguationPatternRule.DisambiguatorAction.UNIFY && matchedTokenCount != uniCounter) {\n          throw new SAXException(language.getName() + \" rule error. The number unified tokens: \"\n                  + uniCounter + \" must be equal to the number of matched tokens: \" + matchedTokenCount\n                  + \"\\n Line: \" + pLocator.getLineNumber() + \", column: \"\n                  + pLocator.getColumnNumber() + \".\");\n        }\n        boolean singleTokenCorrection = endPos - startPos > 1;\n        if ((!singleTokenCorrection && (disambigAction == DisambiguationPatternRule.DisambiguatorAction.FILTER || disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE))\n                && (matchedTokenCount > 1)) {\n          throw new SAXException(\n                  language.getName() + \" rule error. Cannot replace or filter more than one token at a time.\"\n                          + \"\\n Line: \" + pLocator.getLineNumber() + \", column: \"\n                          + pLocator.getColumnNumber() + \".\");\n        }\n        patternTokens.clear();\n        posSelector = null;\n        disambExamples = null;\n        untouchedExamples = null;\n        startPos = -1;\n        endPos = -1;","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java#L324-L360","documentation":"Consistency check for UNIFY disambiguation rules: the number of unify elements collected for the rule must equal the number of tokens matched by the pattern, since unification applies per matched token. Fires at parse time when the rule XML declares mismatched unify features versus its pattern length.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:342 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add or remove unify elements so their count equals the number of matched pattern tokens","Adjust the pattern (or marker corrections) so matchedTokenCount matches uniCounter","Switch to a different action if per-token unification is not intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}