How to recognize English words via ANTLR?
I would like to determirmine if a word is in a large list of keywords (vulgar and so on) and a parser should be a good solution (it should be fast as far as I know) because I need a few rules how to rewrite these words.
My question is how to add to the grammar rules like (if it is possible):
add the asterisk after every letter in the word
leet language
simple rules like word + -ing, word +-ed
(There must be a tutorial for this but I was unable to find it.)
Note: This system will only notify admins so it doesn't have to be 100 percent accurate.
Or can you recommand me another approach that would better?
Thanks!
For a task like this a regular expression or database query is probably a better bet.
Grammars work best for situations where you have very structured data that you either need to validate is syntactically correct, or that you need to parse into another structured format.
Searching for words in a corpus is more the domain of a regex.
精彩评论