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:

how nn andnns text?

you want @ label() of each tree , subtree tag node.

here reference on github buildbinarizeddataset.java:

https://github.com/stanfordnlp/corenlp/blob/master/src/edu/stanford/nlp/sentiment/buildbinarizeddataset.java

please let me know if unclear , can provide further assistance!


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -