// First confuse var B: Boolean; begin B: = ansiresemblestext ('abc', 'apc '); showmessage (booltostr (B); {true} B: = ansiresemblestext ('abc', 'agc '); showmessage (booltostr (B); {false} B: = ansiresemblestext ('abc', 'aac '); showmessage (booltostr (B); {false} {conclusion: the first pair is considered to be similar. What is the basis of the showmessage ?} End;
// I searched the root for the source and found this function: soundexvar S: string; begin S: = soundex ('abc'); showmessage (s); {a120} s: = soundex ('apc '); showmessage (s); {a120} s: = soundex ('agc'); showmessage (s); {A200} s: = soundex ('aac '); showmessage (s); {A200} {conclusion: ansiresemblestext is compared based on another sequence code generated by soundex} end;
// First, soundex reads the first letter, which is case-insensitive, but uses uppercase to indicate var S: string; begin S: = soundex ('xabc'); showmessage (s ); {x120} s: = soundex ('abc'); showmessage (s); {y120} s: = soundex ('zabc'); showmessage (s ); {z120} {conclusion: if the first letter is different, it will never be similar} end;
// From the 2-4 letters, soundex reads a value for them: // H w-1 // A e I o u y 0 // B F P V 1 // C G J K Q S x Z 2 // D T 3 // L 4 // m n 5 // R 6 // However, the-1 is also regarded as 0; if the letters are missing, 0 begin showmessage (soundex ('A'); {a000} showmessage (soundex ('AE') will also be considered ')); {a000} showmessage (soundex ('ai'); {a000} showmessage (soundex ('ao'); {a000} showmessage (soundex ('au ')); {a000} showmessage (soundex ('ay'); {a000} showmessage (soundex ('Ah'); {a000} showmessage (soundex ('aw ')); {a000} showmessage (soundex ('AB'); {a100} showmessage (soundex ('af'); {a100} showmessage (soundex ('ap ')); {a100} showmessage (soundex ('av'); {a100} showmessage (soundex ('ac'); {A200} showmessage (soundex ('ag ')); {A200} showmessage (soundex ('aj '); {A200} showmessage (soundex ('ak'); {A200} showmessage (soundex ('aq ')); {A200} showmessage (soundex ('as'); {A200} showmessage (soundex ('ax '); {A200} showmessage (soundex ('az ')); {A200} showmessage (soundex ('ad'); {A300} showmessage (soundex ('at'); {A300} showmessage (soundex ('al ')); {a400} showmessage (soundex ('am'); {a500} showmessage (soundex ('A'); {a500} showmessage (soundex ('Ar ')); {a600} {conclusion: as long as the above values are the same, the final result is of course similar; it seems to be based on the pronunciation classification} end;
// If the 2-4 letters are not repeated, the truth is the same as var B: Boolean; The begin {B encoding is 1} showmessage (soundex ('AB ')); {a100} showmessage (soundex ('abb'); {a100} showmessage (soundex ('abbb ')); {a100} {R is 6} showmessage (soundex ('arbb'); {a610} showmessage (soundex ('abbr ')); {a160} showmessage (soundex ('abrb'); {a161} {test} B: = ansiresemblestext ('AB', 'abbb '); showmessage (booltostr (B); {returns-1, that is, true; it considers AB and abbb to be similar} {conclusion: If the letters are repeated consecutively, the same letters will be ignored, and 0} end will be missing;
// If there are no duplicates, var B: Boolean; begin showmessage (soundex ('abcd') is no longer calculated from the first letter ')); {A123} showmessage (soundex ('abccdbcdcd'); {A123} {test} B: = ansiresemblestext ('abccd', 'abccdbcdcd '); showmessage (booltostr (B); {true} {if there are duplicates} showmessage (soundex ('abbbcd'); {A123} showmessage (soundex ('abcd ')); {A123} {test} B: = ansiresemblestext ('abbbcd', 'abcd'); showmessage (booltostr (B); {true} {conclusion: it is only encoded with the first four letters, and ignored afterwards. If 2nd-4 letters have continuous duplicates, the ignored letters will be filled with the following .} end;
// In fact, soundex also has an optional parameter. Its default value is 4var B: Boolean; begin showmessage (soundex ('abcd', 6 )); {a12300} showmessage (soundex ('abccd', 6); {a12312} {test} B: = ansiresemblesproc ('abccd', 'abccdcd '); showmessage (booltostr (B); {true} {conclusion: The ansiresemblestext function only uses the default value 4 when using soundex; that is, this problem does not exist in ansiresemblestext; if you need more complex comparisons, just call the soundex function. in addition, the ansiresemblesproc and ansiresemblestext functions are the same. He called the former, no more !} End;
// Once you understand it, no more tests are conducted. If you find it wrong, please let us know!