spacy - 使用 cutom spacy ner 模型训练实体链接器模型时出错
问题描述
我已经用 spacy 的en_core_web_sm
模型训练了一个实体链接器(EL)模型,没有任何问题。但是当我使用自定义 NER 模型训练 EL 模型时,我收到一条错误消息。我该如何解决这个问题?将“sentencizer”组件添加到管道并不能解决问题。
错误:
AttributeError: 'NoneType' object has no attribute 'as_doc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("__main__"))
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\Spacy_NEL_Models\en_el_ambigue\en_el_ambigue\en_el_ambigue.py", line 123, in <module>
nlp.update(texts, annotations, drop=0.2, losses = losses, sgd=optimizer,)
File "C:\Users\work\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\language.py", line 519, in update
proc.update(docs, golds, sgd=get_grads, losses=losses, **kwargs)
File "pipes.pyx", line 1237, in spacy.pipeline.pipes.EntityLinker.update
RuntimeError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipeline with: nlp.add_pipe(nlp.create_pipe('sentencizer')) Alternatively, add the dependency parser, or set sentence boundaries by setting doc[i].is_sent_start.
解决方案
推荐阅读
- angular - Angular2:添加组件时的无限循环
- javascript - 在滚动加载更多功能时使用 js 响应,但任何 js 都不起作用
- javascript - 如何在 php 中创建一个随机序列生成器,它具有像加法和减法这样的算术运算?
- .net-core - 在 .NET Core 中记录基于用户的连接字符串
- python - Python的语法规则中的“suite”和“else”是什么?
- oracle11g - Hybris 5.6 的 ORA 异常
- python-3.x - 我们如何比较不同卷积网络的性能?
- android - Android - 将 Unicode 转换为 HTML 实体
- amazon-s3 - 使用应用脚本将图像从谷歌驱动器上传到亚马逊 S3
- php - 在 foreach 中回显一次