469,909 Members | 1,748 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

String comparison algorithms

Hi,
Hope you can help me with this one. I'm looking for some nice string
comparison algorithms. I want to be able to compare 2 strings (fairly
smallish, less than 50 characters) and return a % of how well they are
similar. So, 2 strings that are absoloutly identical will return 100%.
Strings that are radically different will return numbers near 0%:-
Tokenistic Examples:

String1 String2 % Comnparison
Albatross Car 5
Car Car 100

I would appreciate any
comments/code-samples/suggestions/user-experiences that you may have...
Thanks in advance,
Al.

PS: I already have implemented Lavenstein distance, so no worries there.

Jul 18 '06 #1
4 3331
It all depends how you really want to rate the similarity

In the case that you returned 5 I don't see any similarity at all

<al*****@altavista.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi,
Hope you can help me with this one. I'm looking for some nice string
comparison algorithms. I want to be able to compare 2 strings (fairly
smallish, less than 50 characters) and return a % of how well they are
similar. So, 2 strings that are absoloutly identical will return 100%.
Strings that are radically different will return numbers near 0%:-
Tokenistic Examples:

String1 String2 % Comnparison
Albatross Car 5
Car Car 100

I would appreciate any
comments/code-samples/suggestions/user-experiences that you may have...
Thanks in advance,
Al.

PS: I already have implemented Lavenstein distance, so no worries there.

Jul 18 '06 #2
MySQL has got a similar command: soundex

$sql = "
SELECT title FROM entries
WHERE
(
title LIKE '$ax%'
OR soundex(title) LIKE soundex('$ax')
)
LIMIT 20
";


<al*****@altavista.comwrote in message news:11**********************@i42g2000cwa.googlegr oups.com...
Hi,
Hope you can help me with this one. I'm looking for some nice string
comparison algorithms. I want to be able to compare 2 strings (fairly
smallish, less than 50 characters) and return a % of how well they are
similar. So, 2 strings that are absoloutly identical will return 100%.
Strings that are radically different will return numbers near 0%:-
Tokenistic Examples:

String1 String2 % Comnparison
Albatross Car 5
Car Car 100

I would appreciate any
comments/code-samples/suggestions/user-experiences that you may have...
Thanks in advance,
Al.

PS: I already have implemented Lavenstein distance, so no worries there.

Jul 19 '06 #3
nime wrote:
MySQL has got a similar command: soundex
But soundex is not a string comparison method. It compares words by
their sound (hence the name). I doesn't give a "score" of how well two
words compare.

Jul 19 '06 #4
I think there is a dynamic programming algorithm to determine this : its
called length between the 2 strings. Google this up and I am sure you will
find some code
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : Drop-In Explorer GUI Controls For Your Apps (.Net & ActiveX
Editions Available)
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions rapidly in .Net
---------

<al*****@altavista.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi,
Hope you can help me with this one. I'm looking for some nice string
comparison algorithms. I want to be able to compare 2 strings (fairly
smallish, less than 50 characters) and return a % of how well they are
similar. So, 2 strings that are absoloutly identical will return 100%.
Strings that are radically different will return numbers near 0%:-
Tokenistic Examples:

String1 String2 % Comnparison
Albatross Car 5
Car Car 100

I would appreciate any
comments/code-samples/suggestions/user-experiences that you may have...
Thanks in advance,
Al.

PS: I already have implemented Lavenstein distance, so no worries there.

Jul 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Luca Montecchiani | last post: by
13 posts views Thread by Gram | last post: by
2 posts views Thread by s | last post: by
6 posts views Thread by rakesh | last post: by
32 posts views Thread by tshad | last post: by
15 posts views Thread by roberts.noah | last post: by
7 posts views Thread by bcutting | last post: by
5 posts views Thread by Travis | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.