Java program to get parsing evaluation of sentences using stanford parser

I can get the output of tags and words for the sentence, for example: "My name is Rahul." as

My / PRP $, name / NN, is / VBZ, Rahul / NNP,. /.]

with the program:

LexicalizedParser lp = LexicalizedParser.loadModel( "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" ); lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"}); String sent = "My name is Rahul"; Tree parse = (Tree) lp.apply(sent); List taggedWords = parse.taggedYield(); System.out.println(taggedWords); 

But I also need to get a parsing batch of the offer. Is there any modification I can do with my program to get parsing?

Thanks.

+4
source share
1 answer

There is a score method in the Tree class that you can call to get a score for the proposal.

 double score = parse.score(); 
+4
source

Source: https://habr.com/ru/post/1469479/


All Articles