Created
November 16, 2014 14:54
-
-
Save sugamasao/88bfb2936690d5508a8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ここのコードを修正して使っている(キーワードの種類をCSVの最後に追加) | |
# http://kzy52.com/entry/2014/10/05/195534 | |
require 'csv' | |
original_data = { | |
wikipedia: 'jawiki-latest-all-titles-in-ns0', | |
hatena: 'keywordlist_furigana.csv' | |
} | |
CSV.open("onomasticon.csv", 'w') do |csv| | |
original_data.each do |type, filename| | |
next unless File.file? filename | |
open(filename).each do |title| | |
title.strip! | |
next if title =~ %r(^[+-.$()?*/&%!"'_,]+) | |
next if title =~ /^[-.0-9]+$/ | |
next if title =~ /曖昧さ回避/ | |
next if title =~ /_\(/ | |
next if title =~ /^PJ:/ | |
next if title =~ /の登場人物/ | |
next if title =~ /一覧/ | |
title_length = title.length | |
if title_length > 3 | |
score = [-36000.0, -400 * (title_length ** 1.5)].max.to_i | |
csv << [title, nil, nil, score, '名詞', '一般', '*', '*', '*', '*', title, '*', '*', type] | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment