4

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.

Frakcool
  • 10,915
  • 9
  • 50
  • 89
yAsH
  • 3,367
  • 8
  • 36
  • 67

1 Answers1

4

The Tree class has a score method you can call to get the score of the sentence.

double score = parse.score();
Mia Clarke
  • 8,134
  • 3
  • 49
  • 62
  • 1
    Do you have any idea about checking whether a sentence is grammatically correct or not with the help of these parse scores? – yAsH Mar 16 '13 at 14:15
  • 2
    Here on StackOverflow the rule is one question per thread, to make it easier for others with similair questions to find answers. Ask another question about this, asking is never wrong. – Mia Clarke Mar 16 '13 at 14:48