stanfordnlp/CoreNLP · error · RuntimeException

Error creating data exporter

Error message

Error creating data exporter

What it means

NeuralCorefDataExporter's constructor opens two output writers (data and gold clusters) via IOUtils.getPrintWriter and wraps any failure in RuntimeException("Error creating data exporter"). It is used when exporting neural coref training data, so it is expected only in data-generation runs.

Solutions

  1. Create the parent directories of both output paths before running
  2. Verify the data and gold-cluster output paths in your properties are correct absolute paths
  3. Check write permissions for the process user
  4. Catch and inspect the cause via e.getCause() to see the underlying IO error

Example fix

// before
new NeuralCorefDataExporter(props, dictionaries, "out/data.jsonl", "out/gold.jsonl");
// after
new File("out").mkdirs();
new NeuralCorefDataExporter(props, dictionaries,
    "/abs/out/data.jsonl", "/abs/out/gold.jsonl");
Defensive patterns

Strategy: validation

Validate before calling

for (String p : new String[]{dataPath, goldClusterPath}) {
  java.io.File f = new java.io.File(p);
  java.io.File d = f.getParentFile();
  if (d != null && !d.isDirectory() && !d.mkdirs())
    throw new IllegalStateException("Cannot create export dir: " + d);
  if (d != null && !d.canWrite()) throw new IllegalStateException("Not writable: " + d);
}

Try / catch

try {
  new NeuralCorefDataExporter(props, dictionaries, dataPath, goldClusterPath);
} catch (RuntimeException e) {
  if ("Error creating data exporter".equals(e.getMessage()))
    throw new IllegalStateException("Bad export path(s), cause: " + e.getCause(), e);
  throw e;
}

Prevention

When it happens

Trigger: Constructing NeuralCorefDataExporter when either dataPath or goldClusterPath cannot be opened for writing (any Exception from IOUtils.getPrintWriter).

Common situations: Output directories for the export paths don't exist; paths misspelled in properties; running the exporter without write permissions in the output location.

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/89150f729247c777. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/coref/neural/NeuralCorefDataExporter.java:59

 *
 * @author Kevin Clark
 */
public class NeuralCorefDataExporter implements CorefDocumentProcessor {

  private final boolean conll;
  private final PrintWriter dataWriter;
  private final PrintWriter goldClusterWriter;
  private final Dictionaries dictionaries;

  public NeuralCorefDataExporter(Properties props, Dictionaries dictionaries, String dataPath,
      String goldClusterPath) {
    conll = CorefProperties.conll(props);
    this.dictionaries = dictionaries;
    try {
      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> mentionPairs = CorefUtils.getLabeledMentionPairs(document);
    List<Mention> mentionsList = CorefUtils.getSortedMentions(document);

View on GitHub (pinned to 1b7edd19c4)