【发布时间】:2017-06-10 05:14:29
【问题描述】:
我正在使用斯坦福简单 NLP。我需要将所有名词值获取到 nounPhrases 数组。 me() 方法给我的输出如下:
The parse of the sentence 'I like java and python' is (ROOT (S (NP (PRP I)) (VP (VBP like) (NP (NN java) (CC and) (NN python)))))
这是我的方法
public String s = "I like java and python";
public static Set<String> nounPhrases = new HashSet<>();
public void me() {
Document doc = new Document(" " + s);
for (Sentence sent : doc.sentences()) {
System.out.println("The parse of the sentence '" + sent + "' is " + sent.parse());
if (sent.parse().equals("NN") || sent.parse().equals("NNS") || sent.parse().equals("NNP")
|| sent.parse().equals("NNPS")) {
// I need to assign all nouns to the array nounPhrases
}
}
}
我不确定我的 if 条件是对还是错,因为我是斯坦福 NLP 的新手。请帮我把我的名词放到这个数组中。
我得到了 URL 下面的示例代码表单,并对其进行了一些自定义。
【问题讨论】:
标签: java arrays parsing stanford-nlp