Stanford nndep 获取解析树
Stanford nndep to get parse trees
使用 Stanford CoreNLP,我正在尝试使用神经网络依赖解析器解析文本。它运行得非常快(这就是为什么我想使用它而不是 LexicalizedParser
),并产生高质量的依赖关系。我也有兴趣从中检索解析树(Penn-tree 样式)。因此,鉴于 GrammaticalStructure,我得到了它的根(使用 root()
),然后尝试使用 toOneLineString()
方法将其打印出来。但是,root()
returns 树的根节点,具有 empty/null 个子节点列表。我在说明或常见问题解答中找不到任何关于此的内容。
GrammaticalStructure gs = parser.predict(tagged);
// Print typed dependencies
System.err.println(gs);
// get the tree and print it out in the parenthesised form
TreeGraphNode tree = gs.root();
System.err.println(tree.toOneLineString());
这个输出是:
ROOT-0{CharacterOffsetBeginAnnotation=-1, CharacterOffsetEndAnnotation=-1, PartOfSpeechAnnotation=null, TextAnnotation=ROOT}Typed Dependencies:
[nsubj(tell-5, I-1), aux(tell-5, can-2), advmod(always-4, almost-3), advmod(tell-5, always-4), root(ROOT-0, tell-5), advmod(use-8, when-6), nsubj(use-8, movies-7), advcl(tell-5, use-8), amod(dinosaurs-10, fake-9), dobj(use-8, dinosaurs-10), punct(tell-5, .-11)]
ROOT-0
我怎样才能得到解析树?
我想我可以使用斯坦福提供的 Shift-Reduce 选区解析器。速度非常快,结果具有可比性。
使用 Stanford CoreNLP,我正在尝试使用神经网络依赖解析器解析文本。它运行得非常快(这就是为什么我想使用它而不是 LexicalizedParser
),并产生高质量的依赖关系。我也有兴趣从中检索解析树(Penn-tree 样式)。因此,鉴于 GrammaticalStructure,我得到了它的根(使用 root()
),然后尝试使用 toOneLineString()
方法将其打印出来。但是,root()
returns 树的根节点,具有 empty/null 个子节点列表。我在说明或常见问题解答中找不到任何关于此的内容。
GrammaticalStructure gs = parser.predict(tagged);
// Print typed dependencies
System.err.println(gs);
// get the tree and print it out in the parenthesised form
TreeGraphNode tree = gs.root();
System.err.println(tree.toOneLineString());
这个输出是:
ROOT-0{CharacterOffsetBeginAnnotation=-1, CharacterOffsetEndAnnotation=-1, PartOfSpeechAnnotation=null, TextAnnotation=ROOT}Typed Dependencies:
[nsubj(tell-5, I-1), aux(tell-5, can-2), advmod(always-4, almost-3), advmod(tell-5, always-4), root(ROOT-0, tell-5), advmod(use-8, when-6), nsubj(use-8, movies-7), advcl(tell-5, use-8), amod(dinosaurs-10, fake-9), dobj(use-8, dinosaurs-10), punct(tell-5, .-11)]
ROOT-0
我怎样才能得到解析树?
我想我可以使用斯坦福提供的 Shift-Reduce 选区解析器。速度非常快,结果具有可比性。