def self.setup(csv_path = '/tmp/keywordlist_furigana.csv', csv_url = 'http://d.hatena.ne.jp/images/keyword/keywordlist_furigana.csv')
return if @@words
@@words = { }
csv_path = File.expand_path(csv_path)
unless File.exists? csv_path
puts "haiku: downloading CSV"
open(csv_path, 'w'){ |f|
f.write(open(csv_url).read)
}
end
puts "haiku: parsing CSV"
open(csv_path).each_line{ |line|
yomi, word = *NKF.nkf('-w', line.chomp).split(/\t/)
next unless yomi and word
w = Word.new(word, yomi)
@@words[w.length] = [] unless @@words.has_key? w.length
@@words[w.length].push w
}
puts "haiku: setup done"
@@words
end