Skip to content

Commit

Permalink
more flexible field of science parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 1, 2020
1 parent 4053577 commit 8bfdcf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
14 changes: 7 additions & 7 deletions lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand All @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion lib/bolognese/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bolognese
VERSION = "1.6.9"
VERSION = "1.6.10"
end

0 comments on commit 8bfdcf3

Please sign in to comment.