开发者

How to perform a text-search on a List of CustomObjects that includes the search misspelled words?

I want to perform a text-search on entry of my custom class. That text-search should not only match for the string entered, but may also check for misspelled words. So I'm looking for a library that does that for me.

A little bit more context: Let's say I generate this business object from an SQLServer2008 database:

public class MyTextObject
{
  public String Title {get;set;}
  public String Content {get;set;}
}

In my application I'd have a

List<MyTextObject>

and want to perform a search for the word "control". The search should return any MyTextObject that has the word "control" inside the Title or Content property. So far no problem: I could easily do this with a LINQ-Expression.

Here is the tricky part:

Let's say in one of my business objects, I wanted to write "control" but I've written "cont开发者_开发百科rlo" instead. I want that the search algorithm suggests that business object as well.

How can I do that in a non brute-force way that looks for possible permutations of the search key? Is there any algorithm or library out there that might help me with this situation? I'm also open to other good suggestions =)


I can give you a simple idea that we have follow.

First we search for the word that les say is the "contrlo". If this word not found, we make an automatic correction on spelling that give us the word "control" (and maybe some more) and now we search for the corrected word.

There are a lot of spelling corrections that you can find.

Other Suggestion

I suggest to use the dtSearch. Its commercial but I say that is worth it. They give a simple dll that can do a real search with many parametres.


If I am not mistaken, you need some fuzzy like string matching algorithm. I have done something similar a while ago, I used Levenshtein Distance, and I believe this is the code that I ripped off. I was quite satisfied.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜