I’ve been trying to learn how to use spacy and now I want to learn how to use classy classification, however, the example of classy shown in the official spacy webpage is not working. Here’s the code I’m using followed by the error that I’m getting. Can someone please tell me how to fix this?
import spacy
data = {
"furniture": ["This text is about chairs.",
"Couches, benches and televisions.",
"I really need to get a new sofa."],
"kitchen": ["There also exist things like fridges.",
"I hope to be getting a new stove today.",
"Do you also have some ovens."]
}
# see github repo for examples on sentence-transformers and Huggingface
nlp = spacy.load('en_core_web_md')
nlp.add_pipe("classy_classification",
config={
"data": data,
"model": "spacy"
}
)
print(nlp("I am looking for kitchen appliances.")._.cats)
File "C:UsersvidrrAppDataLocalProgramsPythonPython312Libsite-packagesspacylanguage.py", line 821, in add_pipe
pipe_component = self.create_pipe(
^^^^^^^^^^^^^^^^^
File "C:UsersvidrrAppDataLocalProgramsPythonPython312Libsite-packagesspacylanguage.py", line 690, in create_pipe
raise ValueError(err)
ValueError: [E002] Can't find factory for 'classy_classification' for language English (en). This usually happens when spaCy calls `nlp.create_pipe` with a custom component name that's not registered on the current language class. If you're using a custom component, make sure you've added the decorator `@Language.component` (for function components) or `@Language.factory` (for class components).
Available factories: attribute_ruler, tok2vec, merge_noun_chunks, merge_entities, merge_subtokens, token_splitter, doc_cleaner, parser, beam_parser, lemmatizer, trainable_lemmatizer, entity_linker, entity_ruler, tagger, morphologizer, ner, beam_ner, senter, sentencizer, spancat, spancat_singlelabel, span_finder, future_entity_ruler, span_ruler, textcat, textcat_multilabel, en.lemmatizer