Skip to content

ResemblesText ​

ResemblesText uses the Soundex method to determine whether the string AText and the string AOther are similar.

The function returns True if the two strings are determined to be similar, but otherwise will return False if it is deemed they are not similar.

The function is designed to compare words or names, and not entire sentences.

Please also refer to the string function Soundex.

INFO

Soundex is a phonetic coding algorithm that is used to encode words by how they sound - as pronounced in English.

It is not a perfect algorithm - the name Lee for instance has a different Soundex value to Leigh, even though they are pronounced the same.

And words or names that are not English in origin, will not be accommodated.

Please refer to the internet for more information regarding the Soundex algorithm.

Declaration: Function ResemblesText( const AText, AOther : string) : Boolean;

Simple examples are detailed below.

pascal
procedure ScriptEvent(var Value:Variant);
begin
 If ResemblesText('Lee', 'Leigh') then //Returns False
    LogInfo('Yes, the same!')
 else
    LogInfo('No . . . not the same.');

 If ResemblesText('simson', 'Simpson') then //Returns False
    LogInfo('Yes, the same!')
 else
    LogInfo('No . . . not the same.');

 If ResemblesText('oil', 'OYL') then //Returns True
    LogInfo('Yes, the same!')
 else
    LogInfo('No . . . not the same.');
end;

WARNING

But be careful and mindful of what may be in the string you are passing in.

Sometimes names that don’t sound alike or look even vaguely alike, have the same Soundex code.

This is illustrated in the following code.

An example is also shown in the string function Soundex.

pascal
procedure ScriptEvent(var Value:Variant);
begin
 If ResemblesText('Pierce', 'Price') then //Returns True
    LogInfo('Pierce + Price - Yes, the same!')
 else
    LogInfo('Pierce + Price - No . . . not the same.');

 If ResemblesText('Price', 'Perez') then //Returns True
    LogInfo('Price + Perez - Yes, the same!')
 else
    LogInfo('Price + Perez - No . . . not the same.');

 If ResemblesText('Park', 'Powers') then //Returns True
    LogInfo('Park + Powers - Yes, the same!')
 else
    LogInfo('Park + Powers - No . . . not the same.');

 If ResemblesText('Power', 'Powers') then //Returns False
    LogInfo('Power + Powers - Yes, the same!')
 else
    LogInfo('Power + Powers - No . . . not the same.');

  LogInfo('');
end;