Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Group Similar Items

by blokhead (Monsignor)
on May 27, 2003 at 16:42 UTC ( [id://261049]=note: print w/replies, xml ) Need Help??


in reply to Group Similar Items

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

Replies are listed 'Best First'.
Re: Re: Group Similar Items
by wufnik (Friar) on May 28, 2003 at 07:30 UTC
    the distance approach is great if you are considering biological sequences, but i am not sure how well it will scale if you are considering text or phrases;

    the key problem you will face is determining the right substitution/gap penalties with your distance metric.not so important with words, but important for phrases. if the text is words, determining similarity via phonemes sounds more natural.

    if you don't have an appropriate substitution/deletion penalty matrix, you could get quite dissimilar phrases clustered together.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://261049]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found