Medspacy Scispacy 兼容性问题

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

我正在尝试将 en_ner_bionlp13cg_md 模型与 medspacy 一起使用。这似乎只有在我禁用解析器时才起作用,这是 medspacy 的主要吸引力,如下所示:

nlp = medspacy.load("en_ner_bionlp13cg_md", disable=['parser'])

这是成功的,但我失去了解析。

如果我运行以下命令:

nlp = medspacy.load("en_ner_bionlp13cg_md")
text = "blahblahblah"
doc = nlp(text)
visualize_ent(doc)

我收到以下错误:

ValueError Traceback (most recent call last)
Input In [86], in <cell line: 2>()
1 text = "blahblahblah"
----> 2 doc = nlp(text)
3 visualize_ent(doc)

File c:\Users\ddefr\anaconda3\lib\site-packages\spacy\language.py:1054, in Language.call(self, text, disable, component_cfg)
1052 raise ValueError(Errors.E109.format(name=name)) from e
1053 except Exception as e:
-> 1054 error_handler(name, proc, [doc], e)
1055 if not isinstance(doc, Doc):
1056 raise ValueError(Errors.E005.format(name=name, returned_type=type(doc)))

File c:\Users\ddefr\anaconda3\lib\site-packages\spacy\util.py:1722, in raise_error(proc_name, proc, docs, e)
1721 def raise_error(proc_name, proc, docs, e):
-> 1722 raise e

File c:\Users\ddefr\anaconda3\lib\site-packages\spacy\language.py:1049, in Language.call(self, text, disable, component_cfg)
1047 error_handler = proc.get_error_handler()
1048 try:
-> 1049 doc = proc(doc, **component_cfg.get(name, {})) # type: ignore[call-arg]
1050 except KeyError as e:
1051 # This typically happens if a component is not initialized
1052 raise ValueError(Errors.E109.format(name=name)) from e

File c:\Users\ddefr\anaconda3\lib\site-packages\PyRuSH\PyRuSHSentencizer.py:53, in PyRuSHSentencizer.call(self, doc)
51 def call(self, doc):
52 tags = self.predict([doc])
---> 53 cset_annotations([doc], tags)
54 return doc

File c:\Users\ddefr\anaconda3\lib\site-packages\PyRuSH\StaticSentencizerFun.pyx:48, in PyRuSH.StaticSentencizerFun.cset_annotations()

File c:\Users\ddefr\anaconda3\lib\site-packages\PyRuSH\StaticSentencizerFun.pyx:56, in PyRuSH.StaticSentencizerFun.cset_annotations()

File c:\Users\ddefr\anaconda3\lib\site-packages\spacy\tokens\token.pyx:509, in spacy.tokens.token.Token.sent_start.set()

File c:\Users\ddefr\anaconda3\lib\site-packages\spacy\tokens\token.pyx:528, in spacy.tokens.token.Token.is_sent_start.set()

ValueError: [E043] Refusing to write to token.sent_start if its document is parsed, because this may cause inconsistent state.

非常感谢任何解决此问题的帮助。如果我使用 spacy.load(),则不会出现此错误,仅使用 medspacy.load()。

spacy
1个回答
0
投票

医疗中心开发者她。这个问题之前已在我们的 GitHub issues 中提出过。

注意 scispacy 和 medspacy 都有句子边界检测算法。您需要选择其中之一,而不是两者。那么你就不会遇到这种冲突。

此外,无需“解析器”即可工作的原因是“解析器”启用句子边界方法作为依赖项。

更多信息请点击这里: https://github.com/medspacy/medspacy/issues/131

上述问题应该可以帮助您满足您的需求。如果您不同意,请随时重新打开此票证。

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