1
私はスタンフォードシンプルNLPを使用しています。 nounPhrases配列にすべての名詞の値を取得する必要があります。私()メソッドは以下のように私に出力を提供します:シンプルなCoreNLP - どのようにすべての名詞を配列に取得するのですか?
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)))))
これは私がスタンフォードNLPに新たなんだので、私の条件正しいか間違っているかのかどうかわからないんだけど、私の方法
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
}
}
}
です。私の名詞をこの配列に手伝ってください。
URLの下にサンプルコードフォームがあり、少しカスタマイズしました。