如何使用 nlp stanford parser 获取单词之间的关系
我试图获取字符串和其他单词之间的联系,例如:
屏幕非常好
所以我想入手
屏幕良好
我只是不知道如何得知主题是screen并且描述是very good。
我的代码是
public synchronized String test(String s, LexicalizedParser lp){
if (s.isEmpty()) return "";
if (s.length()>80) return "";
System.out.println(s);
Tree parse = (Tree) lp.apply(s);
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
System.out.println(parse.dependencies(tlp.headFinder()));
}
有人能给我一个如何正确执行的例子吗?
字符串s
是寻找单词之间联系的句子。
I am trying to get the connections between string and other words like:
The screen is very good
so I want to get
screen good
I just don't know how to get that the subject is screen and the description is very good.
My code is
public synchronized String test(String s, LexicalizedParser lp){
if (s.isEmpty()) return "";
if (s.length()>80) return "";
System.out.println(s);
Tree parse = (Tree) lp.apply(s);
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
System.out.println(parse.dependencies(tlp.headFinder()));
}
Can someone give me an example of how to do it right?
The string s
is the sentence to find the connection between words.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取类型化的斯坦福依赖项(如 nsubj、dobj),您需要使用 GrammaticalStructure 类。普通树仅具有无类型依赖关系。使用这样的东西:
To get the typed Stanford Dependencies (like nsubj, dobj) you need to use the GrammaticalStructure classes. A plain Tree only has untyped dependencies. Use something like this: