SOUNDEX()

SOUNDEX(), SOUNDEXS()

Top  Previous  Next

 

The SOUNDEX() function returns a four character string determined by the phonetic content of a string. The SOUNDEXS() function is similar to SOUNDEX() but operates on successive elements of a dynamic array, returning a similarly structured dynamic array of results.

 

 

Format

 

SOUNDEX(string)

 

where

 

stringis the string for which the sound code is to be returned.

 

 

The SOUNDEX() function is useful for situations where it is desired to compare or locate items by their spoken sound. For example, names in a telephone directory could be indexed by their SOUNDEX() value to aid location of similar sounding names.

 

The value returned by SOUNDEX() is made up from the first letter of string in upper case followed by three digits which are found by examination of further characters of string according to the following table.

 

0A  E  H  I  O  U  W  Y
1B  F  P  V
2C  G  J  K  Q  S  X  Z
3D  T
4L
5M  N
6R

 

Non-alphabetic characters and letters in group 0 are ignored. Consecutive occurrences of the same letter insert only a single character. If the result is less than four characters long, zeros are added to fill the remaining positions. Thus the word SOUNDEX encodes to S532.

 

On ECS mode systems, the Soundex algorithm is based only on the letters A to Z, upper and lower case. The character maps do not affect this function.

 

 

Example

 

DISPLAY "Enter name "

INPUT NAME

KEY = SOUNDEX(NAME)

READ OTHER.NAMES FROM PHONONYMS, KEY THEN

  NAME = OTHER.NAMES

END

 

This program fragment prompts for and reads a name. It then establishes the soundex key for this name and attempts to read a list of similar sounding names from the PHONONYMS file. If found, this list replaces the NAME value.