A multi-lingual approach to AllenNLP CoReference Resolution, along with a wrapper for spaCy.
Project description
Crosslingual Coreference
Coreference is amazing but the data required for training a model is very scarce. In our case, the available training for non-English languages also proved to be poorly annotated. Crosslingual Coreference, therefore, uses the assumption a trained model with English data and cross-lingual embeddings should work for languages with similar sentence structures.
Install
pip install crosslingual-coreference
Quickstart
from crosslingual_coreference import Predictor
text = "Do not forget about Momofuku Ando! He created instant noodles in Osaka. At that location, Nissin was founded. Many students survived by eating these noodles, but they don't even know him."
predictor = Predictor(language="en_core_web_sm", device=-1, model_name="info_xlm")
print(predictor.predict(text)["resolved_text"])
# Output
#
# Do not forget about Momofuku Ando!
# Momofuku Ando created instant noodles in Osaka.
# At Osaka, Nissin was founded.
# Many students survived by eating instant noodles,
# but Many students don't even know Momofuku Ando.
Use spaCy pipeline
import crosslingual_coreference
import spacy
text = "Do not forget about Momofuku Ando! He created instant noodles in Osaka. At that location, Nissin was founded. Many students survived by eating these noodles, but they don't even know him."
nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('xx_coref')
doc = nlp(text)
print(doc._.coref_clusters)
# Output
#
# [[[4, 5], [7, 7], [27, 27], [36, 36]],
# [[12, 12], [15, 16]],
# [[9, 10], [27, 28]],
# [[22, 23], [31, 31]]]
print(doc._.resolved_text)
# Output
#
# Do not forget about Momofuku Ando!
# Momofuku Ando created instant noodles in Osaka.
# At Osaka, Nissin was founded.
# Many students survived by eating instant noodles,
# but Many students don't even know Momofuku Ando.
Available models
As of now, there are two models available "info_xlm", "xlm_roberta", which scored 77 and 74 on OntoNotes Release 5.0 English data, respectively.
More Examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for crosslingual-coreference-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8965cf199f27436ef0265f3b7c39aa108f08ccc843c2a2c031ac6c49e0bb6021 |
|
MD5 | cd3b700b8a4e0bfc3cd95ce0d8ff011c |
|
BLAKE2b-256 | 4fb7d8623bb959fab5d5a1e13ed7be7261ee4d7e89e32468244ca1e871c32641 |
Close
Hashes for crosslingual_coreference-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77cdb8b75c646fa3d6d9fb46d050dd0ed68563d8d076dfdca110d09124310064 |
|
MD5 | b9eba35a569ee97a0751f4e1fbce871a |
|
BLAKE2b-256 | dc54eca9364248a86b6bafc43585a5047d9e606d7fa9efd1bbd8cebe186edfa5 |