Reputation:
I would like to run the sample code for spaCy neuralcoref on jupyter notebook.
After I asked my former questeion, Error to import spaCy neuralcoref module even follwoing the sample code, I have tried to install libraries following another answer to this issue on stackoverflow.
What should I do to run the sample code of spaCy neuralcoref?
This part is executable, but notice and output are shown.
# Add neural coref to SpaCy's pipe
import neuralcoref
neuralcoref.add_to_pipe(nlp)
notice
/Users/username/.pyenv/versions/3.7.4/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: spacy.morphology.Morphology size changed, may indicate binary incompatibility. Expected 104 from C header, got 112 from PyObject
return f(*args, **kwds)
/Users/username/.pyenv/versions/3.7.4/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: spacy.vocab.Vocab size changed, may indicate binary incompatibility. Expected 96 from C header, got 112 from PyObject
return f(*args, **kwds)
/Users/username/.pyenv/versions/3.7.4/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: spacy.tokens.span.Span size changed, may indicate binary incompatibility. Expected 72 from C header, got 80 from PyObject
return f(*args, **kwds)
output
<spacy.lang.en.English at 0x114304c10>
When I execute the below part, the popup error message is shown.
doc1 = nlp('My sister has a dog. She loves him.')
print(doc1._.coref_clusters)
popup error message on jupyter notebook
Kernel Restarting
The kernel appears to have died. It will restart automatically.
# Load your usual SpaCy model (one of SpaCy English models)
import spacy
nlp = spacy.load('en')
# Add neural coref to SpaCy's pipe
import neuralcoref
neuralcoref.add_to_pipe(nlp)
doc1 = nlp('My sister has a dog. She loves him.')
print(doc1._.coref_clusters)
I have tried to install libraries following another answer to this issue on stackoverflow.
!git clone https://github.com/huggingface/neuralcoref.git
!pip install -U spacy
!python -m spacy download en
cd neuralcoref
!pip install -r requirements.txt
!pip install -e .
Mac OS Catalina version 10.15.5
Python 3.7.4
spaCy 2.1.0
neuralcoref 4.0
Upvotes: 1
Views: 1723
Reputation: 1442
Downgrade to python 3.7
. neuralcoref works only for python 3.7
and spaCy 2.1.0.
The best way to fix this in opinion would be alter the requirements.txt of neuralcoref and change spacy>=2.1.0,<2.2.0
to spacy==2.1.0
Hope that helps.
Upvotes: 0