stanfordnlp/CoreNLP · error · RuntimeException

IOException reading CEDict from file

Error message

IOException reading CEDict from file 

What it means

ChineseEnglishWordMap.readCEDict parses the CEDict dictionary file (cedict_ts.u8) to build a Chinese-English mapping. If any IOException occurs while reading that file, the method wraps it in a RuntimeException naming the dictionary path, so a missing or unreadable CEDict file fails fast at map construction. The original IOException is chained as the cause.

Solutions

  1. Place cedict_ts.u8 in the working directory or pass the correct dictPath to the ChineseEnglishWordMap constructor
  2. Download CEDict from the official site if the file is missing
  3. Check file permissions and that the process can read the path printed in the exception message
  4. Inspect the chained cause (e.getCause()) to distinguish FileNotFoundException from other IO failures

Example fix

// before
ChineseEnglishWordMap map = new ChineseEnglishWordMap(); // fails if cedict_ts.u8 absent
// after
File dict = new File("cedict_ts.u8");
if (!dict.canRead()) throw new IllegalStateException("Download cedict_ts.u8 to " + dict.getAbsolutePath());
ChineseEnglishWordMap map = new ChineseEnglishWordMap("cedict_ts.u8");
Defensive patterns

Strategy: try-catch

Validate before calling

File dict = new File(dictPath);
if (!dict.exists() || !dict.canRead())
  throw new IllegalStateException("CEDict file missing/unreadable: " + dict.getAbsolutePath());

Try / catch

try {
  ChineseEnglishWordMap map = new ChineseEnglishWordMap(dictPath);
} catch (RuntimeException e) {
  IOException ioe = (IOException) e.getCause();
  // handle missing/unreadable CEDict: locate file or fail gracefully
}

Prevention

When it happens

Trigger: Constructing a ChineseEnglishWordMap (or calling readCEDict) when cedict_ts.u8 is absent from the working directory, the given dictPath is wrong, the file lacks read permissions, or is deleted mid-read.

Common situations: Deploying the library without bundling the CEDict data file, running from a different working directory than where cedict_ts.u8 was placed, or referencing a CEDict version whose filename differs.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/7319c32fbec8c468. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/trees/international/pennchinese/ChineseEnglishWordMap.java:206

              if ( ! t.equals("")) {
                if ( ! oldtrans.contains(t)) {
                  oldtrans.add(t);
                }
              }
            }
          } else {
            Set<String> transList = new LinkedHashSet<>(Arrays.asList(trans));
            String normW = normalize(word);
            Set<String> normSet = normalize(transList);
            if ( ! normW.equals("") && normSet.size() > 0) {
              map.put(normW, normSet);
            }
          }
        }
      }
      infile.close();
    } catch (IOException e) {
      throw new RuntimeException("IOException reading CEDict from file " + dictPath, e);
    }
  }

  /**
   * Make a ChineseEnglishWordMap with a default CEDict path.
   * It looks for the file "cedict_ts.u8" in the working directory, for the
   * value of the CEDICT environment variable, and in a Stanford NLP Group
   * specific place.  It throws an exception if a dictionary cannot be found.
   */
  public ChineseEnglishWordMap() {
    String path = CEDict.path();
    readCEDict(path);
  }

  /**
   * Make a ChineseEnglishWordMap
   * @param dictPath the path/filename of the CEDict
   */

View on GitHub (pinned to 1b7edd19c4)