{"record":{"id":"a683d3a026f75242","repo":"languagetool-org/languagetool","slug":"invalid-confidence-float-value-in-expected-rule","errorCode":null,"errorMessage":"Invalid confidence float value in , expected 'RULE_ID,float_value[,...]': ","messagePattern":"Invalid confidence float value in , expected 'RULE_ID,float_value\\[,\\.\\.\\.\\]': ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java","lineNumber":64,"sourceCode":"    for (Language lang : Languages.get()) {\n      int loadCount = 0;\n      String fileName = filePattern.getAbsolutePath().replace(\"{lang}\", lang.getShortCode());\n      if (!Paths.get(fileName).toFile().exists()) {\n        continue;\n      }\n      List<String> lines = Files.readAllLines(Paths.get(fileName), UTF_8);\n      for (String line : lines) {\n        if (line.startsWith(\"#\")) {\n          continue;\n        }\n        String[] parts = line.split(\",\");\n        if (parts.length >= 2) {   // there might be more columns for better debugging, but we don't use them here\n          try {\n            float confidence = Float.parseFloat(parts[1]);\n            confMap.put(new ConfidenceKey(lang, parts[0]), confidence);\n            loadCount++;\n          } catch (NumberFormatException e) {\n            throw new RuntimeException(\"Invalid confidence float value in \" + fileName + \", expected 'RULE_ID,float_value[,...]': \" + line);\n          }\n        } else {\n          throw new RuntimeException(\"Invalid line in \" + fileName + \", expected 'RULE_ID,float_value[,...]': \" + line);\n        }\n      }\n      logger.info(\"Loaded \" + loadCount + \" mappings for \" + lang + \" from confidence map for rules from \" + fileName);\n    }\n    if (confMap.size() == 0) {\n      throw new RuntimeException(\"No confidence values could be loaded for \" + filePattern +\n        \" -- please check there are actually files that match this pattern\");\n    }\n    return confMap;\n  }\n\n}\n","sourceCodeStart":46,"sourceCodeEnd":80,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java#L46-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-edited confidence files with decimal commas (locale habit); columns shifted when extra debug columns were added; copy-paste from spreadsheets with localized formatting.","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."],"exampleFix":"// before\nMY_RULE,0,75\n// after\nMY_RULE,0.75","handlingStrategy":"validation","validationCode":"for (const line of lines) {\n  const second = line.split('\\t')[1];\n  if (second === undefined || Number.isNaN(parseFloat(second))) throw new Error('Invalid confidence line: ' + line);\n}","typeGuard":"function isValidConfidenceLine(line) {\n  const parts = line.split('\\t');\n  return parts.length >= 2 && !isNaN(parseFloat(parts[1]));\n}","tryCatchPattern":"try {\n  Map<ConfidenceKey,Float> map = new ConfidenceMapLoader().load(filePattern);\n} catch (RuntimeException e) {\n  logger.error(\"Confidence map parse failure: \" + e.getMessage());\n}","preventionTips":["Use dot as decimal separator, never comma.","Lint confidence files before deploying.","Keep the float value strictly in the second tab-separated column."],"tags":["config","parsing","languagetool"],"backgroundTag":"invalid-config-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}