Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f03a674
remove numberType normalization; fixes datacite/product-backlog#787
bklaing2 Apr 28, 2026
ecfedc0
return raw DOI instead of `nil` if Crossref Funder ID is not valid; f…
bklaing2 Apr 28, 2026
7247468
return raw id instead of `nil` if ROR is not valid; fixes datacite/pr…
bklaing2 Apr 28, 2026
c409986
return raw DOI instead of `nil` if DOI is not valid; fixes datacite/p…
bklaing2 Apr 29, 2026
e86458c
return raw DOI instead of `nil` if DOI is not valid; fixes datacite/p…
bklaing2 Apr 29, 2026
f505bc5
return raw id instead of `nil` if ORCID is not valid; fixes datacite/…
bklaing2 Apr 29, 2026
fe32c68
do not manually assign `schemeUri` to ROR; fixes datacite/product-bac…
bklaing2 Apr 29, 2026
423ff9f
do not skip invalid dates, use the raw value; fixes datacite/product-…
bklaing2 Apr 29, 2026
1addbf6
do not add "Issued" date based on `publicationYear`; fixes datacite/p…
bklaing2 Apr 29, 2026
d75eeed
do not remove spaces around hyphen in name; fixes datacite/product-ba…
bklaing2 Apr 29, 2026
e6ea5ea
do not add joining comma in name; fixes datacite/product-backlog#788
bklaing2 Apr 29, 2026
e4b1af1
remove additional subject FOS mapping; fixes datacite/product-backlog…
bklaing2 May 7, 2026
6bce1d6
remove `Namae` normalization; fixes datacite/product-backlog#794
bklaing2 May 11, 2026
93adeaf
do not replace `name` with `givenName, familyName`; fixes datacite/pr…
bklaing2 May 11, 2026
73068a5
rename `name/hsh_to_fos` to `name/hsh_to_subject`
bklaing2 May 13, 2026
5567a19
JATS writer falls back to `publicationYear` when there is no `issued`…
bklaing2 May 13, 2026
010f16a
Merge branch 'metadata-normalization-changes' into remove-author-norm…
bklaing2 May 13, 2026
bd201ac
Merge pull request #233 from datacite/remove-author-normalizations
bklaing2 May 13, 2026
73693e1
Add tests for normalizations that have been removed from datacite reader
codycooperross May 14, 2026
bed5403
Fix expected FOS mapping
codycooperross May 14, 2026
b0f736b
test for unset affiliation scheme
bklaing2 May 14, 2026
ea44a4a
Merge pull request #234 from datacite/normalization-test
bklaing2 May 15, 2026
4973ca3
bump version
bklaing2 May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/bolognese/author_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ def get_one_author(author)
def cleanup_author(author)
return nil unless author.present?

# detect pattern "Smith J.", but not "Smith, John K."
author = author.gsub(/[[:space:]]([A-Z]\.)?(-?[A-Z]\.)$/, ', \1\2') unless author.include?(",")

# remove spaces around hyphens
author = author.gsub(" - ", "-")

# titleize strings
# remove non-standard space characters
author.gsub(/[[:space:]]/, ' ')
Expand Down Expand Up @@ -155,7 +149,6 @@ def get_affiliations(affiliations)
# when `normalize_id` method could not normalize, it returns nil, hence we have following condition
if affiliation_identifier.nil?
if a["affiliationIdentifierScheme"] == "ROR"
scheme_uri = "https://ror.org"
affiliation_identifier = normalize_ror(a["affiliationIdentifier"])
else
affiliation_identifier = a["affiliationIdentifier"]
Expand Down
7 changes: 4 additions & 3 deletions lib/bolognese/doi_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ def validate_doi(doi)
end

def validate_funder_doi(doi)
doi = Array(/\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.stage.datacite.org|handle.test.datacite.org)\/)?(doi:)?(10\.13039\/)?([1-9]\d+)\z/.match(doi)).last
match = Array(/\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.stage.datacite.org|handle.test.datacite.org)\/)?(doi:)?(10\.13039\/)?([1-9]\d+)\z/.match(doi)).last
return doi unless match

# remove non-printing whitespace and downcase
if doi.present?
doi.delete("\u200B").downcase
if match.present?
doi = match.delete("\u200B").downcase
"https://doi.org/10.13039/#{doi}"
end
end
Expand Down
21 changes: 9 additions & 12 deletions lib/bolognese/readers/datacite_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,12 @@ def read_datacite(string: nil, **options)

dates = Array.wrap(meta.dig("dates", "date")).map do |r|
if r.is_a?(Hash) && date = sanitize(r["__content__"]).presence
if Date.edtf(date).present? || Bolognese::Utils::UNKNOWN_INFORMATION.key?(date)
{ "date" => date,
"dateType" => parse_attributes(r, content: "dateType"),
"dateInformation" => parse_attributes(r, content: "dateInformation")
}.compact
end
{ "date" => date,
"dateType" => parse_attributes(r, content: "dateType"),
"dateInformation" => parse_attributes(r, content: "dateInformation")
}.compact
end
end.compact
dates << { "date" => meta.fetch("publicationYear", nil), "dateType" => "Issued" } if meta.fetch("publicationYear", nil).present? && get_date(dates, "Issued").blank?
sizes = Array.wrap(meta.dig("sizes", "size")).map do |k|
if k.blank?
nil
Expand Down Expand Up @@ -179,8 +176,7 @@ def read_datacite(string: nil, **options)
if funder_identifier_type == "Crossref Funder ID"
funder_identifier = validate_funder_doi(funder_identifier)
elsif funder_identifier_type == "ROR"
funder_identifier = normalize_ror(funder_identifier)
scheme_uri = "https://ror.org"
funder_identifier = normalize_ror(funder_identifier)
else
funder_identifier = normalize_id(funder_identifier) ? normalize_id(funder_identifier) : funder_identifier
end
Expand All @@ -196,7 +192,8 @@ def read_datacite(string: nil, **options)
end
related_identifiers = Array.wrap(meta.dig("relatedIdentifiers", "relatedIdentifier")).map do |ri|
if ri["relatedIdentifierType"] == "DOI"
rid = validate_doi(ri["__content__"].to_s.downcase)
doi = ri["__content__"].to_s.downcase
rid = validate_doi(doi) || doi
else
rid = ri["__content__"]
end
Expand All @@ -219,7 +216,8 @@ def read_datacite(string: nil, **options)
relatedItemIdentifier = nil
if rii
if rii["relatedItemIdentifierType"] == "DOI"
rid = validate_doi(rii["__content__"].to_s.downcase)
doi = rii["__content__"].to_s.downcase
rid = validate_doi(doi) || doi
else
rid = rii["__content__"]
end
Expand All @@ -236,7 +234,6 @@ def read_datacite(string: nil, **options)
number = ri["number"]
if number.is_a?(String)
number = number
numberType = nil
else
number = ri.dig("number", "__content__")
numberType = ri.dig("number", "numberType")
Expand Down
12 changes: 6 additions & 6 deletions lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -699,19 +699,19 @@ def normalize_cc_url(id)
end

def normalize_orcid(orcid)
orcid = validate_orcid(orcid)
return nil unless orcid.present?
validated = validate_orcid(orcid)
return orcid unless validated.present?

# turn ORCID ID into URL
"https://orcid.org/" + Addressable::URI.encode(orcid)
"https://orcid.org/" + Addressable::URI.encode(validated)
end

def normalize_ror(ror)
ror = validate_ror(ror)
return nil unless ror.present?
validated = validate_ror(ror)
return ror unless validated.present?

# turn ROR into URL
"https://ror.org/" + Addressable::URI.encode(ror)
"https://ror.org/" + Addressable::URI.encode(validated)
end

def normalize_ids(ids: nil, relation_type: nil)
Expand Down
2 changes: 1 addition & 1 deletion spec/datacite_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
it "insert" do
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| subject.insert_dates(xml) }.to_xml
response = Maremma.from_xml(xml)
expect(response.dig("dates", "date")).to eq([{"__content__"=>"2011-02-01T17:22:41Z", "dateType"=>"Available"}, {"__content__"=>"2011", "dateType"=>"Issued"}])
expect(response.dig("dates", "date")).to eq({"__content__"=>"2011-02-01T17:22:41Z", "dateType"=>"Available"})
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/doi_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@
expect(response).to eq("https://doi.org/10.13039/501100001711")
end

it "non-funder doi" do
it "non-funder doi returns doi unaltered" do
doi = "10.5061/dryad.8515"
response = subject.validate_funder_doi(doi)
expect(response).to be_nil
expect(response).to eq("10.5061/dryad.8515")
end

it { expect(subject.validate_funder_doi("10.13039/100000050")).to eq "https://doi.org/10.13039/100000050" }
Expand All @@ -282,8 +282,8 @@
it { expect(subject.validate_funder_doi('doi:10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
it { expect(subject.validate_funder_doi('10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
it { expect(subject.validate_funder_doi('501100001711')).to eq "https://doi.org/10.13039/501100001711" }
it { expect(subject.validate_funder_doi("https://doi.org/10.13039/5monkeymonkey")).to be_nil }
it { expect(subject.validate_funder_doi('10.13039/5monkeymonkey')).to be_nil }
it { expect(subject.validate_funder_doi("https://doi.org/10.13039/5monkeymonkey")).to eq("https://doi.org/10.13039/5monkeymonkey") }
it { expect(subject.validate_funder_doi("10.13039/5monkeymonkey")).to eq("10.13039/5monkeymonkey") }
end

context "validate prefix" do
Expand Down
Loading
Loading