{"record":{"id":"b0d4a3c8764c07aa","repo":"stanfordnlp/CoreNLP","slug":"error-making-document","errorCode":null,"errorMessage":"Error making document","messagePattern":"Error making document","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/CorefSystem.java","lineNumber":61,"sourceCode":"    } catch (Exception e) {\n      throw new RuntimeException(\"Error initializing coref system\", e);\n    }\n  }\n\n  public CorefSystem(DocumentMaker docMaker, CorefAlgorithm corefAlgorithm,\n      boolean removeSingletonClusters, boolean verbose) {\n    this.docMaker = docMaker;\n    this.corefAlgorithm = corefAlgorithm;\n    this.removeSingletonClusters = removeSingletonClusters;\n    this.verbose = verbose;\n  }\n\n  public void annotate(Annotation ann) {\n    Document document;\n    try {\n      document = docMaker.makeDocument(ann);\n    } catch (Exception e) {\n      throw new RuntimeException(\"Error making document\", e);\n    }\n\n    CorefUtils.checkForInterrupt();\n    corefAlgorithm.runCoref(document);\n    if (removeSingletonClusters) {\n      CorefUtils.removeSingletonClusters(document);\n    }\n    CorefUtils.checkForInterrupt();\n\n    Map<Integer, CorefChain> result = Generics.newHashMap();\n    for (CorefCluster c : document.corefClusters.values()) {\n      result.put(c.clusterID, new CorefChain(c, document.positions));\n    }\n    ann.set(CorefCoreAnnotations.CorefChainAnnotation.class, result);\n  }\n\n  public void initLogger(Logger logger, String logFileName) {\n      try {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/CorefSystem.java#L43-L79","documentation":"CorefSystem.annotate wraps docMaker.makeDocument(ann) and rethrows any exception as RuntimeException(\"Error making document\", e). It means the annotation could not be converted into a coref Document — typically missing prerequisite annotations or bad mention extraction on this input.","triggerScenarios":"Calling corefSystem.annotate(ann) on an Annotation that lacks required upstream annotations (tokens, sentences, parses, speaker info) or whose content crashes DocumentMaker.makeDocument.","commonSituations":"Running the coref annotator in a pipeline without required earlier annotators (tokenize, ssplit, pos, lemma, ner, parse/depparse, dcoref prerequisites); malformed input text; annotations built manually missing CoreAnnotations fields.","solutions":["Check the chained cause (e.getCause()) for the underlying failure","Ensure the pipeline runs all prerequisite annotators before coref (tokenize,ssplit,pos,lemma,ner,parse)","Run StanfordCoreNLP with the full default requirements rather than invoking coref on a hand-built Annotation","Test the same text through StanfordCoreNLP dcoref pipeline to see if input-specific data is the problem"],"exampleFix":"// before\ncorefSystem.annotate(partialAnn); // missing parse annotation -> RuntimeException\n// after\nProperties p = new Properties();\np.setProperty(\"annotators\", \"tokenize,ssplit,pos,lemma,ner,parse,coref\");\nStanfordCoreNLP pipeline = new StanfordCoreNLP(p);\npipeline.annotate(doc); // prerequisites guaranteed","handlingStrategy":"validation","validationCode":"boolean ok = doc.get(CoreAnnotations.SentencesAnnotation.class) != null\n  && doc.get(CoreAnnotations.NamedEntityTagAnnotation.class) != null;\nif (!ok) throw new IllegalStateException(\"Annotation lacks prerequisites for coref\");","typeGuard":null,"tryCatchPattern":"try {\n  corefSystem.annotate(ann);\n} catch (RuntimeException e) {\n  logger.log(Level.SEVERE, \"Document creation failed: \" + e.getCause(), e.getCause());\n}","preventionTips":["Run coref only through a full StanfordCoreNLP pipeline (tokenize,ssplit,pos,lemma,ner,parse,coref)","Never re-tokenize an Annotation after parsing and before coref","Log getCause() when this RuntimeException appears","Smoke-test representative inputs through the pipeline in CI"],"tags":["coref","pipeline","annotation","runtime-exception"],"backgroundTag":"missing-required-argument","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"}