liveBook · Manning

Coreference resolution

As explained in Graph Algorithms for Data Science

Coreference resolution is the task of identifying expressions in text that refer to the same entity and linking them to that entity.

Coreference resolution identifies expressions that refer to the same entity and links those expressions together. It serves as an early step in information extraction, helping later systems extract relationships from unstructured text. section 12.1 section 12.6

Coreference systems resolve several kinds of references:

  • Pronouns and names, such as “Google” and “they,” when both refer to the same entity. section 12.1
  • Ambiguous descriptions, such as “the company,” which may require contextual knowledge to distinguish Google from YouTube. section 12.1
  • Plural references, such as “both companies,” which may resolve to multiple entities. section 12.1
  • Rule-based approaches use syntactic, semantic, and contextual heuristics; neural approaches learn patterns from data instead. section 12.1

Resolving references in an Apple narrative

Given a passage about Apple Inc., Steve Jobs, Steve Wozniak, and Ronald Wayne, a model can replace “They” with the founders and “the company” with Apple Inc. The result can still be wrong: it may assign “his” in “Jobs sold his Volkswagen Bus” to Ronald Wayne, mishandle possessives and articles, or choose AlgoTrim instead of Apple Inc. as the company that acquired Semetric. section 12.4 section 12.4.2

Listing 12.6 Using the coreference model to resolve text references
def coref_text(text):
   coref_doc = coref_nlp(text)
   resolved_text = ""

   for token in coref_doc:
       repres = coref_doc._.coref_chains.resolve(token)
       if repres:
           resolved_text += " " + " and ".join(
               [
                   t.text
                   if t.ent_type_ == ""
                   else [e.text for e in coref_doc.ents if t in e][0]
                   for t in repres
               ]
           )
       else:
           resolved_text += " " + token.text

   return resolved_text

ctext = coref_text(text)
print(ctext)

Inspect the Python function that runs the SpaCy coreference model, resolves each token, substitutes named entities, and builds resolved text. section 12.4.2

How Graph Algorithms for Data Science covers it

How deep it goes
Explains definitions, ambiguity, approach types, and an implementation, but stops short of training models or detailed optimization.
Examples
Uses Google and YouTube ambiguity, plural company references, and an Apple Inc. passage with deliberately exposed resolution errors.
What it assumes
Assumes basic familiarity with text entities and NLP pipelines while defining coreference resolution and its main approaches from zero.
What you can do after
Apply it via SpaCy and coreferee to replace references with resolved entities and inspect downstream extraction risks.
How it connects
Connects to information extraction, named entity recognition, entity linking, relation extraction, text summarization, and question answering.

Also explained in

Compare how 3 books explain coreference resolution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.