26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/bolognese/readers/citeproc_reader.rb', line 26
def read_citeproc(string: nil, **options)
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
meta = string.present? ? Maremma.from_json(string) : {}
citeproc_type = meta.fetch("type", nil)
type = CP_TO_SO_TRANSLATIONS[citeproc_type] || "CreativeWork"
doi = normalize_doi(meta.fetch("DOI", nil))
author = get_authors(from_citeproc(Array.wrap(meta.fetch("author", nil))))
editor = get_authors(from_citeproc(Array.wrap(meta.fetch("editor", nil))))
date_published = get_date_from_date_parts(meta.fetch("issued", nil))
container_title = meta.fetch("container-title", nil)
is_part_of = if container_title.present?
{ "type" => "Periodical",
"title" => container_title,
"issn" => meta.fetch("ISSN", nil) }.compact
else
nil
end
{ "id" => normalize_id(meta.fetch("id", nil)),
"type" => type,
"additional_type" => meta.fetch("additionalType", nil),
"citeproc_type" => citeproc_type,
"bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
"ris_type" => CP_TO_RIS_TRANSLATIONS[type] || "GEN",
"resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
"doi" => doi_from_url(doi),
"url" => normalize_id(meta.fetch("URL", nil)),
"title" => meta.fetch("title", nil),
"author" => author,
"container_title" => container_title,
"publisher" => meta.fetch("publisher", nil),
"is_part_of" => is_part_of,
"date_published" => date_published,
"volume" => meta.fetch("volume", nil),
"description" => meta.fetch("abstract", nil).present? ? { "text" => sanitize(meta.fetch("abstract")) } : nil,
"version" => meta.fetch("version", nil),
"keywords" => meta.fetch("categories", nil)
}
end
|