iso-639 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/iso-639.gemspec +1 -1
- data/lib/iso-639.rb +3 -3
- metadata +1 -1
data/iso-639.gemspec
CHANGED
data/lib/iso-639.rb
CHANGED
@@ -498,9 +498,9 @@ class ISO_639 < Array
|
|
498
498
|
self["zza", "", "", "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki", "zaza; dimili; dimli; kirdki; kirmanjki; zazaki"]
|
499
499
|
]
|
500
500
|
|
501
|
-
#
|
501
|
+
# An inverted index generated from the ISO_639_2 data. Used for searching
|
502
502
|
# all words and codes in all fields.
|
503
|
-
|
503
|
+
INVERTED_INDEX = lambda {
|
504
504
|
index = {}
|
505
505
|
ISO_639_2.each_with_index do |record, i|
|
506
506
|
record.each do |field|
|
@@ -558,7 +558,7 @@ class ISO_639 < Array
|
|
558
558
|
# French name field.
|
559
559
|
def search(term)
|
560
560
|
normalized_term = term.downcase.strip
|
561
|
-
indexes =
|
561
|
+
indexes = INVERTED_INDEX[normalized_term]
|
562
562
|
indexes ? ISO_639_2.values_at(*indexes).uniq : []
|
563
563
|
end
|
564
564
|
end
|