0

Is there any method to check if a sentence is grammatically correct or not using stanford parser? As of now am able to get the parse tree of a sentence using stanford parser. I got stuck here and don't know how to proceed further.

alvas
  • 115,346
  • 109
  • 446
  • 738
user2138780
  • 1
  • 1
  • 1
  • 1
    That's not what parsers like Stanford are designed for -- they're built for robust parsing even in the face of ungrammatical input. See the [FAQ](http://nlp.stanford.edu/software/parser-faq.shtml#j). – Fred Foo Mar 07 '13 at 16:50
  • Then, how do i check whether a sentence is grammatically correct or not? Is there any procedure to do it? – user2138780 Mar 07 '13 at 16:54
  • Google around for "Python grammar checker". I've no hands-on experience with the problem, so I can't recommend any particular tool. – Fred Foo Mar 07 '13 at 16:55

1 Answers1

0

larsmans is right that those parsers are not designed for that, but here is a hack:

You can try using the parser "confidence". Each probabilistic parser calculates probabilities of different tags and assigns the most probable sequence. I've tried this with a part of speech tagger (http://www.ark.cs.cmu.edu/TweetNLP/), where each tag is assigned with some confidence (0.93, 0.45, etc.), I calculate the average confidence of all tags in a sentence and compare it to some confidence threshold (based on other sentences in the corpus).

Obviously if the confidence of the tags is not high enough I assume the sentence is grammatically incorrect. After some more heuristics - like taking care of punctuation or one-word sentences - it worked for me.

Stanford parser is probabilistic and calculates probabilities for sure but I couldn't get it the confidence of the box. Perhaps you'll have to dig in and see how you can expose it.

Yasen
  • 1,663
  • 10
  • 17