利用spacy做测试,写精确和返回的时候,无法使用goldparse
from spacy.gold import Goldparse
Traceback (most recent call last):
File "" , line 1, in <module>
from spacy.gold import Goldparse
ModuleNotFoundError: No module named 'spacy.gold'
for ent in doc_to_test.ents:
doc_gold_text = nlp.make_doc(text)
gold = GoldParse(doc_gold_text, entities=annot.get("entities"))
y_true = [ent.label_ if ent.label_ in x else 'Not ' + ent.label_ for x in gold.ner]
y_pred = [x.ent_type_ if x.ent_type_ == ent.label_ else 'Not ' + ent.label_ for x in doc_to_test]
if (d[ent.label_][0] == 0):
spacy 模块中没有 Goldparse 模块,才报的这个异常,检查下你的spacy 模块版本,建议重新安装一下spacy 就行。
如果以上回答对您有所帮助,点击一下采纳该答案~谢谢