Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added SwissMatch::ZipCode#reverse_name_transliteration_map.

  • Loading branch information...
commit 9b0dddd6cc383a14d4c8a74b465be142a8c07edb 1 parent 2bdab1c
@awd-switzerland awd-switzerland authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/swissmatch/zipcode.rb
View
17 lib/swissmatch/zipcode.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.