Created
July 31, 2013 12:21
-
-
Save Leko/6121520 to your computer and use it in GitHub Desktop.
https://codeiq.jp/ace/fshin2000/q391 このお店とこのお店は同じ店?!
This file contains hidden or 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
# encoding: utf-8 | |
# このお店とこのお店は同じ店?! | |
# https://codeiq.jp/ace/fshin2000/q391 | |
searches = [ | |
"中目黒いぐち", | |
"まるかつ水産 東京ミッドタウン店", | |
"寿司寿" | |
] | |
strs = [ | |
[ | |
"焼鳥 中目黒 いぐち", | |
"串若丸 本店 くしわかまる", | |
"鳥よし 中目黒店 とりよし", | |
], [ | |
"まるかつ水産 東京ミッドタウン店", | |
"まるかつ食堂 東京ミッドタウン店", | |
"東京ミッドタウン店 アンリ・ルルー", | |
"浅野屋 東京ミッドタウン店", | |
], [ | |
"六本木 寿司寿", | |
"寿し処 寿々 すず - 溜池山王/寿司", | |
"松葉寿し まつばずし - 六本木一丁目/寿司", | |
] | |
] | |
anss = [ | |
"焼鳥 中目黒 いぐち", | |
"まるかつ水産 東京ミッドタウン店", | |
"六本木 寿司寿", | |
] | |
# 方針 | |
# [一致度]が最も高いものが対象 | |
# 一致度 = 空白区切りの単語を見ていって、目的.contain?(単語)がtrueなら+1 | |
searches.each_with_index{|search, i| | |
most_match_cnt = 0 | |
most_match_idx = 0 | |
strs[i].each_with_index{|str, i| | |
match = 0 | |
str.split(" ").each{|word| | |
match += search.include?(word) ? 1 : 0 | |
} | |
if match > most_match_cnt | |
most_match_cnt = match | |
most_match_idx = i | |
end | |
} | |
puts strs[i][most_match_idx] | |
# puts strs[i][most_match_idx] == anss[i] ? "Accept" : "Wrong Answer" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment