Every time I run the following code I found on Kaggle, I get ValueError
. This is because of new version v3 of SpaCy:
import scispacy
import spacy
import en_core_sci_lg
from spacy_langdetect import LanguageDetector
nlp = en_core_sci_lg.load(disable=["tagger", "ner"])
nlp.max_length = 2000000
nlp.add_pipe(LanguageDetector(), name='language_detector', last=True)
ValueError: [E966] nlp.add_pipe
now takes the string name of the registered component factory, not a callable component. Expected string, but got <spacy_langdetect.spacy_langdetect.LanguageDetector object at 0x00000216BB4C8D30> (name: 'language_detector').
If you created your component with
nlp.create_pipe('name')
: remove nlp.create_pipe and callnlp.add_pipe('name')
instead.If you passed in a component like
TextCategorizer()
: callnlp.add_pipe
with the string name instead, e.g.nlp.add_pipe('textcat')
.If you're using a custom component: Add the decorator
@Language.component
(for function components) or@Language.factory
(for class components / factories) to your custom component and assign it a name, e.g.@Language.component('your_name')
. You can then runnlp.add_pipe('your_name')
to add it to the pipeline.
I have installed these versions:
python_version : 3.8.5
spacy.version : '3.0.3'
scispacy.version : '0.4.0'
en_core_sci_lg.version : '0.4.0'