I have a php program that searches for events and opening hours within given timeframes. The timeframe is usually written in textual form like "tomorrow" or "january - february". Another function takes names (the set is a short list of teachers) and timeframes as input and returns the working hours during which they don't have any classes, or in another words, they are all free at the same time.
The program naturally accepts correct dates in numeric form, but it doesn't expect the user to input anything correctly. I've found this to be useful, as the user can alter the queries more freely and use shorter terms to get the same results. Also, as a nice side effect, one can input the query using an obscure (Finnish) dialect.
This is based on the fact that everything that is searchable is either a date, a timeframe or a person. Since all of those are either found in a database or otherwise easily recognised, I can take a levenshtein measure from a metaphone of a word and take a good guess on what the user meant to ask. Naturally, I don't have to do this if the query is entered correctly.
So, my question is, can you think of a way to compare strings that isn't as expensive as the levenshtein / metaphone approach? Since the language is Finnish, using either of those apart doesn't yield good results.