stanfordnlp/CoreNLP · error · RuntimeException
Cannot find gold mention with ID=
Error message
Cannot find gold mention with ID=
What it means
Document.extractGoldLinks throws when a gold Mention's originalRef points to a mention ID absent from the document's positions map — i.e., the gold coreference chain references a mention that was never extracted. This is a data consistency failure in gold annotations.
Solutions
- Regenerate or re-download the gold corpus files and verify integrity
- Check that mention extraction settings match the gold data format (no filtering that drops referenced mentions)
- Pre-validate gold data: every non-negative originalRef must map to an existing mention
- Run on the official supported CoNLL-2012 gold files rather than converted/modified copies
Defensive patterns
Strategy: validation
Validate before calling
for (List<Mention> ms : doc.goldMentions)
for (Mention m : ms)
if (m.originalRef >= 0 && !doc.positions.containsKey(m.originalRef))
throw new IllegalStateException("Dangling gold ref: " + m.originalRef); Try / catch
try {
doc.getGoldLinks();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Cannot find gold mention with ID=")) {
logger.severe("Gold data corrupt; regenerate gold files: " + e.getMessage());
} else throw e;
} Prevention
- Use official, unmodified CoNLL-2012 gold data and verify checksums
- Avoid hand-editing gold files; regenerate through the supported converters
- Keep mention extraction settings consistent with the gold data version
- Pre-validate gold chains in a data-loading script
When it happens
Trigger: extractGoldLinks (via getGoldLinks) processing gold CoNLL annotations where m.originalRef >= 0 but positions.get(m.originalRef) returns null — a dangling reference in the gold data or mention filtering removed the referenced mention.
Common situations: Corrupted or hand-edited gold CoNLL files; preprocessed corpora where mentions were filtered but reference links were not updated; version mismatch between mention extraction and gold data format.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- No gold info
- edu.stanford.nlp.coref.CorefScorer.ScorerMissingException
- Error initializing coref system
- Error making document
- Missing head tree for a mention!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/12a5153ffd9379af.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/coref/data/Document.java:290
IntTuple pos = new IntTuple(2);
pos.set(0, i);
pos.set(1, j);
positions.put(id, pos);
antecedents.put(id, new ArrayList<>());
}
}
// SieveCoreferenceSystem.debugPrintMentions(System.err, "", goldOrderedMentionsBySentence);
for (List<Mention> mentions : goldMentions) {
for (Mention m : mentions) {
int id = m.mentionID;
IntTuple src = positions.get(id);
assert (src != null);
if (m.originalRef >= 0) {
IntTuple dst = positions.get(m.originalRef);
if (dst == null) {
throw new RuntimeException("Cannot find gold mention with ID=" + m.originalRef);
}
// to deal with cataphoric annotation
while (dst.get(0) > src.get(0) || (dst.get(0) == src.get(0) && dst.get(1) > src.get(1))) {
Mention dstMention = goldMentions.get(dst.get(0)).get(dst.get(1));
m.originalRef = dstMention.originalRef;
dstMention.originalRef = id;
if (m.originalRef < 0) break;
dst = positions.get(m.originalRef);
}
if (m.originalRef < 0) continue;
// A B C: if A<-B, A<-C => make a link B<-C
for (int k = dst.get(0); k <= src.get(0); k++) {
for (int l = 0; l < goldMentions.get(k).size(); l++) {
if (k == dst.get(0) && l < dst.get(1)) continue;
if (k == src.get(0) && l > src.get(1)) break;View on GitHub (pinned to 1b7edd19c4)