Tutorial :Compare text strings to see if they match (allow slight differences)



Question:

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 string 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


Solution:1

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.


Solution:2

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


Solution:3

You can try something like: Hamming distance


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »