How do I determine if two similar band names represent the same band?

不想你离开。 提交于 2019-12-03 16:14:42

问题


I'm currently working on a project that requires me to match our database of Bands and venues with a number of external services.

Basically I'm looking for some direction on the best method for determining if two names are the same. For Example:

  • Our database venue name - "The Pig and Whistle"
  • service 1 - "Pig and Whistle"
  • service 2 - "The Pig & Whistle"
  • etc etc

I think the main differences are going to be things like missing "the" or using "&" instead of "and" but there could also be things like slightly different spelling and words in different orders.

What algorithms/techniques are commonly used in this situation, do I need to filter noise words or do some sort of spell check type match?

Have you seen any examples of something simlar in c#?

UPDATE: In case anyone is interested in a c# example there is a heap you can access by doing a google code search for Levenshtein distance


回答1:


The canonical (and probably the easiest) way to do this is to measure the Levenshtein distance between the two strings. If the distance is small relative to the size of the string, it's probably the same string. Note that if you have to compare a lot of very small strings it'll be harder to tell whether they're the same or not. It works better with longer strings.

A smarter approach might be to compare the Levenshtein distance between the two strings but to assign a distance of zero to the more obvious transformations, like "and"/"&", "Snoop Doggy Dogg"/"Snoop", etc.




回答2:


I did something like this a while ago, I used the the Discogs database (which is public domain), which also tracks artist aliases;

You can either:

  • Use an API call (namevariations field).
  • Download the monthly data dumps (*_artists.xml.gz) & import it in your database. This contains the same data, but is obviously a lot faster.

One advantage of this over the Levenshtein distance) solution is that you'll get a lot less false matches.
For example, Ryan Adams and Bryan Adams have a score of 2, which is quite good (lower is better matches, Pig and Whistle and Pig & Whistle has a score of 3), yet they're obviously different people.

While you could make a smarter algorithm (which also looks at string length, for example), using the alias DB is a lot simpler & less error-phone; after implementing this, I could completely remove the solution that was suggested in the other answer & had better matches.




回答3:


soundex may also be useful




回答4:


In bioinformatics we use this to compare DNA- or protein sequences all the time.

There are plenty of algorithms, you probably want to look at global alignments.

In this respect the Needleman-Wunsch algorithm is probably what you seek.

If you have particularly long recurring strings to compare you might also want to consider heuristic searches like BLAST.



来源:https://stackoverflow.com/questions/1918838/how-do-i-determine-if-two-similar-band-names-represent-the-same-band

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!