{"record":{"id":"89150f729247c777","repo":"stanfordnlp/CoreNLP","slug":"error-creating-data-exporter-89150f","errorCode":null,"errorMessage":"Error creating data exporter","messagePattern":"Error creating data exporter","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/neural/NeuralCorefDataExporter.java","lineNumber":59,"sourceCode":" *\n * @author Kevin Clark\n */\npublic class NeuralCorefDataExporter implements CorefDocumentProcessor {\n\n  private final boolean conll;\n  private final PrintWriter dataWriter;\n  private final PrintWriter goldClusterWriter;\n  private final Dictionaries dictionaries;\n\n  public NeuralCorefDataExporter(Properties props, Dictionaries dictionaries, String dataPath,\n      String goldClusterPath) {\n    conll = CorefProperties.conll(props);\n    this.dictionaries = dictionaries;\n    try {\n      dataWriter = IOUtils.getPrintWriter(dataPath);\n      goldClusterWriter = IOUtils.getPrintWriter(goldClusterPath);\n    } catch (Exception e) {\n        throw new RuntimeException(\"Error creating data exporter\", e);\n    }\n  }\n\n  @Override\n  public void process(int id, Document document) {\n    JsonArrayBuilder clusters = Json.createArrayBuilder();\n    for (CorefCluster gold : document.goldCorefClusters.values()) {\n      JsonArrayBuilder c = Json.createArrayBuilder();\n      for (Mention m : gold.corefMentions) {\n        c.add(m.mentionID);\n      }\n      clusters.add(c.build());\n    }\n    goldClusterWriter.println(Json.createObjectBuilder().add(String.valueOf(id),\n        clusters.build()).build());\n\n    Map<Pair<Integer, Integer>, Boolean> mentionPairs = CorefUtils.getLabeledMentionPairs(document);\n    List<Mention> mentionsList = CorefUtils.getSortedMentions(document);","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/neural/NeuralCorefDataExporter.java#L41-L77","documentation":"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.","triggerScenarios":"Constructing NeuralCorefDataExporter when either dataPath or goldClusterPath cannot be opened for writing (any Exception from IOUtils.getPrintWriter).","commonSituations":"Output directories for the export paths don't exist; paths misspelled in properties; running the exporter without write permissions in the output location.","solutions":["Create the parent directories of both output paths before running","Verify the data and gold-cluster output paths in your properties are correct absolute paths","Check write permissions for the process user","Catch and inspect the cause via e.getCause() to see the underlying IO error"],"exampleFix":"// before\nnew NeuralCorefDataExporter(props, dictionaries, \"out/data.jsonl\", \"out/gold.jsonl\");\n// after\nnew File(\"out\").mkdirs();\nnew NeuralCorefDataExporter(props, dictionaries,\n    \"/abs/out/data.jsonl\", \"/abs/out/gold.jsonl\");","handlingStrategy":"validation","validationCode":"for (String p : new String[]{dataPath, goldClusterPath}) {\n  java.io.File f = new java.io.File(p);\n  java.io.File d = f.getParentFile();\n  if (d != null && !d.isDirectory() && !d.mkdirs())\n    throw new IllegalStateException(\"Cannot create export dir: \" + d);\n  if (d != null && !d.canWrite()) throw new IllegalStateException(\"Not writable: \" + d);\n}","typeGuard":null,"tryCatchPattern":"try {\n  new NeuralCorefDataExporter(props, dictionaries, dataPath, goldClusterPath);\n} catch (RuntimeException e) {\n  if (\"Error creating data exporter\".equals(e.getMessage()))\n    throw new IllegalStateException(\"Bad export path(s), cause: \" + e.getCause(), e);\n  throw e;\n}","preventionTips":["Pre-create output directories for export paths","Use absolute paths in export properties","Verify write permissions for the process user","Wrap exporter construction early so failures surface before a long export run"],"tags":["java","corenlp","io","file-write","export"],"backgroundTag":"file-write-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}