pythonspacyfrench

Spacy French langage gives NoneType error


Here is the code :

import spacy
nlp = spacy.load('fr_core_news_sm')
doc = nlp('Demain je travaille à la maison')
for token in doc:
    print(token.text)

It gives the error :

File "c:\users\ab\appdata\local\programs\python\python37\lib\site-packages\spacy\lang\fr\lemmatizer.py", line 49, in call if self.is_base_form(univ_pos, morphology): TypeError: 'NoneType' object is not callable

If I change 'fr_core_news_sm' to 'en_core_web_sm', it works well.

My python version is 3.7.7. And Spacy version is 2.3.1.


Solution

  • This seems to be a bug at spaCy 2.3.1: https://github.com/explosion/spaCy/issues/5728

    Downgrade to 2.3.0 and it should work: pip install spacy==2.3.0