简体   繁体   中英

java program to get parse score of a sentence using stanford parser

I am able to get the output of Tags and words for the sentence like "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 the parse score of the sentence. Is there any kind of modification that I can do to my program to get the parse score?

Thanks.

Tree类有一个分数方法,你可以调用它来获得句子的分数。

double score = parse.score();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM