stanfordnlp/CoreNLP · error · RuntimeException

Error creating data exporter

Error message

Error creating data exporter

What it means

FastNeuralCorefDataExporter's constructor wraps all initialization — FeatureExtractor construction, dictionary loading, word counts reading, and opening output PrintWriter files via IOUtils.getPrintWriter — in a try/catch that rethrows any Exception as RuntimeException("Error creating data exporter", e). It is a generic wrapper: the cause holds the real failure (missing file, unwritable path, bad properties).

Solutions

  1. Inspect the exception's cause (e.getCause()) to find the underlying IO/config failure
  2. Verify dataPath and goldClusterPath point to writable locations whose parent directories exist
  3. Check that wordCountsFile exists and is readable if specified in props
  4. Validate the Properties (dictionaries, model paths) before constructing the exporter

Example fix

// before
File out = new File("/nonexistent/dir/coref.jsonl");
// after
File out = new File("/nonexistent/dir/coref.jsonl");
out.getParentFile().mkdirs();
if (!out.getParentFile().canWrite()) throw new IllegalStateException("Output dir not writable: " + out.getParent());
Defensive patterns

Strategy: try-catch

Validate before calling

File data = new File(dataPath), gold = new File(goldClusterPath);
data.getParentFile().mkdirs(); gold.getParentFile().mkdirs();
if (wordCountsFile != null && !new File(wordCountsFile).canRead()) throw new IllegalStateException("wordCountsFile unreadable");

Try / catch

try { new FastNeuralCorefDataExporter(props, dicts, wc, dataPath, goldPath, md, mdStr); } catch (RuntimeException e) { throw new IllegalStateException("Exporter init failed: " + e.getCause(), e); }

Prevention

When it happens

Trigger: Constructing FastNeuralCorefDataExporter when dataPath/goldClusterPath are not writable or their parent directories do not exist, wordCountsFile is missing/unreadable, or props/dictionaries are invalid so FeatureExtractor initialization fails.

Common situations: Running coref data export with an output directory that does not exist or lacks write permission; pointing -coref.data / gold cluster paths at read-only locations; mistyping the word counts file path.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/coref/fastneural/FastNeuralCorefDataExporter.java:65

  private final int maxMentionDistance;
  private final int maxMentionDistanceWithStringMatch;
  private final PrintWriter dataWriter;
  private final PrintWriter goldClusterWriter;

  public FastNeuralCorefDataExporter(Properties props, Dictionaries dictionaries, Compressor<String> compressor,
        String dataPath, String goldClusterPath) {
    String wordCountsFile = StatisticalCorefProperties.wordCountsPath(props);
    int maxMentionDistance = CorefProperties.maxMentionDistance(props);
    int maxMentionDistanceWithStringMatch = CorefProperties.maxMentionDistanceWithStringMatch(props);
    try {
      this.compressor = compressor;
      this.extractor = new FeatureExtractor(props, dictionaries, null, wordCountsFile);
      this.maxMentionDistance = maxMentionDistance;
      this.maxMentionDistanceWithStringMatch = maxMentionDistanceWithStringMatch;
      dataWriter = IOUtils.getPrintWriter(dataPath);
      goldClusterWriter = IOUtils.getPrintWriter(goldClusterPath);
    } catch (Exception e) {
        throw new RuntimeException("Error creating data exporter", e);
    }
  }

  @Override
  public void process(int id, Document document) {
    JsonArrayBuilder clusters = Json.createArrayBuilder();
    for (CorefCluster gold : document.goldCorefClusters.values()) {
      JsonArrayBuilder c = Json.createArrayBuilder();
      for (Mention m : gold.corefMentions) {
        c.add(m.mentionID);
      }
      clusters.add(c.build());
    }
    goldClusterWriter.println(Json.createObjectBuilder().add(String.valueOf(id),
        clusters.build()).build());
    Map<Pair<Integer, Integer>, Boolean> allPairs = CorefUtils.getLabeledMentionPairs(document);
    Map<Pair<Integer, Integer>, Boolean> pairs = new HashMap<>();
    for (Map.Entry<Integer, List<Integer>> e: CorefUtils.heuristicFilter(

View on GitHub (pinned to 1b7edd19c4)