【发布时间】:2021-06-18 13:18:14
【问题描述】:
这是我写给 NER(命名实体识别)的 Python 代码,这是一个用例场景,用户使用 Jupiter notebook 作为给定文本输入。
首先,我编写了一个代码,将场景输入为文本。
text = "customer must be registered if wants to buy the product.unregistered user can’t go to
the shopping cart. Customer logins to the system by entering valid user id and password for
the shopping. customer can make order or cancel order of the product from the shopping cart
after login or registration. Customer has to logout after ordering or surfing for the product "
下一步,我必须把它变成一个字符串。
text_combined = str(text)
其次,我将其放入文档中。
doc = nlp(text_combined)
然后我编写了 NER 代码。我已经放了输出的截图。
for ent in doc.ents:
print(ent.text,ent.label_)
最后,我希望像客户这样的实体是一个人。但是代码被标识为一个组织。 (附上截图)你能解释一下这是为什么吗?有没有人可以解决这个问题?
spacy.displacy.render(doc, style='ent',jupyter=True)
【问题讨论】:
-
您正在加载哪种语言模型?你能在一帧中发布你的代码,而不用拆分它吗?
-
1.显示您的实际代码,在其中创建 NLP 对象和所有内容。 2. 请勿贴代码截图,将代码复制粘贴为文本。
-
对不起,我不知道该怎么做。能否请您解释一下如何将此代码作为 NLP Jupiter 代码?
标签: python spacy named-entity-recognition junit-jupiter