私の主な問題は、GrammaticalStructure からノードを抽出する方法がわからないことです。java netbeans で englishPCFG.ser を使用しています。私の目標は、次のような画面の品質を知ることです。
iPhone 4の画面は素晴らしいです。
私はスクリーンと素晴らしいを抽出したい。NN (画面) と VP (素晴らしい) を抽出するにはどうすればよいですか?
私が書いたコードは次のとおりです。
LexicalizedParser lp = new LexicalizedParser("C:\\englishPCFG.ser");
lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
String sent ="the screen is very good.";
Tree parse = (Tree) lp.apply(Arrays.asList(sent));
parse.pennPrint();
System.out.println();
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
Collection tdl = gs.typedDependenciesCollapsed();