Re: Phonetic entry in forms
ASP.NET
Thread Starter: Paschal
Started:
Replies: 10

Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » Re: Phonetic entry in forms
« Previous Thread Next Thread »
   13 Nov 2004, 6:42
Paschal is online. Last active: 23/01/2005 01:57:13 Paschal
Phonetic entry in forms

I want the users be able to enter any name in a textbox and the system searching phonetically.

For example a school name like St Patrick and if a user type St PatrOck or St Patric the system should be able to propose a choice.

I have to do that because schools name in Ireland are quite amazing like:MUIRE AN TSOLAIS NAOIDH or SCOIL AN CHLOCHAIR CILL BHEAGAN.

I heard about Soundex, but do you know any developement for ASP.Net ?


  
   16 Nov 2004, 12:35
Marcus is not online. Last active: 19/01/2005 23:06:58 Marcus



Top 10 Posts
Joined on 31 Oct 2004
Dublin, Ireland
Posts 19
Re: Phonetic entry in forms
I have a SoundEx implementaion in C# somewhere, let me know if you want me to dig it up. Marcus



blog: http://www.styledesign.biz/weblogs/macinnesm/
 
    
   16 Nov 2004, 12:50
Paschal is online. Last active: 23/01/2005 01:57:13 Paschal
Re: Phonetic entry in forms
Yes Marcus I would appreciate that ! I have to implement this very soon.

Thanks
  
   16 Nov 2004, 1:02
Marcus is not online. Last active: 19/01/2005 23:06:58 Marcus



Top 10 Posts
Joined on 31 Oct 2004
Dublin, Ireland
Posts 19
Re: Phonetic entry in forms

public class Soundex

{

 

       private Soundex()

       {

       }

 

       public static String SoundexCodeConverter(String s_String)

       {

              String s_word = s_String.ToUpper();

              StringBuilder s_soundexCode = new StringBuilder();

              int i_wordLength = s_word.Length;

 

              s_soundexCode.Append(s_word.Substring(0,1));

 

              for ( int i=1; i

              {

                     String s_transformedChar = Transform(s_word.Substring(i,1));

 

               

                     if (!s_transformedChar.Equals( s_soundexCode.ToString().Substring(s_soundexCode.Length - 1) ))

                     {

 

                   

                           if (!s_transformedChar.Equals("A") && !s_transformedChar.Equals("S"))

                           {

 

                                  if (!s_transformedChar.Equals(" "))

                                  {

                                          s_soundexCode.Append(s_transformedChar);

                                  }

                           }  

                     }

              }

 

              s_soundexCode.Append("0000");

 

              return s_soundexCode.ToString().Substring(0,4);

       }

}

 

 

private static String Transform(String s_String)

{

 

       switch (s_String)

       {

              case "A":

              case "E":

              case "I":

              case "O":

              case "U":

              case "Y":

                     return "A";

              case "H":

              case "W":

                     return "S";

              case "B":

              case "F":

              case "P":

              case "V":

                     return "1";

              case "C":

              case "G":

              case "J":

              case "K":

              case "Q":

              case "S":

              case "X":

              case "Z":

                     return "2";

              case "D":

              case "T":

                     return "3";

              case "L":

                     return "4";

              case "M":

              case "N":

                     return "5";

              case "R":

                     return "6";

       }

 

       return " ";  

}




blog: http://www.styledesign.biz/weblogs/macinnesm/
 
    
   16 Nov 2004, 10:33
Paschal is online. Last active: 23/01/2005 01:57:13 Paschal
Re: Phonetic entry in forms
That's all [:D] I was expecting a huge algorithm
Thanks
  
   16 Nov 2004, 6:14
cperrone is not online. Last active: 20/11/2004 17:33:27 cperrone
Re: Phonetic entry in forms
If you are using SQL Server for your searces you may consider the SOUNDEX function in TSQL.
You can also use the DIFFERENCE function to check how much similar 2 terms sound based on their phonetic codes.
I've used the TSQL implementation in the past and to be honest it is far from perfect.
However, I have a more sofisticated version available if you still need a sql server implementation.
Otherwise, if you want to see 4 different C# implementations you could link to http://www.codeproject.com/csharp/soundex.asp


 
    
   16 Nov 2004, 6:18
Paschal is online. Last active: 23/01/2005 01:57:13 Paschal
Re: Phonetic entry in forms
Can you give here your version Claudio ?
  
   16 Nov 2004, 7:14
cperrone is not online. Last active: 20/11/2004 17:33:27 cperrone
Re: Phonetic entry in forms
Ummmm, I just realized I can't really post the code here because it is copyrighted. It comes straight from Ken Henderson's " The Guru's Guide to Transact-SQL "
If you haven't got this book I'd highly recommend it - it's excellent.

 
    
   16 Nov 2004, 7:17
Marcus is not online. Last active: 19/01/2005 23:06:58 Marcus



Top 10 Posts
Joined on 31 Oct 2004
Dublin, Ireland
Posts 19
Re: Phonetic entry in forms
Yes... Excellent book, I've got it too.


blog: http://www.styledesign.biz/weblogs/macinnesm/
  
   16 Nov 2004, 11:40
Paschal is online. Last active: 23/01/2005 01:57:13 Paschal
Re: Phonetic entry in forms
Incredible I got it too and I missed this one :-)

Thanks
 
    
   27 Nov 2004, 7:58
Brian Delahunty is not online. Last active: 12/01/2005 12:36:21 Brian Delahunty

Top 10 Posts
Joined on 11 Nov 2004
Posts 7
Re: Phonetic entry in forms
Looks like you've got the solution to this one already P, but just incase, it might be worth looking at fuzzy logic.. would be perfect for a phonetic matches. Some very good C# articles on fuzzy logic on the CodeProject

  
  Page 1 of 1 (11 items)
Ireland .NET Developer Alliance :: Forums » Technologies » ASP.NET » Re: Phonetic entry in forms

Powered by Community Server :: Forums