Reputation:
If I have a random string that has a sentence in it somewhere.
"e,ktdo.ba Hello, my name is CodeMaker efq ,z unqusiug.."
Can I use a grammar checker to find the sentence without knowing what it is ? I know finding individual words is as easy as using a list that has all the words used in the language and check if any of the words are in the string (or sometimes, even most words will do) but I don't think it's even worthy to discuss making a list of all sentences. I want to know if grammar checkers can "understand" sentence structures and find sentences in random strings (I would prefer a python library but if there isn't any that does what I wan't, I will have to use another language). Or maybe there is a library that isn't a grammar checker but can do what I want (which is doubtful because what I want to do is pretty specific). Is this even possible without AI ?
Upvotes: 1
Views: 504
Reputation: 2413
You can certainly do it without AI. Just step through each position in the string, and ask the checker if a grammatical sentence begins at that point. That's assuming the checker can return success when there's still some (unparseable) input remaining -- if not, you'd have to iterate over start and end positions, asking if the specified substring constitutes a grammatical sentence.
That's if the checker is a black box. If you know more about the grammar/language, you could improve efficiency. E.g., if, as you suggest, you have a list of all valid words in the language, then you could first find all spans of valid words separated by whitespace, then only submit those to checking.
Upvotes: 1