斯坦福解析器:如何提取依赖关系?
我的工作包括在句子中查找查询(可以是名词+动词),然后提取对象。
示例:“编码有时是一项艰巨的工作。”
我的查询是:“编码是”
。
我得到的类型化依赖项是:
nsubj(work-6, coding-1)
cop(work-6, is-2)
advmod(work-6, sometimes-3)
det(work-6, a-4)
amod(work-6, tough-5)
我的程序应该提取 nsubj 依赖项,将“coding”识别为查询并保存“work”。
也许这看起来很简单,但直到现在,我还没有找到能够提取特定类型依赖项的方法,我真的需要它来完成我的工作。
欢迎任何帮助,
My work consists in finding a query (can be noun+verb
) in a sentence, then extract the object.
exemple: "coding is sometimes a tough work."
My query would be: "coding is"
.
the typed dependencies i get are:
nsubj(work-6, coding-1)
cop(work-6, is-2)
advmod(work-6, sometimes-3)
det(work-6, a-4)
amod(work-6, tough-5)
My program should extract the nsubj dependency, identify "coding"
as the query and save "work"
.
May be this seems simple, but until now, i didn't find a method able to extract a specific typed dependency, and I really need this to finish my work.
Any help is welcome,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过以下代码查找依赖项:
You can find dependencies by following code:
我认为没有办法告诉解析器提取给定单词的依赖关系。但是,您可以只运行每个句子的依赖关系列表,搜索查询词出现在
nsubj
关系中的所有实例。另外,你如何存储句子的解析?如果(正如我从你的问题中收集到的)它在一个文本文件中,你可以使用 2 个连续的 grep,一个用于查询单词,一个用于你想要的关系,以获得相关其他单词的列表。
I don't think there's a way to tell the parser to extract the dependencies around a given word. However, you can just run through the list of dependencies for each sentence, searching for all instances in which the query word appears in an
nsubj
relationship.Also, how are you storing the parses of the sentences? If (as I gather from your question) it's in a text file, you can just use 2 successive greps, one for the query word, and one for the relationship you desire, to get a list of relevant other words.