永远坚定 2023-03-21 18:20 采纳率: 66.7%
浏览 17
已结题

spacy 的ner模型建立

在用spacy编写ner模型时,在向ner模型中添加管道的时候,总是报错,哪位知道为啥啊

nlp=spacy.blank('en')
ner=nlp.create_pipe('ner')
nlp.add_pipe(ner, last=True

```python

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.


  • 写回答

1条回答 默认 最新

  • ChatGPTᴼᴾᴱᴺᴬᴵ 2023-03-21 18:48
    关注

    该回答引用NewBing

    你好,这是Bing。我可以帮你解决这个问题。😊


    根据搜索结果¹²³,在spacy v3中,添加管道的方式发生了变化。组件必须被注册,并且可以通过它们的名字添加到一个管道中。你可能需要使用@Language.component或者@Language.factory装饰器来注册你的自定义组件,并给它一个名字,例如@Language.component('your_name')。然后你可以运行nlp.add_pipe('your_name')来把它添加到管道中。


    如果你想要把一个已经训练好的NER模型添加到另一个模型的管道中,你还需要提供第一个模型的vocab对象给spacy.load()函数,例如:

    nlp = spacy.load("en_core_web_sm", exclude=["ner"])
    nlp_entity = spacy.load("custom_ner_model")
    nlp.add_pipe("ner", source=nlp_entity)
    

    希望这些信息对你有帮助。


    源: 与必应的对话, 2023/3/21

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月16日
  • 已采纳回答 4月8日
  • 创建了问题 3月21日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度