huggingface / neuralcoref

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

Get index of span #243

Closed iknoorjobs closed 4 years ago

iknoorjobs commented 4 years ago

I want to get the index of span element in text.

Example:

doc = nlp('My sister has a dog. She loves him') doc._.coref_clusters Output: [My sister: [My sister, She], a dog: [a dog, him]]

Now,

doc._.coref_clusters[0].mentions[1] Output: She

I want to get the starting index of "She" in doc. (Starting index of "She" is 21)

Basically, I want the output as [My sister: [0, 21], a dog: [14, 31]]

iknoorjobs commented 4 years ago

Fixed it. Thanks