This calculates the similarity between two strings as described in Oliver . Note that this implementation does not use a stack as in Oliver's pseudo code, but recursive calls which may or may not speed up the whole process. Note also that the complexity of this algorithm is O(N**3) where N is the length of the longest string.
declaration of similar_text
int similar_text ( string $first , string $second [, float &$percent ] )
test similar_text online
comments for similar_text
On 23. Jun 2015 06:29 PoLyGLoT wrote:
similar_text is weird. I always heard it was (the num of similar characters)*200/ (length of string 1 + length of string 2). "Aluminum" "Spatula" Num letters in common = 4, which works out to be 53.3% similarity. similar_text ==> 2 letters in common, for 26.6% similarity. Why the discrepancy? I'd appreciate your input!