P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You may want to check out Text::Levenshtein, which calculates the edit distance metric (how many character changes, deletions, insertions to change one string to the other) of two strings. Calculate the edit distance between of all pairs of strings. Then pick out some string of your list and group it with ones that are within a certain distance threshold. Keep doing this until you've partitioned your original set of strings into nearby groups.
That's a very rough way of doing it, but it may give you a starting point. There are certainly better ways to choose a group than to pick a random string and just pick all its nearby ones. That original string might be on the very edge of a group, and you'd miss the ones at the opposite end. You may want to look into using some graph algorithms to find strongly connected components within this metric. Also, the fact that the edit measure is a distance metric means you can probably do better than checking all pairs of strings, but you'll have to leave that optimization to a more math-savvy monk. blokhead In reply to Re: Group Similar Items
by blokhead
|
|