SoundexCompare
SoundexCompare simply compares the Soundex representations of the two strings AText and AOther.
The two (2) strings are converted into their phonetic representations, where each character of the resulting string represents one of six families of similar phonemes. The function then compares the first ALength characters of the resulting representations.
An ALength of 8 would give a more precise comparison than an ALength of 5.
SoundexCompare returns -
Zero (0) if the first ALength characters of the phonetic representations are identical - AText = AOther.
Minus one (-1) if the representation of AText is less than the representation of AOther - AText < AOther.
One (1) if the representation of AText is greater than the representation of AOther - AText > AOther.
Declaration: Function SoundexCompare( const AText, AOther : string; ALength : TSoundexLength) : Integer;
For instance, the Soundex value for Simon is S5500 and for Garfunkel is G6152. So Garfunkel is less than Simon. And Eugene is E2500, so is less than Garfunkel.
procedure
ScriptEvent (
var
Value : variant);
var
sConfYN :
boolean
;
begin
LogInfo(
''
);
sLen := SoundexCompare(
'ruby'
,
'roobie'
,
8
);
LogInfo(
'ruby-roobie '
+IntToStr(sLen));
sLen := SoundexCompare(
'leigh'
,
'lee'
,
8
);
LogInfo(
'leigh-lee '
+IntToStr(sLen));
sLen := SoundexCompare(
'lee'
,
'leigh'
,
8
);
LogInfo(
'lee-leigh '
+IntToStr(sLen));
sStr :=
'sleigh'
;
sStr1 :=
'slay'
;
sLen := SoundexCompare(sStr,sStr1,
8
);
LogInfo(
'sleigh-slay '
+IntToStr(sLen));
sStr :=
'michael'
;
sStr1 :=
'eugene'
;
sLen := SoundexCompare(sStr,sStr1,
8
);
LogInfo(
'michael-eugene '
+IntToStr(sLen));
sLen := SoundexCompare(sStr1,sStr,
8
);
LogInfo(
'eugene-michael '
+IntToStr(sLen));
sStr :=
'simon'
;
sStr1 :=
'garfunkel'
;
sLen := SoundexCompare(sStr,sStr1,
8
);
LogInfo(
'simon-garfunkel '
+IntToStr(sLen));
sLen := SoundexCompare(
'garfunkel'
,
'simon'
,
8
);
LogInfo(
'HC garfunkel-simon '
+IntToStr(sLen));
sLen := SoundexCompare(sStr1,sStr,
8
);
LogInfo(
'garfunkel-simon '
+IntToStr(sLen));
sLen := SoundexCompare(
'park'
,
'price'
,
8
);
LogInfo(
'park-price '
+IntToStr(sLen));
end
;
The resulting log follows -
