从句子中提取名称实体及其对应的数值 [英] extract name entities and its corresponding numerical values from sentence

查看:62
本文介绍了从句子中提取名称实体及其对应的数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从句子中提取信息.

I want to extract information from sentences.

目前,我可以使用 spacy 执行以下操作.

Currently, I am able to do the following using spacy.

Amy's monthly payment is $2000. -->  (Amy's monthly payment, $2000)

但是,我正在尝试执行以下操作.

However, I am trying to do the following.

The monthly payments for Amy, Bob, and Eva are $2000, $3000 and $3500 respectively.  
--> ((Amy's monthly payment, $2000), (Bob's monthly payment, $3000), (Eva's monthly payment, $3500))

有什么办法可以通过 python 库(如 Spacy)使用 NLP 方法执行任务?句子的模式不是固定的.使用正则表达式不起作用.

Is there any way that I can perform the task using the NLP method through python library such as Spacy? The pattern of the sentence is not fixed. Using regular expressions is not working.

谢谢

推荐答案

如果您查看 spacy 依赖项解析,您可以看到其中显示了连接词:因此,当您遍历依赖关系分析树时,您需要添加一些考虑到这种连接关系的逻辑.你可以像这样链接连词:

If you look at the spacy dependency parse you can see that conjunctions are shown in it: So you will need to add some logic that takes into account this conjunction relationship when you iterate through the dependency parse tree. You could link the conjunctions like this:

conjunctions = set()
for span in doc:
    if span.dep == conj:
        conjunctions.add(span.head)
        conjunctions.add(span)

您可以在此处使用 spacy 依赖解析可视化:https://.ai/demos/displacy?text=%20monthly%20payments%20for%20Amy%2C%20Bob%2C%20and%20Eva%20are%20%242000%2C%20%243000%20%20%243500%20%243500%20;model=en_core_web_lg&cpu=1&cph=1

You can play around with the spacy dependency parse visualisations here: https://explosion.ai/demos/displacy?text=The%20monthly%20payments%20for%20Amy%2C%20Bob%2C%20and%20Eva%20are%20%242000%2C%20%243000%20and%20%243500%20respectively.&model=en_core_web_lg&cpu=1&cph=1

这篇关于从句子中提取名称实体及其对应的数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆