This is a discussion on What is Soundex? within the PHP Programming forums, part of the Web Development category; Hi, hi guys please explain What is Soundex?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi Senraj, Soundex is a hashing system for english words. From an english word, you generate a letter and three numbers. that roughly describe how an given word sounds. Similar sounding words will have similar codes.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The Soundex code for a name consists of a letter followed by three numbers: the letter is the first letter of the name, and the numbers encode the remaining consonants. Similar sounding consonants share the same number so, for example, the labial B, F, P and V are all encoded as 1. Vowels can affect the coding, but are never coded directly unless they appear at the start of the name.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The exact algorithm is as follows:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In PHP Soundex keys have the property that words pronounced similarly produce the same soundex key, and can thus be used to simplify searches in databases where you know the pronunciation but not the spelling
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Soundex Examples PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| soundex() The soundex() function calculates the soundex key of a string. A soundex key is a four character long alphanumeric string that represent English pronunciation of a word. The soundex() function can be used for spelling applications. This function returns the soundex key of the string on success, or FALSE on failure. Syntax soundex(string) string - Required. Specifies the string to check Tips and Notes Note: The soundex() function creates the same key for similar sounding words. Tip: metaphone() is more accurate than soundex(), because metaphone() knows the basic rules of English pronunciation.
__________________ Thanks & Regards, R.Kamalakannan. |
| |||
| One more Example: In this example use the soundex() function on two similar sounding words: PHP Code: PHP Code:
__________________ Thanks & Regards, R.Kamalakannan. |
| |||
| Hi, Soundex function is built in every platforms like javascript, perl or MySql or MS Sql, etc., I think whoever wants to work on it then it is useful. Any idea how it used in MySql?
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Metaphone is a phonetic algorithm, an algorithm for indexing words by their sound, when pronounced in English. The algorithm produces variable length keys as its output, as opposed to Soundex's fixed-length keys. Similar sounding words share the same keys.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| In Javascript we won't have this actual function, but we have prototype function as: HTML Code: <script> String.prototype.soundex = function(p){ //v1.0 var i, j, r, p = isNaN(p) ? 4 : p > 10 ? 10 : p < 4 ? 4 : p, m = {BFPV: 1, CGJKQSXZ: 2, DT: 3, L: 4, MN: 5, R: 6}, r = (s = this.toUpperCase().replace(/[^A-Z]/g, "").split("")).splice(0, 1); for(i in s) for(j in m) if(j.indexOf(s[i]) + 1 && r[r.length-1] != m[j] && r.push(m[j])) break; return r.length > p && (r.length = p), r.join("") + (new Array(p - r.length + 1)).join("0"); }; </script>
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| we can use the above prototype function as HTML Code: <script> alert("Jonas\nJones\nMatrix\nMaytrix".replace(/\w+/g, function(s){ return s + " = " + s.soundex(); })); </script>
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Hi, In Oracle/PLSQL, the soundex function returns a phonetic representation (the way it sounds) of a string. syntax: Quote:
__________________ Thanks & Regards, R.Kamalakannan. |
| |||
| The Soundex algorithm is as follows: 1. The soundex return value will always begin with the first letter of string1. 2. The soundex function uses only the first 5 consonants to determine the NUMERIC portion of the return value, except if the first letter of string1 is a vowel. 3. The soundex function is not case-sensitive. What this means is that both uppercase and lowercase characters will generate the same soundex return value. Applies To: * Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
__________________ Thanks & Regards, R.Kamalakannan. |
| |||
| For Example: Quote:
Quote:
__________________ Thanks & Regards, R.Kamalakannan. |
| |||
| in PERL As the soundex algorithm was originally used a long time ago in the US it considers only the English alphabet and pronunciation. In particular, non-ASCII characters will be ignored. The recommended method of dealing with characters that have accents, or other unicode characters, is to use the Text::Unidecode module available from CPAN.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| example in PERL Code: use Text::Soundex; # Original algorithm. $code = soundex($name); # Get the soundex code for a name. @codes = soundex(@names); # Get the list of codes for a list of names. # American Soundex variant (NARA) - Used for US census data. $code = soundex_nara($name); # Get the soundex code for a name. @codes = soundex_nara(@names); # Get the list of codes for a list of names. # Redefine the value that soundex() will return if the input string # contains no identifiable sounds within it. $Text::Soundex::nocode = 'Z000';
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |