I want to check that 2 words are very close each others. My need is really simple: we allow the user to execute an action by answering to an email, and the user should answer with one word (APPROVED
, REFUSED
, etc.). The list of possible action is really short. Now, I have to parse this answer, but my comparison has to be "typo-safe", i.e. if the user input is aproved
or apporved
for example, it should be ok.
Of course I can create my own almost-ok words (["Approved", "Aproved", "Apporved", ...]
) and compare the user input with each element of this array, but defining all possible typos is really boring...
I know that I can do that with Lucene, but it seems a little bit too much for my needs, and ideally I would like to have a method like WordUtils.proximity("Approved", userInput)
. In addition, a phonetical comparison is not mandatory in my case.
Is there a small library that can do that?