bolognese 0.8.5 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -9
- data/README.md +15 -1
- data/lib/bolognese.rb +2 -0
- data/lib/bolognese/bibtex.rb +57 -1
- data/lib/bolognese/citeproc.rb +116 -0
- data/lib/bolognese/codemeta.rb +9 -1
- data/lib/bolognese/crossref.rb +20 -0
- data/lib/bolognese/datacite.rb +9 -1
- data/lib/bolognese/datacite_json.rb +9 -1
- data/lib/bolognese/datacite_utils.rb +1 -1
- data/lib/bolognese/metadata.rb +185 -1
- data/lib/bolognese/ris.rb +117 -0
- data/lib/bolognese/schema_org.rb +8 -0
- data/lib/bolognese/utils.rb +84 -17
- data/lib/bolognese/version.rb +1 -1
- data/resources/kernel-3/metadata.xsd +3 -3
- data/spec/bibtex_spec.rb +34 -0
- data/spec/citeproc_spec.rb +48 -0
- data/spec/codemeta_spec.rb +33 -3
- data/spec/crossref_spec.rb +80 -2
- data/spec/datacite_json_spec.rb +28 -12
- data/spec/datacite_spec.rb +72 -0
- data/spec/datacite_utils_spec.rb +1 -1
- data/spec/fixtures/citeproc.json +21 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_citeproc/maremma.yml +100 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_ris/BlogPosting.yml +100 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_ris/maremma.yml +100 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_citeproc/journal_article.yml +723 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_citeproc/with_pages.yml +370 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_ris/journal_article.yml +723 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_ris/with_pages.yml +370 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Citeproc_JSON.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/BlogPosting.yml +155 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/Dataset.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/BlogPosting.yml +155 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/Dataset.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/read/datacite.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write/datacite_to_bibtex.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_citeproc/BlogPosting.yml +653 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_ris/BlogPosting.yml +653 -0
- data/spec/schema_org_spec.rb +30 -0
- data/spec/utils_spec.rb +50 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7649099d379d9ce1513465ff2d9f012139542c2a
|
4
|
+
data.tar.gz: 476243eda3bd701c7677e36c7f49692c202347f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d1ec8c50ddb12e3fd155b020bc0c4b542740b57c553ccf05739f0832eecef7c0fadc099ce17be355c42b24cd7711146540fd53d37fb995d1e2caefc3b169a7
|
7
|
+
data.tar.gz: a1ac1c3e04f106c0161d6e6fcc2f7a21a7691ee77f0c1f4f66a309758d5a6f20e3555fe8b7a4384df564d518a1df17f62ad6085a3d09fde54bef8e31edb7517a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bolognese (0.8.
|
4
|
+
bolognese (0.8.7)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
bibtex-ruby (~> 4.1)
|
7
7
|
builder (~> 3.2, >= 3.2.2)
|
@@ -21,12 +21,13 @@ GEM
|
|
21
21
|
minitest (~> 5.1)
|
22
22
|
thread_safe (~> 0.3, >= 0.3.4)
|
23
23
|
tzinfo (~> 1.1)
|
24
|
-
addressable (2.
|
24
|
+
addressable (2.5.1)
|
25
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
25
26
|
bibtex-ruby (4.4.3)
|
26
27
|
latex-decode (~> 0.0)
|
27
28
|
builder (3.2.3)
|
28
|
-
codeclimate-test-reporter (1.0.
|
29
|
-
simplecov
|
29
|
+
codeclimate-test-reporter (1.0.8)
|
30
|
+
simplecov (<= 0.13)
|
30
31
|
colorize (0.8.1)
|
31
32
|
crack (0.4.3)
|
32
33
|
safe_yaml (~> 1.0.0)
|
@@ -64,8 +65,8 @@ GEM
|
|
64
65
|
namae (0.10.2)
|
65
66
|
nokogiri (1.6.8.1)
|
66
67
|
mini_portile2 (~> 2.1.0)
|
67
|
-
oj (2.18.
|
68
|
-
postrank-uri (1.0.
|
68
|
+
oj (2.18.5)
|
69
|
+
postrank-uri (1.0.22)
|
69
70
|
addressable (>= 2.3.0, < 2.6)
|
70
71
|
nokogiri (>= 1.6.1, < 1.8)
|
71
72
|
public_suffix (>= 2.0.0, < 2.1)
|
@@ -98,9 +99,9 @@ GEM
|
|
98
99
|
simplecov-html (0.10.0)
|
99
100
|
thor (0.19.4)
|
100
101
|
thread_safe (0.3.6)
|
101
|
-
tzinfo (1.2.
|
102
|
+
tzinfo (1.2.3)
|
102
103
|
thread_safe (~> 0.1)
|
103
|
-
unicode (0.4.4.
|
104
|
+
unicode (0.4.4.4)
|
104
105
|
vcr (3.0.3)
|
105
106
|
webmock (1.24.6)
|
106
107
|
addressable (>= 2.3.6)
|
@@ -123,4 +124,4 @@ DEPENDENCIES
|
|
123
124
|
webmock (~> 1.22, >= 1.22.3)
|
124
125
|
|
125
126
|
BUNDLED WITH
|
126
|
-
1.
|
127
|
+
1.14.6
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ Bolognese reads and/or writes these metadata formats:
|
|
39
39
|
</tr>
|
40
40
|
<tr>
|
41
41
|
<td><a href='https://api.datacite.org/'>DataCite JSON</a></td>
|
42
|
-
<td>
|
42
|
+
<td>datacite_json</td>
|
43
43
|
<td>application/vnd.datacite+json</td>
|
44
44
|
<td>Yes</td>
|
45
45
|
<td>Yes</td>
|
@@ -51,6 +51,13 @@ Bolognese reads and/or writes these metadata formats:
|
|
51
51
|
<td>Yes</td>
|
52
52
|
<td>Yes</td>
|
53
53
|
</tr>
|
54
|
+
<tr>
|
55
|
+
<td><a href='http://gsl-nagoya-u.net/http/pub/citeproc-doc.html'>Citeproc JSON</a></td>
|
56
|
+
<td>citeproc</td>
|
57
|
+
<td>application/vnd.citationstyles.csl+json</td>
|
58
|
+
<td>Yes</td>
|
59
|
+
<td>Yes</td>
|
60
|
+
</tr>
|
54
61
|
<tr>
|
55
62
|
<td><a href='https://codemeta.github.io/'>Codemeta</a></td>
|
56
63
|
<td>codemeta</td>
|
@@ -65,6 +72,13 @@ Bolognese reads and/or writes these metadata formats:
|
|
65
72
|
<td>Yes</td>
|
66
73
|
<td>Yes</td>
|
67
74
|
</tr>
|
75
|
+
<tr>
|
76
|
+
<td><a href='http://en.wikipedia.org/wiki/RIS_(file_format)'>RIS</a></td>
|
77
|
+
<td>ris</td>
|
78
|
+
<td>application/x-research-info-systems</td>
|
79
|
+
<td>Yes</td>
|
80
|
+
<td>Yes</td>
|
81
|
+
</tr>
|
68
82
|
</tbody>
|
69
83
|
</table>
|
70
84
|
|
data/lib/bolognese.rb
CHANGED
@@ -14,6 +14,8 @@ require "bolognese/datacite_json"
|
|
14
14
|
require "bolognese/schema_org"
|
15
15
|
require "bolognese/codemeta"
|
16
16
|
require "bolognese/bibtex"
|
17
|
+
require "bolognese/ris"
|
18
|
+
require "bolognese/citeproc"
|
17
19
|
require "bolognese/orcid"
|
18
20
|
require "bolognese/cli"
|
19
21
|
require "bolognese/string"
|
data/lib/bolognese/bibtex.rb
CHANGED
@@ -26,6 +26,44 @@ module Bolognese
|
|
26
26
|
"WebSite" => "misc"
|
27
27
|
}
|
28
28
|
|
29
|
+
BIB_TO_CP_TRANSLATIONS = {
|
30
|
+
"article" => "article-journal"
|
31
|
+
}
|
32
|
+
|
33
|
+
BIB_TO_RIS_TRANSLATIONS = {
|
34
|
+
"article" => "JOUR",
|
35
|
+
"book" => "BOOK",
|
36
|
+
"inbook" => "CHAP",
|
37
|
+
"inproceedings" => "CPAPER",
|
38
|
+
"manual" => nil,
|
39
|
+
"misc" => "GEN",
|
40
|
+
"phdthesis" => "THES",
|
41
|
+
"proceedings" => "CONF",
|
42
|
+
"techreport" => "RPRT",
|
43
|
+
"unpublished" => "UNPD"
|
44
|
+
}
|
45
|
+
|
46
|
+
SO_TO_RIS_TRANSLATIONS = {
|
47
|
+
"Article" => "",
|
48
|
+
"AudioObject" => "song",
|
49
|
+
"Blog" => nil,
|
50
|
+
"BlogPosting" => "BLOG",
|
51
|
+
"Collection" => nil,
|
52
|
+
"CreativeWork" => "GEN",
|
53
|
+
"DataCatalog" => "CTLG",
|
54
|
+
"Dataset" => "DATA",
|
55
|
+
"Event" => nil,
|
56
|
+
"ImageObject" => "FIGURE",
|
57
|
+
"Movie" => "MPCT",
|
58
|
+
"PublicationIssue" => nil,
|
59
|
+
"ScholarlyArticle" => "JOUR",
|
60
|
+
"Service" => nil,
|
61
|
+
"SoftwareSourceCode" => "COMP",
|
62
|
+
"VideoObject" => "VIDEO",
|
63
|
+
"WebPage" => "ELEC",
|
64
|
+
"WebSite" => nil
|
65
|
+
}
|
66
|
+
|
29
67
|
def initialize(string: nil)
|
30
68
|
@raw = string
|
31
69
|
end
|
@@ -46,6 +84,14 @@ module Bolognese
|
|
46
84
|
BIB_TO_SO_TRANSLATIONS[metadata.type.to_s] || "ScholarlyArticle"
|
47
85
|
end
|
48
86
|
|
87
|
+
def citeproc_type
|
88
|
+
BIB_TO_CP_TRANSLATIONS[metadata.type.to_s] || "misc"
|
89
|
+
end
|
90
|
+
|
91
|
+
def ris_type
|
92
|
+
BIB_TO_RIS_TRANSLATIONS[metadata.type.to_s] || "GEN"
|
93
|
+
end
|
94
|
+
|
49
95
|
def resource_type_general
|
50
96
|
SO_TO_DC_TRANSLATIONS[type]
|
51
97
|
end
|
@@ -75,9 +121,11 @@ module Bolognese
|
|
75
121
|
end
|
76
122
|
|
77
123
|
def container_title
|
78
|
-
metadata.journal.to_s.presence || metadata.
|
124
|
+
metadata.journal.to_s.presence || metadata.publisher.to_s
|
79
125
|
end
|
80
126
|
|
127
|
+
alias_method :journal, :container_title
|
128
|
+
|
81
129
|
def date_published
|
82
130
|
metadata.date.to_s.presence
|
83
131
|
end
|
@@ -86,6 +134,14 @@ module Bolognese
|
|
86
134
|
metadata.year.to_s.presence
|
87
135
|
end
|
88
136
|
|
137
|
+
def volume
|
138
|
+
metadata.volume.to_s.presence
|
139
|
+
end
|
140
|
+
|
141
|
+
def pagination
|
142
|
+
metadata.pages.to_s.presence
|
143
|
+
end
|
144
|
+
|
89
145
|
def is_part_of
|
90
146
|
if metadata.journal.present?
|
91
147
|
{ "type" => "Periodical",
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Bolognese
|
2
|
+
class Citeproc < Metadata
|
3
|
+
|
4
|
+
SO_TO_DC_RELATION_TYPES = {
|
5
|
+
"citation" => "References",
|
6
|
+
"sameAs" => "IsIdenticalTo",
|
7
|
+
"isPartOf" => "IsPartOf",
|
8
|
+
"hasPart" => "HasPart",
|
9
|
+
"isPredecessor" => "IsPreviousVersionOf",
|
10
|
+
"isSuccessor" => "IsNewVersionOf"
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(string: nil)
|
14
|
+
@raw = string
|
15
|
+
end
|
16
|
+
|
17
|
+
def metadata
|
18
|
+
@metadata ||= raw.present? ? Maremma.from_json(raw) : {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def exists?
|
22
|
+
metadata.present?
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid?
|
26
|
+
citeproc.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
def doi
|
30
|
+
metadata.fetch("DOI", nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
def id
|
34
|
+
normalize_id(metadata.fetch("id", nil))
|
35
|
+
end
|
36
|
+
|
37
|
+
def url
|
38
|
+
normalize_id(metadata.fetch("URL", nil))
|
39
|
+
end
|
40
|
+
|
41
|
+
def resource_type_general
|
42
|
+
SO_TO_DC_TRANSLATIONS[type]
|
43
|
+
end
|
44
|
+
|
45
|
+
def type
|
46
|
+
CP_TO_SO_TRANSLATIONS[citeproc_type] || "CreativeWork"
|
47
|
+
end
|
48
|
+
|
49
|
+
def citeproc_type
|
50
|
+
metadata.fetch("type", nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def additional_type
|
54
|
+
metadata.fetch("additionalType", nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
def bibtex_type
|
58
|
+
Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
|
59
|
+
end
|
60
|
+
|
61
|
+
def ris_type
|
62
|
+
CP_TO_RIS_TRANSLATIONS[type] || "GEN"
|
63
|
+
end
|
64
|
+
|
65
|
+
def title
|
66
|
+
metadata.fetch("title", nil)
|
67
|
+
end
|
68
|
+
|
69
|
+
def author
|
70
|
+
authors = from_citeproc(Array.wrap(metadata.fetch("author", nil)))
|
71
|
+
get_authors(authors)
|
72
|
+
end
|
73
|
+
|
74
|
+
def editor
|
75
|
+
editors = from_citeproc(Array.wrap(metadata.fetch("editor", nil)))
|
76
|
+
get_authors(editors)
|
77
|
+
end
|
78
|
+
|
79
|
+
def description
|
80
|
+
{ "text" => metadata.fetch("abstract", nil) }
|
81
|
+
end
|
82
|
+
|
83
|
+
def version
|
84
|
+
metadata.fetch("version", nil)
|
85
|
+
end
|
86
|
+
|
87
|
+
def keywords
|
88
|
+
metadata.fetch("categories", nil)
|
89
|
+
end
|
90
|
+
|
91
|
+
def date_published
|
92
|
+
issued = metadata.fetch("issued", nil)
|
93
|
+
get_date_from_date_parts(issued)
|
94
|
+
end
|
95
|
+
|
96
|
+
def publication_year
|
97
|
+
date_published[0..3].to_i.presence
|
98
|
+
end
|
99
|
+
|
100
|
+
def is_part_of
|
101
|
+
if container_title.present?
|
102
|
+
{ "type" => "Periodical",
|
103
|
+
"name" => container_title,
|
104
|
+
"issn" => metadata.fetch("ISSN", nil) }.compact
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def publisher
|
109
|
+
metadata.fetch("publisher", nil)
|
110
|
+
end
|
111
|
+
|
112
|
+
def container_title
|
113
|
+
metadata.fetch("container-title", nil)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/bolognese/codemeta.rb
CHANGED
@@ -48,6 +48,14 @@ module Bolognese
|
|
48
48
|
metadata.fetch("@type", nil)
|
49
49
|
end
|
50
50
|
|
51
|
+
def citeproc_type
|
52
|
+
"computer_program"
|
53
|
+
end
|
54
|
+
|
55
|
+
def ris_type
|
56
|
+
SO_TO_RIS_TRANSLATIONS[type] || "GEN"
|
57
|
+
end
|
58
|
+
|
51
59
|
def additional_type
|
52
60
|
metadata.fetch("additionalType", nil)
|
53
61
|
end
|
@@ -87,7 +95,7 @@ module Bolognese
|
|
87
95
|
end
|
88
96
|
|
89
97
|
def keywords
|
90
|
-
Array(metadata.fetch("tags", nil)).join(", ").presence
|
98
|
+
Array.wrap(metadata.fetch("tags", nil)).join(", ").presence
|
91
99
|
end
|
92
100
|
|
93
101
|
def date_created
|
data/lib/bolognese/crossref.rb
CHANGED
@@ -102,6 +102,10 @@ module Bolognese
|
|
102
102
|
metadata.dig("crossref", "journal", "journal_metadata").presence || {}
|
103
103
|
end
|
104
104
|
|
105
|
+
def journal_issue
|
106
|
+
metadata.dig("crossref", "journal", "journal_issue").presence || {}
|
107
|
+
end
|
108
|
+
|
105
109
|
def bibliographic_metadata
|
106
110
|
metadata.dig("crossref", "journal", "journal_article").presence ||
|
107
111
|
metadata.dig("crossref", "conference", "conference_paper").presence ||
|
@@ -121,6 +125,14 @@ module Bolognese
|
|
121
125
|
CR_TO_SO_TRANSLATIONS[additional_type] || "ScholarlyArticle"
|
122
126
|
end
|
123
127
|
|
128
|
+
def citeproc_type
|
129
|
+
CR_TO_CP_TRANSLATIONS[additional_type] || "article-journal"
|
130
|
+
end
|
131
|
+
|
132
|
+
def ris_type
|
133
|
+
CR_TO_RIS_TRANSLATIONS[additional_type] || "JOUR"
|
134
|
+
end
|
135
|
+
|
124
136
|
def additional_type
|
125
137
|
if metadata.dig("crossref", "journal").present?
|
126
138
|
metadata.dig("crossref", "journal").keys.last.camelize
|
@@ -204,6 +216,14 @@ module Bolognese
|
|
204
216
|
Time.parse(metadata.fetch("timestamp", "")).utc.iso8601
|
205
217
|
end
|
206
218
|
|
219
|
+
def volume
|
220
|
+
journal_issue.dig("journal_volume", "volume")
|
221
|
+
end
|
222
|
+
|
223
|
+
def issue
|
224
|
+
journal_issue.dig("issue")
|
225
|
+
end
|
226
|
+
|
207
227
|
def page_start
|
208
228
|
bibliographic_metadata.dig("pages", "first_page")
|
209
229
|
end
|
data/lib/bolognese/datacite.rb
CHANGED
@@ -66,6 +66,14 @@ module Bolognese
|
|
66
66
|
DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
67
67
|
end
|
68
68
|
|
69
|
+
def citeproc_type
|
70
|
+
DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || "other"
|
71
|
+
end
|
72
|
+
|
73
|
+
def ris_type
|
74
|
+
SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
75
|
+
end
|
76
|
+
|
69
77
|
def additional_type
|
70
78
|
metadata.fetch("resourceType", {}).fetch("__content__", nil) ||
|
71
79
|
metadata.fetch("resourceType", {}).fetch("resourceTypeGeneral", nil)
|
@@ -187,7 +195,7 @@ module Bolognese
|
|
187
195
|
end
|
188
196
|
|
189
197
|
def publication_year
|
190
|
-
metadata.fetch("publicationYear")
|
198
|
+
metadata.fetch("publicationYear", nil)
|
191
199
|
end
|
192
200
|
|
193
201
|
def language
|
@@ -35,6 +35,14 @@ module Bolognese
|
|
35
35
|
DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
36
36
|
end
|
37
37
|
|
38
|
+
def citeproc_type
|
39
|
+
DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || "other"
|
40
|
+
end
|
41
|
+
|
42
|
+
def ris_type
|
43
|
+
SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
44
|
+
end
|
45
|
+
|
38
46
|
def additional_type
|
39
47
|
metadata.fetch("resource-type", nil)
|
40
48
|
end
|
@@ -60,7 +68,7 @@ module Bolognese
|
|
60
68
|
end
|
61
69
|
|
62
70
|
def keywords
|
63
|
-
metadata.fetch("subject", nil)
|
71
|
+
Array.wrap(metadata.fetch("subject", nil)).join(", ").presence
|
64
72
|
end
|
65
73
|
|
66
74
|
def author
|
@@ -67,7 +67,7 @@ module Bolognese
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def insert_person(xml, person, type)
|
70
|
-
person_name = person["
|
70
|
+
person_name = person["familyName"].present? ? [person["familyName"], person["givenName"]].compact.join(", ") : person["name"]
|
71
71
|
|
72
72
|
xml.send(type + "Name", person_name)
|
73
73
|
xml.givenName(person["givenName"]) if person["givenName"].present?
|
data/lib/bolognese/metadata.rb
CHANGED
@@ -29,6 +29,51 @@ module Bolognese
|
|
29
29
|
"Other" => "CreativeWork"
|
30
30
|
}
|
31
31
|
|
32
|
+
DC_TO_CP_TRANSLATIONS = {
|
33
|
+
"Audiovisual" => "motion_picture",
|
34
|
+
"Collection" => nil,
|
35
|
+
"Dataset" => "dataset",
|
36
|
+
"Event" => nil,
|
37
|
+
"Image" => "graphic",
|
38
|
+
"InteractiveResource" => nil,
|
39
|
+
"Model" => nil,
|
40
|
+
"PhysicalObject" => nil,
|
41
|
+
"Service" => nil,
|
42
|
+
"Software" => "computer_program",
|
43
|
+
"Sound" => "song",
|
44
|
+
"Text" => "report",
|
45
|
+
"Workflow" => nil,
|
46
|
+
"Other" => nil
|
47
|
+
}
|
48
|
+
|
49
|
+
CR_TO_CP_TRANSLATIONS = {
|
50
|
+
"proceedings" => nil,
|
51
|
+
"reference-book" => nil,
|
52
|
+
"journal-issue" => nil,
|
53
|
+
"proceedings-article" => "paper-conference",
|
54
|
+
"other" => nil,
|
55
|
+
"dissertation" => "thesis",
|
56
|
+
"dataset" => "dataset",
|
57
|
+
"edited-book" => "book",
|
58
|
+
"journal-article" => "article-journal",
|
59
|
+
"journal" => nil,
|
60
|
+
"report" => "report",
|
61
|
+
"book-series" => nil,
|
62
|
+
"report-series" => nil,
|
63
|
+
"book-track" => nil,
|
64
|
+
"standard" => nil,
|
65
|
+
"book-section" => "chapter",
|
66
|
+
"book-part" => nil,
|
67
|
+
"book" => "book",
|
68
|
+
"book-chapter" => "chapter",
|
69
|
+
"standard-series" => nil,
|
70
|
+
"monograph" => "book",
|
71
|
+
"component" => nil,
|
72
|
+
"reference-entry" => "entry-dictionary",
|
73
|
+
"journal-volume" => nil,
|
74
|
+
"book-set" => nil
|
75
|
+
}
|
76
|
+
|
32
77
|
SO_TO_DC_TRANSLATIONS = {
|
33
78
|
"Article" => "Text",
|
34
79
|
"AudioObject" => "Sound",
|
@@ -50,6 +95,100 @@ module Bolognese
|
|
50
95
|
"WebSite" => "Text"
|
51
96
|
}
|
52
97
|
|
98
|
+
SO_TO_CP_TRANSLATIONS = {
|
99
|
+
"Article" => "",
|
100
|
+
"AudioObject" => "song",
|
101
|
+
"Blog" => "report",
|
102
|
+
"BlogPosting" => "post-weblog",
|
103
|
+
"Collection" => nil,
|
104
|
+
"CreativeWork" => nil,
|
105
|
+
"DataCatalog" => "dataset",
|
106
|
+
"Dataset" => "dataset",
|
107
|
+
"Event" => nil,
|
108
|
+
"ImageObject" => "graphic",
|
109
|
+
"Movie" => "motion_picture",
|
110
|
+
"PublicationIssue" => nil,
|
111
|
+
"ScholarlyArticle" => "article-journal",
|
112
|
+
"Service" => nil,
|
113
|
+
"SoftwareSourceCode" => "computer_program",
|
114
|
+
"VideoObject" => "broadcast",
|
115
|
+
"WebPage" => "webpage",
|
116
|
+
"WebSite" => "webpage"
|
117
|
+
}
|
118
|
+
|
119
|
+
CP_TO_SO_TRANSLATIONS = {
|
120
|
+
"song" => "AudioObject",
|
121
|
+
"post-weblog" => "BlogPosting",
|
122
|
+
"dataset" => "Dataset",
|
123
|
+
"graphic" => "ImageObject",
|
124
|
+
"motion_picture" => "Movie",
|
125
|
+
"article-journal" => "ScholarlyArticle",
|
126
|
+
"computer_program" => "SoftwareSourceCode",
|
127
|
+
"broadcast" => "VideoObject",
|
128
|
+
"webpage" => "WebPage"
|
129
|
+
}
|
130
|
+
|
131
|
+
SO_TO_RIS_TRANSLATIONS = {
|
132
|
+
"Article" => nil,
|
133
|
+
"AudioObject" => nil,
|
134
|
+
"Blog" => nil,
|
135
|
+
"BlogPosting" => "BLOG",
|
136
|
+
"Collection" => nil,
|
137
|
+
"CreativeWork" => "GEN",
|
138
|
+
"DataCatalog" => "CTLG",
|
139
|
+
"Dataset" => "DATA",
|
140
|
+
"Event" => nil,
|
141
|
+
"ImageObject" => "FIGURE",
|
142
|
+
"Movie" => "MPCT",
|
143
|
+
"PublicationIssue" => nil,
|
144
|
+
"ScholarlyArticle" => "JOUR",
|
145
|
+
"Service" => nil,
|
146
|
+
"SoftwareSourceCode" => "COMP",
|
147
|
+
"VideoObject" => "VIDEO",
|
148
|
+
"WebPage" => "ELEC",
|
149
|
+
"WebSite" => nil
|
150
|
+
}
|
151
|
+
|
152
|
+
CR_TO_RIS_TRANSLATIONS = {
|
153
|
+
"proceedings" => "CONF",
|
154
|
+
"reference-book" => "BOOK",
|
155
|
+
"journal-issue" => nil,
|
156
|
+
"proceedings-article" => "CPAPER",
|
157
|
+
"other" => "GEN",
|
158
|
+
"dissertation" => "THES",
|
159
|
+
"dataset" => "DATA",
|
160
|
+
"edited-book" => "BOOK",
|
161
|
+
"journal-article" => "JOUR",
|
162
|
+
"journal" => nil,
|
163
|
+
"report" => nil,
|
164
|
+
"book-series" => nil,
|
165
|
+
"report-series" => nil,
|
166
|
+
"book-track" => nil,
|
167
|
+
"standard" => nil,
|
168
|
+
"book-section" => "CHAP",
|
169
|
+
"book-part" => "CHAP",
|
170
|
+
"book" => "BOOK",
|
171
|
+
"book-chapter" => "CHAP",
|
172
|
+
"standard-series" => nil,
|
173
|
+
"monograph" => "BOOK",
|
174
|
+
"component" => nil,
|
175
|
+
"reference-entry" => "DICT",
|
176
|
+
"journal-volume" => nil,
|
177
|
+
"book-set" => nil
|
178
|
+
}
|
179
|
+
|
180
|
+
CP_TO_RIS_TRANSLATIONS = {
|
181
|
+
"post-weblog" => "BLOG",
|
182
|
+
"dataset" => "DATA",
|
183
|
+
"graphic" => "FIGURE",
|
184
|
+
"book" => "BOOK",
|
185
|
+
"motion_picture" => "MPCT",
|
186
|
+
"article-journal" => "JOUR",
|
187
|
+
"computer_program" => "COMP",
|
188
|
+
"broadcast" => "MPCT",
|
189
|
+
"webpage" => "ELEC"
|
190
|
+
}
|
191
|
+
|
53
192
|
attr_reader :id, :raw, :provider, :schema_version, :license, :citation,
|
54
193
|
:additional_type, :alternate_name, :url, :version, :keywords, :editor,
|
55
194
|
:page_start, :page_end, :date_modified, :language, :spatial_coverage,
|
@@ -62,7 +201,7 @@ module Bolognese
|
|
62
201
|
:is_referenced_by, :references, :is_documented_by, :documents,
|
63
202
|
:is_compiled_by, :compiles, :is_variant_form_of, :is_original_form_of,
|
64
203
|
:is_reviewed_by, :reviews, :is_derived_from, :is_source_of, :format,
|
65
|
-
:related_identifier, :reverse
|
204
|
+
:related_identifier, :reverse, :citeproc_type, :ris_type, :volume, :issue
|
66
205
|
|
67
206
|
def publication_year
|
68
207
|
date_published && date_published[0..3]
|
@@ -156,6 +295,30 @@ module Bolognese
|
|
156
295
|
JSON.pretty_generate hsh
|
157
296
|
end
|
158
297
|
|
298
|
+
def citeproc
|
299
|
+
hsh = {
|
300
|
+
"type" => citeproc_type,
|
301
|
+
"id" => id,
|
302
|
+
"categories" => keywords.present? ? keywords.split(", ") : nil,
|
303
|
+
"language" => language,
|
304
|
+
"author" => to_citeproc(author),
|
305
|
+
"editor" => to_citeproc(editor),
|
306
|
+
"issued" => get_date_parts(date_published),
|
307
|
+
"submitted" => get_date_parts(date_submitted),
|
308
|
+
"abstract" => description.is_a?(Hash) ? description.fetch("text", nil) : description,
|
309
|
+
"container-title" => journal,
|
310
|
+
"DOI" => doi,
|
311
|
+
"issue" => issue,
|
312
|
+
"page" => pagination,
|
313
|
+
"publisher" => publisher,
|
314
|
+
"title" => title,
|
315
|
+
"URL" => url,
|
316
|
+
"version" => version,
|
317
|
+
"volume" => volume
|
318
|
+
}.compact
|
319
|
+
JSON.pretty_generate hsh
|
320
|
+
end
|
321
|
+
|
159
322
|
def codemeta
|
160
323
|
hsh = {
|
161
324
|
"@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
|
@@ -193,5 +356,26 @@ module Bolognese
|
|
193
356
|
}.compact
|
194
357
|
BibTeX::Entry.new(bib).to_s
|
195
358
|
end
|
359
|
+
|
360
|
+
def ris
|
361
|
+
{
|
362
|
+
"TY" => ris_type,
|
363
|
+
"T1" => title,
|
364
|
+
"T2" => container_title,
|
365
|
+
"AU" => to_ris(author),
|
366
|
+
"DO" => doi,
|
367
|
+
"UR" => url,
|
368
|
+
"AB" => description.present? ? description["text"] : nil,
|
369
|
+
"KW" => keywords.to_s.split(", ").presence,
|
370
|
+
"PY" => publication_year,
|
371
|
+
"PB" => publisher,
|
372
|
+
"AN" => alternate_name.present? ? alternate_name["name"] : nil,
|
373
|
+
"LA" => language,
|
374
|
+
"VL" => volume,
|
375
|
+
"IS" => issue,
|
376
|
+
"SP" => pagination,
|
377
|
+
"ER" => ""
|
378
|
+
}.compact.map { |k, v| v.is_a?(Array) ? v.map { |vi| "#{k} - #{vi}" }.join("\r\n") : "#{k} - #{v}" }.join("\r\n")
|
379
|
+
end
|
196
380
|
end
|
197
381
|
end
|