stanfordnlp/CoreNLP · error · RuntimeIOException

Couldn't load

Error message

Couldn't load {neutralWordsFile}

What it means

loadGenderNumber wraps failures reading the neutral-words list into RuntimeIOException with the message "Couldn't load <neutralWordsFile>". It signals the gender/number neutral-word resource could not be read while initializing dcoref dictionaries.

Solutions

  1. Check the neutral words file path/property value and confirm the file exists
  2. Ensure the CoreNLP models jar is on the classpath
  3. Use classpath:/ URLs for built-in resources instead of bare relative paths
  4. Confirm read permissions and correct working directory

Example fix

// before
props.setProperty("coref.gender.neutral", "neutralWords.txt");
// after
props.setProperty("coref.gender.neutral", "classpath:/edu/stanford/nlp/models/dcoref/neutral.words");
Defensive patterns

Strategy: try-catch

Validate before calling

String p = props.getProperty("coref.gender.neutral");
if (p != null && !IOUtils.existsInClasspathOrFileSystem(p)) {
    throw new IllegalStateException("Neutral words file not found: " + p);
}

Try / catch

try {
    new Dictionaries(props);
} catch (RuntimeIOException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Couldn't load")) {
        log.error("Gender/number resource missing: " + e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Constructing Dictionaries when getWordsFromFile throws IOException for the neutralWordsFile path (missing file, bad URL, permission denied).

Common situations: Missing CoreNLP models jar, wrong gender/number file properties, deployment strips resource files, or network URL unreachable when a URL path is configured.

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/3dcbbbbe30d642c3. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/dcoref/Dictionaries.java:390

        countries.add(line.split("\t")[1].toLowerCase());
      }
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  }

  /**
   * Load Bergsma and Lin (2006) gender and number list.
   * <br>
   * The list is converted from raw text and numbers to a serialized
   * map, which saves quite a bit of time loading.
   * See edu.stanford.nlp.dcoref.util.ConvertGenderFile
   */
  private void loadGenderNumber(String file, String neutralWordsFile) {
    try {
      getWordsFromFile(neutralWordsFile, neutralWords, false);
    } catch (IOException e) {
      throw new RuntimeIOException("Couldn't load " + neutralWordsFile);
    }
    try {
      Map<List<String>, Gender> temp = IOUtils.readObjectFromURLOrClasspathOrFileSystem(file);
      genderNumber.putAll(temp);
    } catch (IOException | ClassNotFoundException e) {
      throw new RuntimeIOException("Couldn't load " + file);
    }
  }

  private static void loadCorefDict(String[] file,
      ArrayList<Counter<Pair<String, String>>> dict) {

    for(int i = 0; i < 4; i++){
      dict.add(new ClassicCounter<>());

      BufferedReader reader = null;
      try {
        reader = IOUtils.readerFromString(file[i]);

View on GitHub (pinned to 1b7edd19c4)