diff --git a/Gemfile.lock b/Gemfile.lock index f41410dd..d8d760bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bolognese (1.6.9) + bolognese (1.6.10) activesupport (>= 4.2.5) benchmark_methods (~> 0.7) bibtex-ruby (>= 5.1.0) diff --git a/lib/bolognese/utils.rb b/lib/bolognese/utils.rb index 58fc3894..da5be895 100644 --- a/lib/bolognese/utils.rb +++ b/lib/bolognese/utils.rb @@ -1177,11 +1177,11 @@ def name_to_fos(name) def hsh_to_fos(hsh) # first find subject in Fields of Science (OECD) fos = JSON.load(File.read(File.expand_path('../../../resources/oecd/fos-mappings.json', __FILE__))).fetch("fosFields") - subject = fos.find { |l| l["fosLabel"] == hsh["__content__"] || "FOS: " + l["fosLabel"] == hsh["__content__"] } + subject = fos.find { |l| l["fosLabel"] == hsh["__content__"] || "FOS: " + l["fosLabel"] == hsh["__content__"] || l["fosLabel"] == hsh["subject"]} if subject return [{ - "subject" => sanitize(hsh["__content__"]), + "subject" => sanitize(hsh["__content__"] || hsh["subject"]), "subjectScheme" => hsh["subjectScheme"], "schemeUri" => hsh["schemeURI"], "valueUri" => hsh["valueURI"], @@ -1200,19 +1200,19 @@ def hsh_to_fos(hsh) # try to extract forId if hsh["subjectScheme"] == "FOR" - for_id = hsh["__content__"].split(" ").first + for_id = hsh["__content__"].split(" ").first || hsh["subject"].split(" ").first for_id = for_id.rjust(6, "0") subject = for_fields.find { |l| l["forId"] == for_id } || for_disciplines.find { |l| l["forId"] == for_id[0..3] } else - subject = for_fields.find { |l| l["forLabel"] == hsh["__content__"] } || - for_disciplines.find { |l| l["forLabel"] == hsh["__content__"] } + subject = for_fields.find { |l| l["forLabel"] == hsh["__content__"] || l["forLabel"] == hsh["subject"] } || + for_disciplines.find { |l| l["forLabel"] == hsh["__content__"] || l["forLabel"] == hsh["subject"] } end if subject [{ - "subject" => sanitize(hsh["__content__"]), + "subject" => sanitize(hsh["__content__"] || hsh["subject"]), "subjectScheme" => hsh["subjectScheme"], "schemeUri" => hsh["schemeURI"], "valueUri" => hsh["valueURI"], @@ -1224,7 +1224,7 @@ def hsh_to_fos(hsh) }] else [{ - "subject" => sanitize(hsh["__content__"]), + "subject" => sanitize(hsh["__content__"] || hsh["subject"]), "subjectScheme" => hsh["subjectScheme"], "schemeUri" => hsh["schemeURI"], "valueUri" => hsh["valueURI"], diff --git a/lib/bolognese/version.rb b/lib/bolognese/version.rb index 0b9e421a..881d1c61 100644 --- a/lib/bolognese/version.rb +++ b/lib/bolognese/version.rb @@ -1,3 +1,3 @@ module Bolognese - VERSION = "1.6.9" + VERSION = "1.6.10" end