7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/music/text/normalization.rb', line 7
def normalize_artist_name(text)
lowercase_name = text.
tr("0-9A-Za-z", "0-9A-Za-z").
downcase
case lowercase_name
when 'bruce springsteen and the e street band'
'bruce_springsteen'
when 'tom petty and the hearbreakers'
'tom_petty'
when 'bob marley and the wailers'
'bob_marley'
when 'the beatles'
'the_beatles'
when 'the verve'
'the_verve'
else
lowercase_name.
gsub(/['\.]/, '').
sub(/^(a|an|the)\ +/, '').
gsub(/[^a-z0-9\p{Hiragana}\p{Katakana}ー-一-龠々]+/, '_').
sub(/^_/, '').sub(/_$/, '')
end
end
|