1
0
Fork 0

give hight weight for name matching

if you search for 'Chris Martin' coldplay will be higher ranked than the
singer 'Chris Martin', and that shouldn't be so
This commit is contained in:
Jens Fahnenbruck 2012-06-21 11:34:43 +02:00
parent f5b9f2e120
commit 14f9a16c3b
2 changed files with 13 additions and 1 deletions

View File

@ -60,7 +60,13 @@ module MusicBrainz
:mbid => self.safe_get_attr(a, nil, 'id')
}
aliases = a.css('alias-list > alias').map{ |item| item.text }
if aliases.include? name
if artist[:name] == name
artist[:weight] += 100
elsif artist[:name].downcase == name.downcase
artist[:weight] += 50
elsif artist[:name].downcase.gsub(/\s/, '') == name.downcase.gsub(/\s/, '')
artist[:weight] += 25
elsif aliases.include? name
artist[:weight] += 20
elsif aliases.map{ |item| item.downcase }.include? name.downcase
artist[:weight] += 10

View File

@ -13,6 +13,12 @@ class TestMusicbrainzArtist < Test::Unit::TestCase
assert_operator(0, :<, matches.length)
assert_equal("Kasabian", matches.first[:name])
end
should "find name first than alias" do
matches = MusicBrainz::Artist.search('Chris Martin')
assert_operator(0, :<, matches.length)
assert_equal("Chris Martin", matches.first[:name])
end
should "get correct result by name" do
@artist = MusicBrainz::Artist.find_by_name('Kasabian')