huggingface / neuralcoref

✨Fast Coreference Resolution in spaCy with Neural Networks
https://huggingface.co/coref/
MIT License
2.85k stars 477 forks source link

getting a none value for `print(doc._.coref_clusters)` #259

Closed chettipalli closed 4 years ago

chettipalli commented 4 years ago

hey people, I have attached code and the output. As you can see I am getting a none value when I am trying to print(doc._.coref_clusters) and the code above line in the given program is giving the output well and good. why is this? something related to new version bugs or something like that? please respond, thanks.

import spacy
import neuralcoref

nlp = spacy.load('en')
doc = nlp('My sister has a dog. She loves him.')

for token in doc:
    print('{}:{}'.format(token,token.vector[:3]))
neuralcoref.add_to_pipe(nlp)
print(doc._.coref_clusters)

doc2 = nlp('Angela lives in Boston. She is quite happy in that city.')
for ent in doc2.ents:
    print(ent._.coref_cluster)
(spacy) C:\Users\Gourav\Desktop\py3>python coref.py
C:\Users\Gourav\Anaconda3\envs\spacy\lib\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)
C:\Users\Gourav\Anaconda3\envs\spacy\lib\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)
C:\Users\Gourav\Anaconda3\envs\spacy\lib\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)
My:[3.3386087  0.17132008 2.5449834 ]
sister:[ 0.57823443  2.995358   -0.9161793 ]
has:[-1.2454867   0.10024977 -2.9887996 ]
a:[-2.6144893  -0.87124985  0.77286935]
dog:[-1.5898073  1.3804269 -1.875045 ]
.:[-0.20775741 -3.216754   -0.9142698 ]
She:[ 1.9065745 -1.1759269 -1.1481409]
loves:[-3.0270743  0.6966858 -3.8048356]
him:[ 2.6918807 -1.7273386 -5.5162654]
.:[-1.5350039 -2.1957831 -1.6328099]
None
chettipalli commented 4 years ago

guys i got it!