languagetool-org/languagetool · error · RuntimeException
Invalid confidence float value in , expected 'RULE_ID,float_
Error message
Invalid confidence float value in , expected 'RULE_ID,float_value[,...]':
What it means
Each data line of a confidence map file must be 'RULE_ID,float_value' (extra columns allowed for debugging). When the second column cannot be parsed as a float, Float.parseFloat throws NumberFormatException, which load rethrows as a RuntimeException naming the file and offending line.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java:64
for (Language lang : Languages.get()) {
int loadCount = 0;
String fileName = filePattern.getAbsolutePath().replace("{lang}", lang.getShortCode());
if (!Paths.get(fileName).toFile().exists()) {
continue;
}
List<String> lines = Files.readAllLines(Paths.get(fileName), UTF_8);
for (String line : lines) {
if (line.startsWith("#")) {
continue;
}
String[] parts = line.split(",");
if (parts.length >= 2) { // there might be more columns for better debugging, but we don't use them here
try {
float confidence = Float.parseFloat(parts[1]);
confMap.put(new ConfidenceKey(lang, parts[0]), confidence);
loadCount++;
} catch (NumberFormatException e) {
throw new RuntimeException("Invalid confidence float value in " + fileName + ", expected 'RULE_ID,float_value[,...]': " + line);
}
} else {
throw new RuntimeException("Invalid line in " + fileName + ", expected 'RULE_ID,float_value[,...]': " + line);
}
}
logger.info("Loaded " + loadCount + " mappings for " + lang + " from confidence map for rules from " + fileName);
}
if (confMap.size() == 0) {
throw new RuntimeException("No confidence values could be loaded for " + filePattern +
" -- please check there are actually files that match this pattern");
}
return confMap;
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Fix the offending line so the second column is a valid float using a dot, e.g. 'MY_RULE,0.75'.
- Replace decimal commas with dots.
- Remove trailing empty columns or stray whitespace/non-numeric characters from the second field.
Example fix
// before MY_RULE,0,75 // after MY_RULE,0.75
Defensive patterns
Strategy: validation
Validate before calling
for (const line of lines) {
const second = line.split('\t')[1];
if (second === undefined || Number.isNaN(parseFloat(second))) throw new Error('Invalid confidence line: ' + line);
} Type guard
function isValidConfidenceLine(line) {
const parts = line.split('\t');
return parts.length >= 2 && !isNaN(parseFloat(parts[1]));
} Try / catch
try {
Map<ConfidenceKey,Float> map = new ConfidenceMapLoader().load(filePattern);
} catch (RuntimeException e) {
logger.error("Confidence map parse failure: " + e.getMessage());
} Prevention
- Use dot as decimal separator, never comma.
- Lint confidence files before deploying.
- Keep the float value strictly in the second tab-separated column.
When it happens
Trigger: A confidence file for some language contains a line like 'MY_RULE,high' or 'MY_RULE,0,9' (comma decimal separator) or an empty second column.
Common situations: Hand-edited confidence files with decimal commas (locale habit); columns shifted when extra debug columns were added; copy-paste from spreadsheets with localized formatting.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Invalid line in , expected 'RULE_ID,float_value[,...]':
- Could not load simple replacement data from: " + path + ". E
- Format error in file " + path + ", line: " + line
- id is null for rule with name '
- Format error in file " + path + ", line: " + line + ", " + "
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/a683d3a026f75242.
Report an issue: GitHub.