lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.7.2 vs lib/dwc-archive/classification_normalizer.rb in dwc-archive-0.7.3

- old
+ new

@@ -58,11 +58,11 @@ private def get_canonical_name(a_scientific_name) a_scientific_name.force_encoding('utf-8') canonical_name = @parser.parse(a_scientific_name, :canonical_only => true) - canonical_name.to_s.empty? ? a_scientific_name : canonical_name.force_encoding('utf-8') + canonical_name.to_s.empty? ? a_scientific_name : canonical_name end def get_fields(element) data = element.fields.inject({}) { |res, f| res[f[:term].split('/')[-1].downcase.to_sym] = f[:index].to_i; res } data[:id] = element.id[:index] @@ -87,14 +87,14 @@ end def set_scientific_name(row, fields) row[fields[:scientificname]] = 'N/A' unless row[fields[:scientificname]] canonical_name = '' - scientific_name = row[fields[:scientificname]].strip + scientific_name = row[fields[:scientificname]].strip.force_encoding('utf-8') if separate_canonical_and_authorship?(row, fields) - canonical_name = row[fields[:scientificname]].strip - scientific_name += " #{row[fields[:scientificnameauthorship]].strip}" + canonical_name = row[fields[:scientificname]].strip.force_encoding('utf-8') + scientific_name += " #{row[fields[:scientificnameauthorship]].strip.force_encoding('utf-8')}" else canonical_name = get_canonical_name(row[fields[:scientificname]]) end fields[:canonicalname] = row.size row << canonical_name @@ -122,12 +122,12 @@ elsif !@core_fields[:acceptednameusageid] && @core_fields[:taxonomicstatus] && status_synonym?(r[@core_fields[:taxonomicstatus]]) add_synonym_from_core(parent_id, r) else taxon = @normalized_data[r[@core_fields[:id]]] ? @normalized_data[r[@core_fields[:id]]] : @normalized_data[r[@core_fields[:id]]] = DarwinCore::TaxonNormalized.new taxon.id = r[@core_fields[:id]] - taxon.current_name = r[@core_fields[:scientificname]].force_encoding("utf-8") - taxon.current_name_canonical = r[@core_fields[:canonicalname]].force_encoding("utf-8") + taxon.current_name = r[@core_fields[:scientificname]] + taxon.current_name_canonical = r[@core_fields[:canonicalname]] taxon.parent_id = r[parent_id] taxon.rank = r[@core_fields[:taxonrank]] if @core_fields[:taxonrank] taxon.status = r[@core_fields[:taxonomicstatus]] if @core_fields[:taxonomicstatus] add_name_string(taxon.current_name) add_name_string(taxon.current_name_canonical) @@ -246,7 +246,5 @@ end end end end - -