richardpaulhudson / coreferee

Coreference resolution for English, French, German and Polish, optimised for limited training data and easily extensible for further languages
MIT License
102 stars 16 forks source link

Error with dictionaries with python3.8 #12

Closed binbin83 closed 1 year ago

binbin83 commented 1 year ago

Hi, While testing coreferee in French on this simple example :

"Robin est un garçon, il est gentils. La Reine Elisabeth II est aussi gentille"

with this code :

import spacy
import coreferee
nlp = spacy.load("fr_core_news_lg")
nlp.add_pipe('coreferee')
doc = nlp(text)
doc._.coref_chains.print()

I get, this error message :

Unexpected error in Coreferee annotating document, skipping .... ⚠ <class 'TypeError'> ⚠ unsupported operand type(s) for |: 'dict' and 'dict'

versions: python==3.8.1 spacy==3.2.0 fr_core_news_lg==3.2.0 coreferee==1.3.1

I think this issue is due to an operation on dict that is not yet supported in python3.8. The syntax to concatenate two dicts need to be changed as follows:

a = {"exemple_1":5,"exemple_2":3}
b = {"exemple_2":5,"exemple_3":3}
c = {**a,**b}

instead of :

a = {"exemple_1":5,"exemple_2":3}
b = {"exemple_2":5,"exemple_3":3}
c = a|b

In French, the following changes need to be applied at least in this file:

"coreferee/lang/fr/language_specific_rules.py", line 1276,

After changing this file, the bug is disappearing on my example but might be in other languages or use cases.

Hope this helps, Thank you for your amazing work,

richardpaulhudson commented 1 year ago

Thank you very much for letting us know about this — I'll fix it in the next release.