Using a Levenshtein distance algorithm sounds interesting. It could probably be interesting to use a combination of all methods in series. That is, first apply a "preprocessing function" that removes punctuation (.,!?) and flattens the any upcase characters. Then apply a Levenshtein distance algorithm to allow a generous match and spell correction then use regular expressions to allow synonyms and omission of parts of the sentence.
Originally Posted by rogster001
It depends, if you are on a POSIX box you probably have regex.h, otherwise get pcre. A regular expression is imo probably best suitable to allow variations in the input and synonyms. For example a regex string like this:
Originally Posted by .RK
Would allow for some variation in the input, including the lazy single "woods" "forrest" answer. If you also pre-process the string to flatten the case and get rid of punctuation and multiple whitespace, even more so.
const char *woods = "^((go|travel) to (the |teh )?)?(forrest|woods)$";