nlp - Stanford nndep to get parse trees -
using stanford corenlp, trying parse text using neural nets dependency parser. runs fast (that's why want use , not lexicalizedparser), , produces high-quality dependency relations. interested in retrieving parse trees (penn-tree style) too. so, given grammaticalstructure, getting root of (using root()), , trying print out using toonelinestring() method. however, root() returns root node of tree, empty/null list of children. couldn't find on in instructions or faqs.
grammaticalstructure gs = parser.predict(tagged); // print typed dependencies system.err.println(gs); // tree , print out in parenthesised form treegraphnode tree = gs.root(); system.err.println(tree.toonelinestring()); the output of is:
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 how can parse tree too?
figured can use shift-reduce constituency parser made available stanford. it's fast , results comparable.
Comments
Post a Comment