Skip to content

Commit

Permalink
Added SwissMatch::ZipCode#reverse_name_transliteration_map.
Browse files Browse the repository at this point in the history
  • Loading branch information
awd-switzerland committed Apr 4, 2013
1 parent 2bdab1c commit 9b0dddd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/swissmatch/zipcode.rb
Expand Up @@ -158,6 +158,23 @@ def transliterated_names
).uniq
end

# @return [Hash<String, String>]
# A map to get the names which match a transliteration
def reverse_name_transliteration_map
result = {}
@all_names.map { |name|
trans_name1 = SwissMatch.transliterate1(name)
trans_name2 = SwissMatch.transliterate2(name)
result[trans_name1] ||= []
result[trans_name2] ||= []
result[trans_name1] << name
result[trans_name2] << name
}
result.each_value(&:uniq!)

result
end


# Since a zip code can - for any given language - have no name, exactly one name,
# or even multiple names, it is sometimes difficult to write good code to
Expand Down

0 comments on commit 9b0dddd

Please sign in to comment.