languagetool-org/languagetool · error · IOException

Format error in file " + path + ", line: " + line

Error message

Format error in file " + path + ", line: " + line

What it means

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.

Solutions

  1. Locate the offending line (printed in the exception message) in the file at 'path'.
  2. Ensure it has exactly one semicolon separating the two forms, e.g. 'color;colour'.
  3. Remove extra semicolons or fix a wrong separator (e.g. ',' -> ';').

Example fix

// before (data file)
color:colour
// after (data file)
color;colour
Defensive patterns

Strategy: validation

Validate before calling

// validate coherency data lines before loading
for (String line : Files.readAllLines(Paths.get(path))) {
    if (line.isEmpty() || line.startsWith("#")) continue;
    if (line.split(";", -1).length != 2)
        throw new IllegalStateException("Bad coherency line: " + line);
}

Try / catch

try { loader.loadWords(path, language); } catch (IOException e) { log.error("Coherency data format error: " + e.getMessage()); throw new UncheckedIOException(e); }

Prevention

When it happens

Trigger: 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 '#').

Common situations: Misspelled separator (comma or tab instead of semicolon); trailing semicolon on a line; contributors editing language coherency data by hand.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/a96b3487356bf426. Report an issue: GitHub.

Appendix: source

Thrown at languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java:52

 * @since 3.0
 */
public class WordCoherencyDataLoader {

  public Map<String, Set<String>> loadWords(String path) {
    InputStream stream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);
    Map<String, Set<String>> map = new Object2ObjectOpenHashMap<>();
    try (
      InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
      BufferedReader br = new BufferedReader(reader)
    ) {
      String line;
      while ((line = br.readLine()) != null) {
        if (line.isEmpty() || line.charAt(0) == '#') {   // ignore comments
          continue;
        }
        String[] parts = line.split(";");
        if (parts.length != 2) {
          throw new IOException("Format error in file " + path + ", line: " + line);
        }
        if(map.containsKey(parts[0])) {
          map.get(parts[0]).add(parts[1]);
        } else {
          map.put(parts[0], Stream.of(parts[1]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));
        }
        if(map.containsKey(parts[1])) {
          map.get(parts[1]).add(parts[0]);
        } else {
          map.put(parts[1], Stream.of(parts[0]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));
        }
      }
    } catch (IOException e) {
      throw new RuntimeException("Could not load coherency data from " + path, e);
    }
    return Collections.unmodifiableMap(map);
  }

View on GitHub (pinned to 2e990059ce)