{"record":{"id":"0c8752e8aa97e944","repo":"languagetool-org/languagetool","slug":"language-getname-rule-error-the-number","errorCode":null,"errorMessage":"\" + language.getName() + \" rule error. The number of interpretations specified with wd: \" + newWdList.size() + \" must be equal to the number of matched tokens (\" + matchedTokenCount + \")\" + \"\\n Line: \" + pLocator.getLineNumber() + \", column: \" + pLocator.getColumnNumber() + \".","messagePattern":"\" \\+ language\\.getName\\(\\) \\+ \" rule error\\. The number of interpretations specified with wd: \" \\+ newWdList\\.size\\(\\) \\+ \" 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":314,"sourceCode":"\n        endPositionCorrection = endPos - tokenCountForMarker;\n        if (startPos != -1 && endPos != -1) {\n          rule.setStartPositionCorrection(startPos);\n          rule.setEndPositionCorrection(endPositionCorrection);\n        } else {\n          startPos = 0;\n          endPos = tokenCountForMarker;\n        }\n        rule.setSubId(inRuleGroup ? StringInterner.intern(Integer.toString(subId)) : \"1\");\n\n        int matchedTokenCount = endPos - startPos;\n        if (newWdList != null) {\n          if (disambigAction == DisambiguationPatternRule.DisambiguatorAction.ADDCHUNK || \n              disambigAction == DisambiguationPatternRule.DisambiguatorAction.ADD || disambigAction == DisambiguationPatternRule.DisambiguatorAction.REMOVE\n                  || disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE) {\n            if ((!newWdList.isEmpty() && disambigAction == DisambiguationPatternRule.DisambiguatorAction.REPLACE)\n                    && newWdList.size() != matchedTokenCount) {\n              throw new SAXException(\n                      language.getName() + \" rule error. The number of interpretations specified with wd: \"\n                              + newWdList.size()\n                              + \" must be equal to the number of matched tokens (\" + matchedTokenCount + \")\"\n                              + \"\\n Line: \" + pLocator.getLineNumber() + \", column: \"\n                              + pLocator.getColumnNumber() + \".\");\n            }\n            rule.setNewInterpretations(newWdList.toArray(new AnalyzedToken[0]));\n          }\n          newWdList.clear();\n        }\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);","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java#L296-L332","documentation":"Consistency check when finishing a disambiguation rule: for actions that interpret matched tokens, the wd elements must correspond one-to-one with the tokens matched by the pattern (marker-adjusted count). Fires when a rule XML declares more or fewer wd interpretations than the pattern has tokens, at line/column of the rule group end.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationRuleHandler.java:314 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Adjust the number of wd elements in the rule to match the number of pattern tokens","Fix the pattern length or marker span so matchedTokenCount equals the wd list size","Split the rule if different token counts need different interpretations"],"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-14T05:17:10.506Z"}