如何使用 spaCy 中 NER 或 EntityRuler 匹配的实体来训练 TextCategorizer?
我试图了解如何根据早期管道组件找到的命名实体(而不仅仅是原始文本)对文档进行分类。
说我有文件 “毛工资 50 美元。净工资 40 美元。税 10 美元”
我想将整个文本分类为多标签文本猫中的工资单。
通过一些自定义 EntityRuler 模式,我可以轻松预测文档实体标签,如下所示: “总工资 [金钱]。净工资 [金钱]。税收 [金钱]”
我的问题是,如何使用这些标签(存储在 doc.ents / Token.ent_type 中)作为特征来训练 TextCategorizer,以便它只关心是否令牌是金钱,并且在预测类别时不区分不同的数量($50、$40、$10)?即,如何根据所有或部分文档标记的 token.ent_type 而不是 token.text 对文档进行分类?
我正在使用 spaCy 3.2
I'm trying to understand how to classify a document based on named entities found by earlier pipeline components rather than just the raw text.
Say I have the document
"Gross Pay $50. Net Pay $40. Tax $10"
I want to classify the whole text as a PAYSLIP in a multilabel textcat.
With some custom EntityRuler patterns I can easily predict the document entity labels as something like:
"Gross Pay [MONEY]. Net Pay [MONEY]. Tax [MONEY]"
My question is, how do I use these labels (stored in doc.ents / Token.ent_type) as features to train a TextCategorizer so it only cares whether a token is MONEY and doesn't distinguish between the different quantities ($50, $40, $10) when predicting a category? ie, how do I classify documents based on token.ent_type and not token.text for all or some of the documents' tokens?
I'm using spaCy 3.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论