Reputation: 381
I am a bit stuck on this one problem in the current project I am working on:
I want to take one ArrayList<String>
(call it A) and compare it to many ArrayList<String>
, making note of how many strings match in these array comparisons. Then, I want to order the multiple string arrays in order from most similar to least similar to A.
Does anyone know any fast algorithms to do this? Not looking for code so much as algorithms, but I am working in Java.
Thanks!
Upvotes: 5
Views: 866
Reputation: 1
If you want to compare the similarity (or difference) between strings then try an edit distance algorithm such as the Levenshtein distance algorithm.
http://en.wikipedia.org/w/index.php?title=Levenshtein_distance
Upvotes: 0
Reputation: 393846
My suggestion :
set.contains(string)
find out how many matches each array list contains.Upvotes: 4