languagetool-org/languagetool · error · RuntimeException
Format error in file " + path + ", line: " + line + ", " + "
Error message
Format error in file " + path + ", line: " + line + ", " + "expected 3 semicolon-separated parts, got " + parts.length
What it means
ConfusionPairsDataLoader.loadWords parses a data file line by line and expects each non-comment line to have exactly 3 semicolon-separated parts (word, form, tag). A malformed line produces a RuntimeException naming the file, line, actual and expected part counts.
Source
Thrown at languagetool-language-modules/es/src/main/java/org/languagetool/rules/es/ConfusionPairsDataLoader.java:49
* Load data for {@link AccentuationCheckRule}.
* @since 3.3
*/
class ConfusionPairsDataLoader {
private static final String FILE_ENCODING = "utf-8";
Map<String, AnalyzedTokenReadings> loadWords(String path) {
final Map<String, AnalyzedTokenReadings> map = new HashMap<>();
final InputStream inputStream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);
try (Scanner scanner = new Scanner(inputStream, FILE_ENCODING)) {
while (scanner.hasNextLine()) {
final String line = scanner.nextLine().trim();
if (line.isEmpty() || line.charAt(0) == '#') { // ignore comments
continue;
}
final String[] parts = line.split(";");
if (parts.length != 3) {
throw new RuntimeException("Format error in file " + path + ", line: "
+ line + ", " + "expected 3 semicolon-separated parts, got "
+ parts.length);
}
final AnalyzedToken analyzedToken = new AnalyzedToken(parts[1], parts[2], null);
if (!map.containsKey(parts[0])) {
map.put(parts[0], new AnalyzedTokenReadings(analyzedToken, 0));
} else {
AnalyzedTokenReadings atrs = map.get(parts[0]);
atrs.addReading(analyzedToken, "");
map.replace(parts[0], atrs);
}
}
}
return map;
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Open the file named in the message at the reported line and make it have exactly 3 semicolon-separated fields.
- Remove extra semicolons (including trailing ones) or add missing fields.
- Keep the word/tag fields free of ';' characters; escape or rephrase such content.
Example fix
// before (confusion_pairs.txt, 4 parts) bien;bian;VMIC0000;;comment // after bem;vien;VMIC0000
Defensive patterns
Strategy: validation
Validate before calling
String[] parts = line.split(";");
if (parts.length != 3) {
throw new IllegalArgumentException("Skipping malformed data line " + lineNo + ": expected 3 ';'-separated parts, got " + parts.length);
} Try / catch
try {
loader.loadWords(path, map);
} catch (RuntimeException e) {
LOG.error("Malformed confusion-pairs data file: {}", e.getMessage());
} Prevention
- Validate data files with a linter/script before committing
- Never place ';' inside word or tag fields
- Check for accidental trailing semicolons on data lines
When it happens
Trigger: loadWords → loadFromPath reads a confusion-pairs data file (e.g. Spanish confusion_pairs.txt) and a non-empty, non-# line splits on ';' into other than 3 fields.
Common situations: Hand-editing the data file and adding/removing a semicolon; a line containing a trailing semicolon (4 parts) or only 2 fields; using semicolons inside the tag or word field.
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
- Could not load simple replacement data from: " + path + ". E
- Format error in file " + path + ", line: " + line
- Incorrect number of fields: " + line
- Form has more than 1 modern form:" + line
- Replacement has more than 1 modern form:" + line
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/685562be2a92070b.
Report an issue: GitHub.