Installing NeuralCoref properly and Testing out with An Example.

Kaustav Mukherjee
1 min readFeb 5, 2022

Installation of Coreference Module to use proper spacy version .

Neuralcoref 4.0 works correctly with spacy version 2.1.0 .

If spacy version is above 2.1.0 or V3 it throws error:

ValueError: spacy.strings.StringStore size changed, may indicate binary incompatibility. Expected 112 from C header, got 64 from PyObject

conda create — name summarization-conda python=3.7
conda activate summarization-conda
pip3 install neuralcoref
pip3 uninstall spacy
pip3 install spacy==2.1.0
python3 -m spacy download en

Run the Below Code in Jupyter to resolve coreference:

# Load your usual SpaCy model (one of SpaCy English models)
import re
import pandas as pd
import bs4
import requests
import spacy
from spacy import displacy
#nlp = spacy.load('en_core_web_sm')
nlp = spacy.load('en')
import neuralcorefcoref = neuralcoref.NeuralCoref(nlp.vocab)#nlp = spacy.load('en')nlp.add_pipe(coref, name='neuralcoref')# You're done. You can now use NeuralCoref the same way you usually manipulate a SpaCy document and it's annotations.doc = nlp('My sister has a dog. She loves him.')
print(doc._.has_coref)
print(doc._.coref_clusters)
print(doc._.coref_resolved)
#doc._.coref_cluster.main
#doc._.coref_resolved
##Output:
True
[My sister: [My sister, She], a dog: [a dog, him]]
My sister has a dog. My sister loves a dog.

--

--

Kaustav Mukherjee

DISTRBUTED DEEP LEARNING ARCHITECT,DATA PHILOSOPHER,MACHINE LEARNING ON REAL-TIME STREAMS