lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.5.14 vs lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.5.15
- old
+ new
@@ -17,11 +17,11 @@
end
end
class SynonymNormalized < Struct.new(:name, :canonical_name, :status);end
- class VernacularNormalized < Struct.new(:name, :language);end
+ class VernacularNormalized < Struct.new(:name, :language, :locality);end
class ClassificationNormalizer
attr_reader :error_names, :tree, :normalized_data
def initialize(dwc_instance)
@@ -208,12 +208,23 @@
def ingest_vernaculars(extension)
DarwinCore.logger_write(@dwc.object_id, "Ingesting vernacular names extension")
ext, fields = *extension
ext.read do |rows|
rows[0].each do |r|
+
+ language = nil
+ if fields[:language]
+ language = r[fields[:language]]
+ elsif fields[:languagecode]
+ language = r[fields[:languagecode]]
+ end
+
+ locality = fields[:locality] ? r[fields[:locality]] : nil
+
vernacular = VernacularNormalized.new(
r[fields[:vernacularname]],
- fields[:languagecode] ? r[fields[:languagecode]] : nil)
+ language,
+ locality)
@normalized_data[r[fields[:id]]].vernacular_names << vernacular
add_name_string(vernacular.name)
end
end
end