stanfordnlp/CoreNLP · error · RuntimeIOException

CTBunk file not found

Error message

CTBunk file not found: ${filename}

What it means

CTBunkDict.readCTBunkDict() loads the CTBunk (Chinese Treebank) dictionary file specified by the loader's filename argument. When the file cannot be found on disk, the caught FileNotFoundException is rethrown as a RuntimeIOException with this message. It typically means the CTBunk resource is missing or its path is wrong.

Solutions

  1. Download/obtain the CTBunk dictionary file and place it at the path the tagger expects (it ships in the tagger's resource distribution for Chinese models).
  2. Verify the configured path/filename — check the working directory and make relative paths absolute.
  3. Run with the correct model/config that requires CTBunk only if you actually have the resource, or switch to a model whose features don't need it.

Example fix

// before
java -cp stanford-postagger.jar ... -model chinese.tagger // CTBunk file absent
// after
ls /models/ctbunki.txt # ensure file exists, or set the path in config
gazettedir=/full/path/to/ctbunk/resources
Defensive patterns

Strategy: validation

Validate before calling

// Java: verify CTBunk resource exists before initializing the tagger
File f = new File(ctbunkPath);
if (!f.isFile()) throw new IllegalStateException("Missing CTBunk file: " + ctbunkPath);

Try / catch

// Java
try {
  CTBunkDict d = new CTBunkDict(filename);
} catch (RuntimeIOException e) {
  log("CTBunk resource missing; install it or switch models", e);
}

Prevention

When it happens

Trigger: Constructing CTBunkDict (via DistributionFactory / the MaxentTagger feature pipeline, e.g. with a ctb features file) when the configured CTBunk file path doesn't exist at runtime.

Common situations: Running the Chinese POS tagger without the required CTBunk dictionary file distributed separately, wrong working directory so relative paths don't resolve, or config pointing to a renamed/moved resource.

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 stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/1b6c195d9e982622. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/tagger/maxent/CTBunkDict.java:54

    try{

      BufferedReader CTBunkDetectorReader = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "GB18030"));
      for (String CTBunkDetectorLine; (CTBunkDetectorLine = CTBunkDetectorReader.readLine()) != null; ) {
        String[] fields = CTBunkDetectorLine.split(" ");
        String tag=fields[1];
        Set<String> words=CTBunk_dict.get(tag);

        if(words==null){
          words = Generics.newHashSet();
          CTBunk_dict.put(tag,words);
        }
        words.add(fields[0]);

      }

    } catch (FileNotFoundException e) {
      throw new RuntimeIOException("CTBunk file not found: " + filename, e);
    } catch (IOException e) {
      throw new RuntimeIOException("CTBunk I/O error: " + filename, e);
    }
  }



  /**
   * Returns "1" as true if the dictionary listed this word with this tag,
   *  and "0" otherwise.
   *
   * @param tag  The POS tag
   * @param word The word
   * @return "1" as true if the dictionary listed this word with this tag,
   *  and "0" otherwise.
   */
  protected static String getTag(String tag, String word) {
    CTBunkDict dict = CTBunkDict.getInstance();

View on GitHub (pinned to 1b7edd19c4)