languagetool-org/languagetool · error

File with example sentences not found:

Error message

File with example sentences not found: 

What it means

ProhibitedCompoundRuleEvaluator.getRelevantSentences requires a per-token corpus file <token>.txt inside each input directory; if absent it throws this RuntimeException. Same pattern as ConfusionRuleEvaluator: the tool cannot collect example sentences for the compound word without its file.

Source

Thrown at languagetool-dev/src/main/java/org/languagetool/dev/bigdata/ProhibitedCompoundRuleEvaluator.java:204

        //System.out.printf(ENGLISH, "Recall:       %.3f (%d false negatives)\n", recall, evalValues.falseNegatives);
        //double fMeasure = FMeasure.getWeightedFMeasure(precision, recall);
        //System.out.printf(ENGLISH, "F-measure:    %.3f (beta=0.5)\n", fMeasure);
        //System.out.printf(ENGLISH, "Good Matches: %d (true positives)\n", evalValues.truePositives);
        //System.out.printf(ENGLISH, "All matches:  %d\n", evalValues.truePositives + evalValues.falsePositives);
        System.out.printf(summary + "\n");
      }
    }
    return results;
  }

  // TODO deduplicate / delegate
  private List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> getRelevantSentences(List<String> inputs, String token, int maxSentences) throws IOException {
    List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> sentences = new ArrayList<>();
    for (String input : inputs) {
      if (new File(input).isDirectory()) {
        File file = new File(input, token + ".txt");
        if (!file.exists()) {
          throw new RuntimeException("File with example sentences not found: " + file);
        }
        try (FileInputStream fis = new FileInputStream(file)) {
          SentenceSource sentenceSource = new PlainTextSentenceSource(fis, language);
          sentences = getSentencesFromSource(inputs, token, maxSentences, sentenceSource);
        }
      } else {
        SentenceSource sentenceSource = MixingSentenceSource.create(inputs, language);
        sentences = getSentencesFromSource(inputs, token, maxSentences, sentenceSource);
      }
    }
    return sentences;
  }

  private List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> getSentencesFromSource(List<String> inputs, String token, int maxSentences, SentenceSource sentenceSource) {
    List<Map.Entry<Sentence, Map.Entry<Integer, Integer>>> sentences = new ArrayList<>();
    Pattern pattern = Pattern.compile("(?iu)\\b(" + token.toLowerCase() + ")\\p{Alpha}+\\b|\\b\\p{Alpha}+(" + token.toLowerCase() + ")\\b");
    while (sentenceSource.hasNext()) {
      Sentence sentence = sentenceSource.next();

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Generate/place the missing <token>.txt file in the input directory
  2. Verify token names match filenames exactly (case-sensitive)
  3. Confirm the correct input directories were passed on the command line
  4. Catch and skip tokens without files if partial runs are acceptable

Example fix

// before
java ProhibitedCompoundRuleEvaluator de-DE /data/compounds pairs.txt
// /data/compounds/Haustuer/Haustuer.txt missing
// after
./generate_sentences.sh Haustür > /data/compounds/Haustuer/Haustuer.txt
Defensive patterns

Strategy: validation

Validate before calling

for (String token : tokens) {
  for (String input : inputs) {
    if (new File(input).isDirectory() && !new File(input, token + ".txt").exists()) {
      throw new IllegalStateException("Missing corpus file for " + token + " in " + input);
    }
  }
}

Prevention

When it happens

Trigger: Running the evaluator with input directories missing a <token>.txt for one of the compound-word tokens; filename case mismatch; corpus generated for a different word list.

Common situations: Partial corpus generation; compound tokens with characters altered by filename sanitization; wrong input directory passed for the language.

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/61e77bcb64fab6a3. Report an issue: GitHub.