Я пытался научиться использовать spacy, а теперь хочу научиться использовать классную классификацию, однако пример classy, показанный на официальной веб-странице Spacy, не работает. Вот код, который я использую, за которым следует ошибка, которую я получаю. Может кто-нибудь сказать мне, как это исправить?
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:\Users\vidrr\AppData\Local\Programs\Python\Python312\Lib\site-packages\spacy\language.py", line 821, in add_pipe
pipe_component = self.create_pipe(
^^^^^^^^^^^^^^^^^
File "C:\Users\vidrr\AppData\Local\Programs\Python\Python312\Lib\site-packages\spacy\language.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
Подробнее здесь: https://stackoverflow.com/questions/786 ... on-example
Что вызывает эту ошибку в официальном примере классификации spacy classy? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему Presidio с Spacy NLP Engine не распознает организации и Pesel, пока Spacy делает?
Anonymous » » в форуме Python - 0 Ответы
- 16 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как создавать маршруты с помощью FastAPI внутри класса и classy-fastapi — продолжение
Anonymous » » в форуме Python - 0 Ответы
- 42 Просмотры
-
Последнее сообщение Anonymous
-