!mkdir temp
%cd temp
!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 .
主要诀窍在于要从资源库安装,直接pip会报错。
测试:
import neuralcoref
import spacy
nlp = spacy.load('en')
neuralcoref.add_to_pipe(nlp)
task = nlp('My sister has a dog. She loves him.')
print(task._.coref_clusters)