checking if a sentence is grammatically correct using stanford parser [duplicate]

巧了我就是萌 提交于 2019-12-08 12:56:21

问题


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:


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.



来源:https://stackoverflow.com/questions/15276664/checking-if-a-sentence-is-grammatically-correct-using-stanford-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!