languagetool-org/languagetool · error · RuntimeException

No confidence values could be loaded for -- please check th

Error message

No confidence values could be loaded for  -- please check there are actually files that match this pattern

What it means

After iterating all languages, if no confidence mappings were loaded at all (empty confMap), ConfidenceMapLoader.load throws a RuntimeException. This guards against silently running with no confidence adjustment because the file pattern matched no existing files.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java:73

          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

  1. Check the pattern in the config matches the actual filenames and location.
  2. Create confidence files for the languages you use, named per the pattern.
  3. Ensure the matched files contain at least one valid 'RULE_ID,float' line.
  4. Verify the server process has read access to the files.

Example fix

// before
ruleIdToConfidenceFile=/etc/lt/conf-{lang}.csv   # no such files
// after
ruleIdToConfidenceFile=/etc/lt/confidence-{lang}.csv  # files exist: confidence-en.csv, ...
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
if (!languages.some(l => fs.existsSync(pattern.replace('{lang}', l)))) {
  throw new Error('No files match confidence pattern: ' + pattern);
}

Type guard

function patternMatchesAnyFile(pattern, langs) {
  return langs.some(l => fs.existsSync(pattern.replace('{lang}', l)));
}

Try / catch

try {
  Map<ConfidenceKey,Float> map = new ConfidenceMapLoader().load(filePattern);
} catch (RuntimeException e) {
  logger.error("No confidence files loaded: " + e.getMessage());
}

Prevention

When it happens

Trigger: The 'ruleIdToConfidenceFile' pattern contains '{lang}' but no per-language files matching it exist (e.g. pattern /conf/{lang}-confidence.csv while files are named confidence-{lang}.csv), or all matching files are empty.

Common situations: Filename-pattern mismatch between config and deployed files; files deployed to the wrong directory; per-language files all empty.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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