Compare text strings to see if they match (allow slight differences)
I'm trying to compare data from two sources.
ORIG Kick-Ass: Music From The Motion Picture
ALT Kick-A*s (Music from the Motion Picture)
ALT Kick-Ass: (Music from the Motion Picture)[Explicit]
ALT Kick-Ass: A dedication
ALT 1 ALT 2 and ORIG are the same match. ALT 3 is a dummy result.
I need to verify that these have a match, is there any methods available to me within the PHP library. I was thinking of counting each individual character with count_chars, then comparing that do the ORIG strin开发者_运维问答g using a percentage match. However if its a short title it wouldn't work too well.
Do you have any ideas how I could verify that they match,
Cheers,
J
Well, there's always the levenshtein distance, but I'm not sure how ultimately useful that would be for you.
Could be worth a shot, though.
you could consider using edit distance
http://en.wikipedia.org/wiki/Levenshtein_distance
the php call:
http://ca2.php.net/levenshtein
it returns the number of changes you would have to make (insertions & deletions) to transform one string into another
hth
You can try something like: Hamming distance
精彩评论