How to change an Artist's spelling?

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

How to change an Artist's spelling?

Postby Scottes » Fri Apr 12, 2013 1:54 pm

Some time ago I wrote a Python script to query MM and find similar Artists, Songs and Albums using the Levenshtein distance algorithms. The goal was to find misspellings and mis-punctuations like Pink vs P!nk, or Crosby Stills & Nash vs Crosby, Stills and Nash. The program spit out several lists of near-matches, and I would use those lists and go into MM to manually make changes.

I doing this over in C# because I want to eliminate the manual process, and build a graphical interface with button that will let me easily indicate the changes to make. Since I don't fully understand the MM database, I wanted to make sure that I do the changes correctly.

The program is just beginning, but right now I do an OpenSQL query, and then I iterate over the results, adding each Artist to a list:
Code: Select all
var QueryData = SDB.Database.OpenSQL( "select * from artists" );
while( true )
    if (QueryData.StringByName("Artist") == null)
    ArtistsList.Add( QueryArtists.StringByName("Artist") )

I then iterate over the list of Artists, computing Levenshtein distances to find Artists with similar names. The program will display similar Artist names, allowing me to choose which one is correct (and thus which is incorrect), or that the pair is not a match and should be ignored.

Now let's say that I have find an Artist with the correct spelling and another Artist with the "same" name spelled incorrectly. If I just change the incorrect spelling to the correct spelling, would I end up with 2 Artists with the correct spelling? Would MM handle this or complain?

I am thinking that I really should step through all the Songs, with a query to match to the incorrect spelling, and change each song's Artist to the Artist with the correct spelling. Something like (semi-pseudo-code):
Code: Select all
QUERY = "Artist LIKE " + IncorrectSpelling
var QuerySongs = SDB.Database.QuerySongs( QUERY );

foreach( Song in QuerySongs ) {
    Song = QuerySongs.Item;
    Song.ArtistName = CorrectSpelling;

Am I correct in this thinking that I should change each song, or can I do it faster by making one change in the Artist table?

Any other tips/info would be appreciated! Thanks.
MonkeyMatch - Find and fix similar/incorrect spellings
MonkeyMatch Thread
Posts: 139
Joined: Sat Mar 21, 2009 6:51 am

Return to MediaMonkey 4 Addons developer forum

Who is online

Users browsing this forum: No registered users and 3 guests