http://qs1969.pair.com?node_id=754410


in reply to Cluster a big bunch of strings

I had a similar issue when I set up a web site that consolidates music charts from around the world. In my case I wanted to match names of artists and titles of songs, the source data tended to have challenges ranging from the simple ("Beatles" v "The Beatles" and "Gary Crosby" v "Gary Crosby and his Orchestra") to the really quite complex ("Paul McCartney" v "Wings").

I have used a modified Levenshtein distance algorithm on strings that have been Soundex-ed, which was then tuned so that processing the 279,524 entries currently takes 4 or so hours on a reasonable machine.

You have to match the processing you are doing with the types of mistakes in your data. For names this will be spelling mistakes (so when matching names you must preprocess them with something like Soundex). For titles I would guess that, like my song titles, the words tend to be spelt correctly but you get them in different orders, you get issues like:

So you want to process the names to spot the type of transcription error you have got. For example I take the distinctive words independent of order and use that as a first pass check, if you can quickly spot items that don't match then the tiny minority that could match can have distances calculated with a more comprehensive algorithm. My guess would be that, as with my data, the matches are few and far between.

Finally, in my case, there are always things that just don't match and have to be processed by hand. Don't be surprised to find that, for some of the dumb things people do, you just have to fix them manually. We have a continual effort to detect matches and fix them in our source data