Basic Text Categorization fails in 3.2 #9732
-
A very basic test for Text Categorization fails. import spacy
nlp = spacy.load("en_core_web_md")
doc = nlp("This is a sentence.")
textcat = nlp.add_pipe("textcat")
processed = textcat(doc) I get the following error:
I tried using en_core_web_sm, and another piece of code dervied from the API docs as follows. I still get the same error. nlp = spacy.load("en_core_web_sm")
from spacy.pipeline.textcat import DEFAULT_SINGLE_TEXTCAT_MODEL
config = {
"threshold": 0.5,
"model": DEFAULT_SINGLE_TEXTCAT_MODEL,
}
nlp.add_pipe("textcat", config=config)
nlp("spacy.io usage spacy-101") Info about spaCy
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The |
Beta Was this translation helpful? Give feedback.
The
textcat
component that you've just added this way hasn't been initialized (it doesn't even know which labels it's supposed to predict) and it hasn't been trained. I'd suggest having a look at the training docs (https://spacy.io/usage/spacy-101#training, https://spacy.io/usage/training) and trying out a textcat demo project (spacy project clone pipelines/textcat_demo
, https://spacy.io/usage/projects)