{"record":{"id":"677f4961870675ad","repo":"stanfordnlp/CoreNLP","slug":"quoteattribution-docoreference-null-pronouncorefm","errorCode":null,"errorMessage":"QuoteAttribution doCoreference: Null pronounCorefMap","messagePattern":"QuoteAttribution doCoreference: Null pronounCorefMap","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/quoteattribution/Sieves/Sieve.java","lineNumber":101,"sourceCode":"      int currQuoteParagraph = QuoteAttributionUtils.getQuoteParagraphIndex(doc, currQuote);\n      if (currQuoteParagraph == quoteParagraph) {\n        quoteNames.addAll(scanForNames(new Pair<>(currQuote.get(CoreAnnotations.TokenBeginAnnotation.class), currQuote.get(CoreAnnotations.TokenEndAnnotation.class))).first);\n      } else {\n        break;\n      }\n    }\n\n    Set<Person> namesInParagraph = new HashSet<>();\n    for (String name : quoteNames) {\n      namesInParagraph.addAll(characterMap.get(name));\n    }\n    // log.info(\"getNamesInParagraph for \" + quote.toShorterString() + \" got \" + namesInParagraph);\n    return namesInParagraph;\n  }\n\n  public Person doCoreference(int corefMapKey, CoreMap quote) {\n    if (pronounCorefMap == null) {\n      log.warn(\"QuoteAttribution doCoreference: Null pronounCorefMap\");\n      return null;\n    }\n    Set<Person> quoteNames = new HashSet<>();\n    if (quote != null) {\n      quoteNames = getNamesInParagraph(quote);\n    }\n    // log.info(\"Names in paragraph are: \" + quoteNames);\n    String referent = pronounCorefMap.get(corefMapKey);\n    // log.info(\"pronounCorefMap lookup referent of charOffsetBegin \" + corefMapKey + \" is \" + referent);\n    Person candidate = resolveAmbiguities(referent);\n    // log.info(\"Candidate is: \" + candidate);\n    if (candidate != null && ! quoteNames.contains(candidate)) {\n      return candidate;\n    }\n    return null;\n  }\n\n  private static class TokenNode {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/quoteattribution/Sieves/Sieve.java#L83-L119","documentation":"Sieve.doCoreference resolves pronouns to people using pronounCorefMap, which is populated by a prior coreference sieve pass. If the map was never initialized (coreference not run or setup skipped), the method logs a warning and returns null instead of throwing, leaving the quote without a resolved speaker.","triggerScenarios":"Calling doCoreference (directly or via quote attribution sieves) before the pass that builds pronounCorefMap, or constructing Sieve subclasses without running the coreference stage.","commonSituations":"Custom pipelines that call quote-attribution sieves out of order; disabling the coreference sieve in AnnotatorPool options; reusing Sieve objects across documents without re-initialization.","solutions":["Ensure the coreference sieve stage runs before sieves that call doCoreference so pronounCorefMap is populated.","Check the QuoteAttributionAnnotator options — do not disable coreference (e.g. markCoref=false) when sieves need it.","Guard call sites: treat a null return from doCoreference as 'no speaker' rather than propagating it.","If invoking Sieve directly, initialize pronounCorefMap yourself before calling doCoreference."],"exampleFix":"// before\nPerson speaker = sieve.doCoreference(key, quote);\n// after\nif (corefRun) {\n  Person speaker = sieve.doCoreference(key, quote);\n  if (speaker == null) { /* quote skipped: coref unavailable */ }\n}","handlingStrategy":"type-guard","validationCode":"if (pronounCorefMap == null) { throw new IllegalStateException(\"Run the coreference sieve before doCoreference\"); }","typeGuard":"if (pronounCorefMap == null) return null; // caller must null-check","tryCatchPattern":"Person speaker = sieve.doCoreference(key, quote);\nif (speaker == null) { log.warn(\"coreference map missing or no antecedent; quote left unattributed\"); }","preventionTips":["Always run quote-attribution sieves in the documented order (coreference first)","Do not disable coreference in QuoteAttributionAnnotator options when using pronoun sieves","Null-check the Person returned by doCoreference at every call site"],"tags":["nlp","quote-attribution","coreference","null"],"backgroundTag":"null-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}