{"record":{"id":"5dd97c789245d15e","repo":"stanfordnlp/CoreNLP","slug":"cannot-find-gold-mention-with-id-originalref","errorCode":null,"errorMessage":"Cannot find gold mention with ID={originalRef}","messagePattern":"Cannot find gold mention with ID=(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/Document.java","lineNumber":545,"sourceCode":"        IntTuple pos = new IntTuple(2);\n        pos.set(0, i);\n        pos.set(1, j);\n        positions.put(id, pos);\n        antecedents.put(id, new ArrayList<>());\n      }\n    }\n\n//    SieveCoreferenceSystem.debugPrintMentions(System.err, \"\", goldOrderedMentionsBySentence);\n    for (List<Mention> mentions : goldOrderedMentionsBySentence) {\n      for (Mention m : mentions) {\n        int id = m.mentionID;\n        IntTuple src = positions.get(id);\n\n        assert (src != null);\n        if (m.originalRef >= 0) {\n          IntTuple dst = positions.get(m.originalRef);\n          if (dst == null) {\n            throw new RuntimeException(\"Cannot find gold mention with ID=\" + m.originalRef);\n          }\n\n          // to deal with cataphoric annotation\n          while (dst.get(0) > src.get(0) || (dst.get(0) == src.get(0) && dst.get(1) > src.get(1))) {\n            Mention dstMention = goldOrderedMentionsBySentence.get(dst.get(0)).get(dst.get(1));\n            m.originalRef = dstMention.originalRef;\n            dstMention.originalRef = id;\n\n            if (m.originalRef < 0) break;\n            dst = positions.get(m.originalRef);\n          }\n          if (m.originalRef < 0) continue;\n\n          // A B C: if A<-B, A<-C => make a link B<-C\n          for (int k = dst.get(0); k <= src.get(0); k++) {\n            for (int l = 0; l < goldOrderedMentionsBySentence.get(k).size(); l++) {\n              if (k == dst.get(0) && l < dst.get(1)) continue;\n              if (k == src.get(0) && l > src.get(1)) break;","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/Document.java#L527-L563","documentation":"extractGoldLinks resolves each mention's originalRef (gold antecedent mention ID) against the positions map and throws RuntimeException(\"Cannot find gold mention with ID=...\") when the referenced mention ID does not exist. It indicates a broken or out-of-order gold annotation where a coref link points to an unknown mention.","triggerScenarios":"extractGoldLinks processes gold mentions and a mention's originalRef is >= 0 but positions.get(m.originalRef) is null — i.e. the antecedent mention was never registered, typically due to malformed MUC/CoNLL gold key data.","commonSituations":"Corrupted or hand-edited gold key files, SGML MUC files with COREF REF attributes pointing to mentions outside the document or appearing later than expected, or gold annotations truncated mid-document.","solutions":["Validate the gold key file — every COREF REF must point to an earlier, existing mention ID","Re-obtain a clean version of the MUC/CoNLL gold file","Check for truncation or malformed SGML tags in the source document","If preprocessing gold data, ensure mention IDs are preserved and registered in positions"],"exampleFix":"// before\n<COREF ID=\"5\" REF=\"99\">he</COREF> <!-- REF 99 does not exist -->\n// after\n<COREF ID=\"5\" REF=\"3\">he</COREF> <!-- REF points to an earlier valid mention -->","handlingStrategy":"validation","validationCode":"// validate gold key: every REF must reference an earlier COREF ID\nSet<Integer> seen = new HashSet<>();\nMatcher m = Pattern.compile(\"<COREF ID=\\\"(\\\\d+)\\\"(.*?REF=\\\"(\\\\d+)\\\")?\").matcher(mucFileText);\nwhile (m.find()) {\n    int id = Integer.parseInt(m.group(1));\n    if (m.group(3) != null && !seen.contains(Integer.parseInt(m.group(3)))) {\n        throw new IllegalStateException(\"REF points to unknown mention: \" + m.group(3));\n    }\n    seen.add(id);\n}","typeGuard":null,"tryCatchPattern":"try {\n    doc.extractGoldLinks();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot find gold mention\")) {\n        log.error(\"Malformed gold key: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Validate COREF REF attributes point to earlier, existing mentions","Never hand-edit gold key files without re-validating","Re-export MUC files from a trusted converter","Check documents for truncation before extraction"],"tags":["java","corenlp","gold-annotation","data-corruption"],"backgroundTag":"record-not-found","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"}