{"record":{"id":"3ff476e202782f0a","repo":"languagetool-org/languagetool","slug":"invalid-line-format-de-item-count-en-item-coun","errorCode":null,"errorMessage":"Invalid line format (DE item count != EN item count): \" + line","messagePattern":"Invalid line format \\(DE item count != EN item count\\): \" \\+ line","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/translation/BeoLingusTranslator.java","lineNumber":94,"sourceCode":"      logger.info(\"Init dict done (\" + (t2-t1) + \"ms) - loaded \" + instance.getDeEnSize() + \" de -> en items.\");\n    }\n    return instance;\n  }\n\n  public BeoLingusTranslator(File file) throws IOException {\n    tagger = Languages.getLanguageForShortCode(\"de\").getTagger();\n    List<String> lines = Files.readAllLines(file.toPath());\n    for (String line : lines) {\n      if (line.trim().isEmpty() || line.startsWith(\"#\")) {\n        continue;\n      }\n      String[] parts = line.split(\" :: \");\n      String german = parts[0];\n      String english = parts[1];\n      String[] germanParts = german.split(\"\\\\|\");\n      String[] englishParts = english.split(\"\\\\|\");\n      if (germanParts.length != englishParts.length) {\n        throw new IOException(\"Invalid line format (DE item count != EN item count): \" + line);\n      }\n      int i = 0;\n      for (String germanPart : germanParts) {\n        handleItem(de2en, germanParts, englishParts, i, germanPart);\n        //handleItem(en2de, englishParts, germanParts, i, englishParts[i]);  -- direction not supported yet\n        i++;\n      }\n    }\n  }\n\n  private void handleItem(Map<String, List<TranslationEntry>> map, String[] germanParts, String[] englishParts, int i, String germanPart) {\n    germanPart = germanPart.replaceAll(\"/.*?/\", \"\");    // e.g. \"oder {conj} /o.; od./\"\n    List<String> germanSubParts = split(germanPart);\n    for (String germanSubPart : germanSubParts) {\n      String key = cleanForLookup(germanSubPart);\n      List<TranslationEntry> oldEntries = map.get(key);\n      if (oldEntries != null) {\n        if (!englishParts[i].trim().isEmpty()) {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/translation/BeoLingusTranslator.java#L76-L112","documentation":"BeoLingusTranslator loads a tab/separator-delimited bilingual dictionary file where each line is 'german :: english', and the '|' character separates alternative items on each side. When parsing a line, if the German side and English side contain a different number of '|' separated items, the parallel translation mapping cannot be built and an IOException is thrown naming the offending line.","triggerScenarios":"Calling the BeoLingusTranslator constructor on a dictionary resource file that contains a line where split(\"|\") on the German part yields a different count than on the English part, e.g. 'Haus :: house|building'.","commonSituations":"A corrupted or hand-edited BeoLingus dump; an updated dictionary file with a format drift; adding a synonym on one language side only; wrong file loaded into the translator.","solutions":["Open the dictionary file, find the reported line, and make the '|' item counts equal on both sides of ' :: '.","Remove extra '|' separators if they are not intended as parallel item delimiters.","Replace the dictionary resource with a known-good version of the BeoLingus data file."],"exampleFix":"// before (dictionary line)\nHaus|Gebäude :: house\n// after\nHaus|Gebäude :: house|building","handlingStrategy":"try-catch","validationCode":"String[] de = line.split(\" :: \")[0].split(\"\\\\|\");\nString[] en = line.split(\" :: \")[1].split(\"\\\\|\");\nif (de.length != en.length) throw new IllegalArgumentException(\"Mismatched items: \" + line);","typeGuard":null,"tryCatchPattern":"try (var reader = ...) { /* load dictionary */ } catch (IOException e) {\n  if (e.getMessage().startsWith(\"Invalid line format\")) { /* fix data file or skip line */ }\n}","preventionTips":["Keep '|' item counts symmetric on both sides of each dictionary line","Validate dictionary files after editing before shipping them","Use version-controlled, tested dictionary resources"],"tags":["languagetool","dictionary-parsing","io","data-format"],"backgroundTag":"invalid-argument-format","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"}