languagetool-org/languagetool · error · RuntimeException

Could not find a source handler for ${dumpFileName} - Wikipe

Error message

Could not find a source handler for ${dumpFileName} - Wikipedia files must be named '*.xml', Tatoeba files must be named 'tatoeba-*', CommonCrawl files '*.xz', plain text files '*.txt'

What it means

MixingSentenceSource.create dispatches each dump file to a sentence source based on its file name/extension (.xml for Wikipedia, tatoeba-* for Tatoeba, .xz for CommonCrawl, .txt for plain text). If a file matches none of the patterns it throws a RuntimeException explaining the required naming conventions. The extension is the only format selector, so naming is a hard requirement.

Source

Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/MixingSentenceSource.java:58

  public static MixingSentenceSource create(List<String> dumpFileNames, Language language) throws IOException {
    return create(dumpFileNames, language, null);
  }

  public static MixingSentenceSource create(List<String> dumpFileNames, Language language, Pattern filter) throws IOException {
    List<SentenceSource> sources = new ArrayList<>();
    for (String dumpFileName : dumpFileNames) {
      File file = new File(dumpFileName);
      if (file.getName().endsWith(".xml")) {
        sources.add(new WikipediaSentenceSource(new FileInputStream(dumpFileName), language, filter));
      } else if (file.getName().startsWith("tatoeba-")) {
        sources.add(new TatoebaSentenceSource(new FileInputStream(dumpFileName), language, filter));
      } else if (file.getName().endsWith(".txt")) {
        sources.add(new PlainTextSentenceSource(new FileInputStream(dumpFileName), language, filter));
      } else if (file.getName().endsWith(".xz")) {
        sources.add(new CommonCrawlSentenceSource(new FileInputStream(dumpFileName), language, filter));
      } else {
        throw new RuntimeException("Could not find a source handler for " + dumpFileName +
                " - Wikipedia files must be named '*.xml', Tatoeba files must be named 'tatoeba-*', CommonCrawl files '*.xz', plain text files '*.txt'");
      }
    }
    return new MixingSentenceSource(sources, language);
  }

  private MixingSentenceSource(List<SentenceSource> sources, Language language) {
    super(language);
    this.sources = sources;
  }

  Map<String, Integer> getSourceDistribution() {
    return sourceDistribution;
  }
  
  @Override
  public boolean hasNext() {
    for (SentenceSource source : sources) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Rename the file to match one of the supported patterns: *.xml, tatoeba-*, *.xz, or *.txt
  2. Decompress double-compressed files (e.g. dump.xml.bz2 -> dump.xml) before passing
  3. Check for case-sensitivity issues in the extension or prefix

Example fix

// before
java ... MixingSentenceSource dewiki-latest-pages-articles.xml.bz2
// after
bunzip2 dewiki-latest-pages-articles.xml.bz2
java ... MixingSentenceSource dewiki-latest-pages-articles.xml
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(dumpFileName);
String n = f.getName().toLowerCase(Locale.ROOT);
boolean ok = n.endsWith(".xml") || n.startsWith("tatoeba-") || n.endsWith(".xz") || n.endsWith(".txt");
if (!ok) throw new IllegalArgumentException("Unsupported dump name: " + n);

Try / catch

try {
  MixingSentenceSource.create(dumpFileNames, language, filter);
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Could not find a source handler")) {
    System.err.println("Rename the dump file per conventions: " + e.getMessage());
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a dump file with an unhandled extension such as .bz2, .7z, or no extension; a Tatoeba file not named with the tatoeba- prefix.

Common situations: Downloads saved as .xml.bz2 (double extension) not renamed; compressed plain-text files; typos like Tatoeba-2019.txt with capital T and no dash prefix matching.

Related errors


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