languagetool-org/languagetool · error · RuntimeException

Cannot read file: ${freqListFile.getAbsolutePath()}

Error message

Cannot read file: ${freqListFile.getAbsolutePath()}

What it means

I/O guard in DictionaryBuilder.readFreqList: opening or reading the frequency list file failed (missing file, permission issue, or read error), so the word-frequency map cannot be populated.

Source

Thrown at languagetool-tools/src/main/java/org/languagetool/tools/DictionaryBuilder.java:141

  protected boolean isOptionTrue(String option) {
    return hasOption(option) && "true".equals(getOption(option));
  }
  
  protected void readFreqList(File freqListFile) {
    try (
      FileInputStream fis = new FileInputStream(freqListFile.getAbsoluteFile());
      InputStreamReader reader = new InputStreamReader(fis, StandardCharsets.UTF_8);
      BufferedReader br = new BufferedReader(reader)
    ) {
      String line;
      while ((line = br.readLine()) != null) {
        Matcher m = pFreqEntry.matcher(line);
        if (m.matches()) {
          freqList.put(m.group(3), Integer.parseInt(m.group(1)));
        }
      }
    } catch (IOException e) {
      throw new RuntimeException("Cannot read file: " + freqListFile.getAbsolutePath());
    }
  }
  
  protected File addFreqData(File dictFile, boolean useSeparator) throws IOException {
    if (!isOptionTrue("fsa.dict.frequency-included")) {
      throw new IOException("In order to use frequency data add the line 'fsa.dict.frequency-included=true' to the dictionary info file.");
    }
    String separator = getOption("fsa.dict.separator");
    if (separator == null || separator.trim().isEmpty()) {
      throw new IOException("A separator character (fsa.dict.separator) must be defined in the dictionary info file.");
    }
    File tempFile = File.createTempFile(DictionaryBuilder.class.getSimpleName(), "WithFrequencies.txt");
    tempFile.deleteOnExit();
    String encoding = getOption("fsa.dict.encoding");
    int freqValuesApplied = 0;

    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile.getAbsoluteFile()), encoding));
         BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(dictFile.getAbsoluteFile()), encoding))) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Verify the frequency list file path passed to the builder
  2. Check file readability and encoding (UTF-8 expected)
  3. Ensure the file is present on the machine running the build
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at languagetool-tools/src/main/java/org/languagetool/tools/DictionaryBuilder.java:141 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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