I just wrote a phonematic name search in C# using the Levenshtein Distance Algorithm. It is very tricky and was quite hard to figure out. This is the samething google uses, and many major search engines. it matches by rank to the text you type in, even if it is mispelled. I believe in open source, and I wrote this for one of my company projects, and with a little simple modification. You can use it for yourself. If you would like a copy of the source. feel free to contact me. Also, I am an expert in .NET so if you need help. Just ask.

It would be nice of you to post something in the code snippets section if it is easy enough to just isolate the relevant code sections. I think many people would be interested in taking a look.


Ed

I just wrote a phonematic name search in C# using the Levenshtein Distance Algorithm. It is very tricky and was quite hard to figure out. This is the samething google uses, and many major search engines. it matches by rank to the text you type in, even if it is mispelled. I believe in open source, and I wrote this for one of my company projects, and with a little simple modification. You can use it for yourself. If you would like a copy of the source. feel free to contact me. Also, I am an expert in .NET so if you need help. Just ask.

I just wrote a phonematic name search in C# using the Levenshtein Distance Algorithm.

Hi Shabosco, this is arif, i need the source for search file, as am struck in one of my project that rquires the file search. It would be of great pleasure if you could post it to my mail id : arif_829@rediffmail.com.
Thanks in advance
Arif

Hi.

Any idea how do i...

i) arrange/sort people's names displayed in a listbox in alphabetical order AND by their surnames?

ii) search for people by name? (my code now can only search by their ID no.)


Thz a lot!

This might be what you're after.... not 100% sure as just passing through the thread.

It's always worth Googling for Java solutions to these problems. This code took 2min to transpose from Java to C#

My apologise if I've misunderstood what people are after.

public static int GetLavenshteinDistance(string s, string t) {
   if (String.IsNullOrEmpty(s) || String.IsNullOrEmpty(t)) throw new ArgumentException("The strings must not be null.");
   /*
    * Ported from a Java algorithm by Chas Emerick
    * http://www.merriampark.com/ldjava.htm
    * 
    */
   int n = s.Length;
   int m = t.Length;
   if (n == 0) {
    return m;
   } else if (m == 0) {
    return n;
   }
   int[] p = new int[n + 1];
   int[] d = new int[n + 1];
   int[] _d;
   char t_j;
   int cost;
   for (int i = 0; i <= n; i++) {
    p[i] = i;
   }
   for (int j = 1; j <= m; j++) {
    t_j = t[j - 1];
    d[0] = j;
    for (int i = 1; i <= n; i++) {
     cost = (s[i - 1] == t_j) ? 0 : 1;
     d[i] = Math.Min(Math.Min(d[i - 1] + 1, p[i] + 1), p[i - 1] + cost);
    }
    _d = p;
    p = d;
    d = _d;
   }
   return p[n];
  }
This article has been dead for over six months. Start a new discussion instead.