checking if a sentence is grammatically correct us

2019-06-13 18:46发布

This question already has an answer here:

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.

1条回答
The star\"
2楼-- · 2019-06-13 19:26

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.

查看更多
登录 后发表回答