I'm looking for some bright ideas around filtering and string searches, or at least pointers to some good articles开发者_如何学编程 on the subject. I have a C# WP7 app that has a list of items, and it searches against another list. But I find that the filter isn't very good. Lets say I have Francisco in one list, it will find San Francisco Bay Bridge in the list. One idea is to be exact, but then you miss on things like "The Bay" won't be matched to "Bay".
I guess I'm looking for best practices to make the filtering engine smarter, right now, it's pretty much just display if you get any match anywhere in the list. Below is the basic code i'm using,very simple find on a name. Just want some ideas to make it more "smart".
subList.Select(arty => mainList.Where(Item => Item.AllItems.IndexOf(item.Name, StringComparison.OrdinalIgnoreCase) >= 0))
Another popular approach is similarity in terms of necessary insertion, deletion, or substitution operations to go from one string ( the search term) to the other (matches in the data store) - the Levenshtein distance.
You can compute a score using the Levenshtein (or Edit) distance and then take the top N in terms of minimal changes needed below a certain threshold.
精彩评论