Skip to content
Advertisement

Convert constituent string to Tree object (Stanza)

I am doing some experiments in Python with Stanza and I have converted a lot of sentences into ParseTree objects and saved them into a file like this:

JavaScript

And now I want to read that file, get the strings of the Tree and convert them again into a ParseTree object but I am not able to find how it should be done properly.

I checked Data Conversion but I can not find what I am trying to do and the Constituency Parser examples show how to get the string representation but not how to convert that string into a Tree.

Regards.

Advertisement

Answer

I have found the solution reading the source code in their GitHub.

Inside the constituency module, in the tree_reader file there is a method called read_trees(text) that it does exactly what I wanted.

Regards.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement