user3505558
user3505558

Reputation: 31

how to form a Tree (adapted from stanford parser) from String (which is not the output from Stanford Parser)

I need to extract the SVO (Subject, Verb, Object) of the Indonesian sentences. I have the string parse tree in Indonesian, and now I need to transform it to Tree form (which is adapted from Tree class Stanford parser). Can anyone tell me how to build the tree?

some references just tell me about build the tree automatically from the output of Stanford Parser like this :

.... 
Tree tree = parser.apply(tokens);
....

I just want to use the Tree class, but the input is not the output from Stanford Parser.

Thanks before!

Upvotes: 3

Views: 619

Answers (1)

justhalf
justhalf

Reputation: 9107

You can use Tree.valueOf(String)

Tree tree = Tree.valueOf(tokens);

From the documentation linked above:

This gives you a tree from a String representation (as a bracketed Tree, of the kind produced by toString(), pennPrint(), or as in the Penn Treebank). It's not the most efficient thing to do for heavy duty usage. The Tree returned is created by a LabeledScoredTreeReaderFactory. This means that "standard" normalizations (stripping functional categories, indices, empty nodes, and A-over-A nodes) will be done on it.

Upvotes: 3

Related Questions