stanford nlp - How to add tags to a parsed tree that has no tag? -
for example, parsing tree stanford sentiment treebank
"(2 (2 (2 near) (2 (2 the) (2 end))) (3 (3 (2 takes) (2 (2 on) (2 (2 a) (2 (2 whole) (2 (2 other) (2 meaning)))))) (2 .)))"
,
where number sentiment label of each node.
i want add pos tagging information each node. such as:
"(np (adjp (in near)) (dt the) (nn end)) "
i have tried directly parse sentence, resulted tree different in sentiment treebank (may because of parsing version or parameters, have tried contact author there no response).
how can obtain tagging information?
i think code in edu.stanford.nlp.sentiment.buildbinarizeddataset should helpful. main() method steps through how these binary trees can created in java code.
some key lines out in code:
lexicalizedparser parser = lexicalizedparser.loadmodel(parsermodel); treebinarizer binarizer = treebinarizer.simpletreebinarizer(parser.gettlpparams().headfinder(), parser.treebanklanguagepack()); ... tree tree = parser.apply(tokens); tree binarized = binarizer.transformtree(tree);
you can access node tag information tree object. should @ javadoc edu.stanford.nlp.trees.tree see how access information.
also in answer have code shows accessing tree:
you want @ label() of each tree , subtree tag node.
here reference on github buildbinarizeddataset.java:
please let me know if unclear , can provide further assistance!
Comments
Post a Comment