如何在句子中挑选主语,谓语,宾语和形容词 [英] How to pick out a the subject, predicate, and object and adjectives in a sentence

查看:124
本文介绍了如何在句子中挑选主语,谓语,宾语和形容词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Stanford CoreNLP在Java代码中提取句子的主语,谓语和宾语,并找出哪些形容词去往主语,谓语或宾语.

I want to extract the subject, predicate, and object of a sentence and find out which adjectives go to the subject, predicate, or object with Stanford CoreNLP in java code.

我试图使用依赖性解析器来解决此问题,方法是找到依赖性索引,检查依赖性标签是否等于amod,然后将其添加到ArrayList中,但是使用此方法有时,形容词的依赖性标签不是amod且为nmod和其他标签可能会出现.

I have tried to use the dependency parser to solve this by finding the dependency index, checking the dependency tag if it equals amod, then adding it to an ArrayList, but with this method sometimes the adjective's dependency tag is not amod and is nmod, and other tags may come up.

在确定对象和谓词时,我使用了与上述类似的方法.我检查了它是否为det,以及是否有其他任何标记表示它是谓词或对象.但是,有时会出现不同的标签,并且必须解析每个标签效率不高,这在某种程度上意味着它是指向对象的谓词.

With determining the object and predicate, I have used a similar method as above. I have checked if it is det, and if it is any other tags that mean it is a predicate or object. However, sometimes different tags come up and it is not efficient to have to parse every tag that somewhat means it is a predicate pointing to the object.

所以我的问题是,如何获得一个句子的主语,谓语和宾语以及每个形容词,而又不需要检查每个标记?

So my question is, how to I get the subject, predicate, and object of a sentence and each's adjectives but not need to check each tag?

对于上述尝试,我使用了Stanford CoreNLP Simple API,但是如果确实需要标准API,我可以.

For the above mentioned attempts, I have used Stanford CoreNLP Simple API, but I am OK with the standard API if it is truly needed.

推荐答案

您应该尝试使用openie注释器,该注释器将查找(主题,谓词,对象)三元组.

You should try out the openie annotator which will find (subject, predicate, object) triples.

示例命令:

java -Xmx5g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,depparse,coref,natlog,openie -file basic-example.txt -outputFormat text

示例:

The tall man ate the delicious pizza.

示例输出:

1.0     man     ate     pizza
1.0     man     ate     delicious pizza
1.0     tall man        ate     pizza
1.0     tall man        ate     delicious pizza

这篇关于如何在句子中挑选主语,谓语,宾语和形容词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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