{"record":{"id":"f0d3fde8cb8ebb1d","repo":"stanfordnlp/CoreNLP","slug":"error-creating-data-exporter","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/fastneural/FastNeuralCorefDataExporter.java","lineNumber":65,"sourceCode":"  private final int maxMentionDistance;\n  private final int maxMentionDistanceWithStringMatch;\n  private final PrintWriter dataWriter;\n  private final PrintWriter goldClusterWriter;\n\n  public FastNeuralCorefDataExporter(Properties props, Dictionaries dictionaries, Compressor<String> compressor,\n        String dataPath, String goldClusterPath) {\n    String wordCountsFile = StatisticalCorefProperties.wordCountsPath(props);\n    int maxMentionDistance = CorefProperties.maxMentionDistance(props);\n    int maxMentionDistanceWithStringMatch = CorefProperties.maxMentionDistanceWithStringMatch(props);\n    try {\n      this.compressor = compressor;\n      this.extractor = new FeatureExtractor(props, dictionaries, null, wordCountsFile);\n      this.maxMentionDistance = maxMentionDistance;\n      this.maxMentionDistanceWithStringMatch = maxMentionDistanceWithStringMatch;\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    Map<Pair<Integer, Integer>, Boolean> allPairs = CorefUtils.getLabeledMentionPairs(document);\n    Map<Pair<Integer, Integer>, Boolean> pairs = new HashMap<>();\n    for (Map.Entry<Integer, List<Integer>> e: CorefUtils.heuristicFilter(","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/fastneural/FastNeuralCorefDataExporter.java#L47-L83","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the exception's cause (e.getCause()) to find the underlying IO/config failure","Verify dataPath and goldClusterPath point to writable locations whose parent directories exist","Check that wordCountsFile exists and is readable if specified in props","Validate the Properties (dictionaries, model paths) before constructing the exporter"],"exampleFix":"// before\nFile out = new File(\"/nonexistent/dir/coref.jsonl\");\n// after\nFile out = new File(\"/nonexistent/dir/coref.jsonl\");\nout.getParentFile().mkdirs();\nif (!out.getParentFile().canWrite()) throw new IllegalStateException(\"Output dir not writable: \" + out.getParent());","handlingStrategy":"try-catch","validationCode":"File data = new File(dataPath), gold = new File(goldClusterPath);\ndata.getParentFile().mkdirs(); gold.getParentFile().mkdirs();\nif (wordCountsFile != null && !new File(wordCountsFile).canRead()) throw new IllegalStateException(\"wordCountsFile unreadable\");","typeGuard":null,"tryCatchPattern":"try { new FastNeuralCorefDataExporter(props, dicts, wc, dataPath, goldPath, md, mdStr); } catch (RuntimeException e) { throw new IllegalStateException(\"Exporter init failed: \" + e.getCause(), e); }","preventionTips":["mkdirs() on output parents before export","Check write permissions for the process user","Unwrap getCause() to see the real IO error","Validate Properties keys before constructing components"],"tags":["java","io","exporter","wrapped-exception"],"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"}