stanfordnlp/CoreNLP · error · RuntimeException
Error making document
Error message
Error making document
What it means
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.
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
Example fix
// before
corefSystem.annotate(partialAnn); // missing parse annotation -> RuntimeException
// after
Properties p = new Properties();
p.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,coref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(p);
pipeline.annotate(doc); // prerequisites guaranteed Defensive patterns
Strategy: validation
Validate before calling
boolean ok = doc.get(CoreAnnotations.SentencesAnnotation.class) != null
&& doc.get(CoreAnnotations.NamedEntityTagAnnotation.class) != null;
if (!ok) throw new IllegalStateException("Annotation lacks prerequisites for coref"); Try / catch
try {
corefSystem.annotate(ann);
} catch (RuntimeException e) {
logger.log(Level.SEVERE, "Document creation failed: " + e.getCause(), e.getCause());
} Prevention
- 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
When it happens
Trigger: Calling corefSystem.annotate(ann) on an Annotation that lacks required upstream annotations (tokens, sentences, parses, speaker info) or whose content crashes DocumentMaker.makeDocument.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Error initializing coref system
- edu.stanford.nlp.coref.CorefScorer.ScorerMissingException
- Cannot find gold mention with ID=
- No gold info
- Missing head tree for a mention!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b0d4a3c8764c07aa.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/coref/CorefSystem.java:61
} catch (Exception e) {
throw new RuntimeException("Error initializing coref system", e);
}
}
public CorefSystem(DocumentMaker docMaker, CorefAlgorithm corefAlgorithm,
boolean removeSingletonClusters, boolean verbose) {
this.docMaker = docMaker;
this.corefAlgorithm = corefAlgorithm;
this.removeSingletonClusters = removeSingletonClusters;
this.verbose = verbose;
}
public void annotate(Annotation ann) {
Document document;
try {
document = docMaker.makeDocument(ann);
} catch (Exception e) {
throw new RuntimeException("Error making document", e);
}
CorefUtils.checkForInterrupt();
corefAlgorithm.runCoref(document);
if (removeSingletonClusters) {
CorefUtils.removeSingletonClusters(document);
}
CorefUtils.checkForInterrupt();
Map<Integer, CorefChain> result = Generics.newHashMap();
for (CorefCluster c : document.corefClusters.values()) {
result.put(c.clusterID, new CorefChain(c, document.positions));
}
ann.set(CorefCoreAnnotations.CorefChainAnnotation.class, result);
}
public void initLogger(Logger logger, String logFileName) {
try {View on GitHub (pinned to 1b7edd19c4)