我正在执行脚本。所以在 nlp.add_pipe 我面临着某种错误

问题描述 投票:0回答:0

您好,我正在尝试执行我的 python 脚本。但是在执行时我遇到了 NLP 错误。所以在下面我粘贴了代码片段 ans 以及完整的错误。所以请让我知道我哪里出错了

代码片段

nlp_sents = English()
nlp_sents.add_pipe(nlp_sents.create_pipe('sentencizer'))

执行时出错

ValueError: [E966] `nlp.add_pipe` now takes the string name of the registered component factory, not a callable component. Expected string, but got <spacy.pipeline.sentencizer.Sentencizer object at 0x0000019B0046E0C0> (name: 'None').

- If you created your component with `nlp.create_pipe('name')`: remove nlp.create_pipe and call `nlp.add_pipe('name')` instead.

- If you passed in a component like `TextCategorizer()`: call `nlp.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 run `nlp.add_pipe('your_name')` to add it to the pipeline.

python spacy
© www.soinside.com 2019 - 2024. All rights reserved.