stanfordnlp/CoreNLP

How to read parser output into a Java object

singhakr opened this issue · 1 comments

I am trying to read the parser output from files, both phrase structure tree and dependency tree, back into a Java object. The data has been manually corrected for some errors, so I can't use the parser directly to get the Tree object. After some searching in the Javadoc API, I found that DiskTreebank can be used for this purpose. However, I am not sure of the exact usage of this class to read store parsed data back into Java object, which I can use programmatically. Can someone please given example of how to do this.

I know it is not very difficult to write Java code to read parser output into a Java object, but if there is a simple way provided by the Standford API itself, that would be more reliable and I would prefer that, as I might make mistakes regarding coreferences and dependencies or other details which I don't know about.

Any help or pointer will be greatly appreciated.

I have found that is as easy as this:

        DiskTreebank treebank = new DiskTreebank();

        treebank.loadPath("some-path", null);

Hope someone finds it useful.