{"record":{"id":"a96b3487356bf426","repo":"languagetool-org/languagetool","slug":"format-error-in-file-path-line-line-a96b34","errorCode":null,"errorMessage":"Format error in file \" + path + \", line: \" + line","messagePattern":"Format error in file \" \\+ path \\+ \", line: \" \\+ line","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java","lineNumber":52,"sourceCode":" * @since 3.0\n */\npublic class WordCoherencyDataLoader {\n\n  public Map<String, Set<String>> loadWords(String path) {\n    InputStream stream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);\n    Map<String, Set<String>> map = new Object2ObjectOpenHashMap<>();\n    try (\n      InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);\n      BufferedReader br = new BufferedReader(reader)\n    ) {\n      String line;\n      while ((line = br.readLine()) != null) {\n        if (line.isEmpty() || line.charAt(0) == '#') {   // ignore comments\n          continue;\n        }\n        String[] parts = line.split(\";\");\n        if (parts.length != 2) {\n          throw new IOException(\"Format error in file \" + path + \", line: \" + line);\n        }\n        if(map.containsKey(parts[0])) {\n          map.get(parts[0]).add(parts[1]);\n        } else {\n          map.put(parts[0], Stream.of(parts[1]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));\n        }\n        if(map.containsKey(parts[1])) {\n          map.get(parts[1]).add(parts[0]);\n        } else {\n          map.put(parts[1], Stream.of(parts[0]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));\n        }\n      }\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not load coherency data from \" + path, e);\n    }\n    return Collections.unmodifiableMap(map);\n  }\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java#L34-L70","documentation":"WordCoherencyDataLoader.loadWords reads a coherency data file where each line must contain exactly two semicolon-separated fields ('word;word'). This IOException is thrown for any non-empty, non-comment line that does not split into exactly 2 parts.","triggerScenarios":"Calling loadFromPath/loadWords on a coherency file containing a line with zero or multiple semicolons, e.g. 'word' or 'a;b;c' (no comments allowed except lines starting with '#').","commonSituations":"Misspelled separator (comma or tab instead of semicolon); trailing semicolon on a line; contributors editing language coherency data by hand.","solutions":["Locate the offending line (printed in the exception message) in the file at 'path'.","Ensure it has exactly one semicolon separating the two forms, e.g. 'color;colour'.","Remove extra semicolons or fix a wrong separator (e.g. ',' -> ';')."],"exampleFix":"// before (data file)\ncolor:colour\n// after (data file)\ncolor;colour","handlingStrategy":"validation","validationCode":"// validate coherency data lines before loading\nfor (String line : Files.readAllLines(Paths.get(path))) {\n    if (line.isEmpty() || line.startsWith(\"#\")) continue;\n    if (line.split(\";\", -1).length != 2)\n        throw new IllegalStateException(\"Bad coherency line: \" + line);\n}","typeGuard":null,"tryCatchPattern":"try { loader.loadWords(path, language); } catch (IOException e) { log.error(\"Coherency data format error: \" + e.getMessage()); throw new UncheckedIOException(e); }","preventionTips":["Use ';' as the only separator in coherency files","Check for trailing semicolons on lines","Add CI format checks for language data files"],"tags":["java","data-file","parsing","languagetool"],"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"}