bibtex-ruby 4.4.7 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +23 -24
- data/History.txt +4 -0
- data/Rakefile +23 -25
- data/bibtex-ruby.gemspec +1 -1
- data/examples/bib2html.rb +5 -6
- data/examples/bib2yaml.rb +2 -2
- data/features/step_definitions/bibtex_steps.rb +3 -6
- data/features/step_definitions/name_steps.rb +1 -2
- data/lib/bibtex.rb +11 -13
- data/lib/bibtex/bibliography.rb +45 -58
- data/lib/bibtex/compatibility.rb +3 -5
- data/lib/bibtex/elements.rb +49 -42
- data/lib/bibtex/entry.rb +80 -84
- data/lib/bibtex/entry/citeproc_converter.rb +47 -52
- data/lib/bibtex/entry/rdf_converter.rb +97 -63
- data/lib/bibtex/error.rb +10 -11
- data/lib/bibtex/extensions.rb +2 -5
- data/lib/bibtex/filters.rb +4 -9
- data/lib/bibtex/filters/latex.rb +0 -2
- data/lib/bibtex/filters/linebreaks.rb +0 -2
- data/lib/bibtex/lexer.rb +81 -81
- data/lib/bibtex/names.rb +24 -28
- data/lib/bibtex/replaceable.rb +15 -17
- data/lib/bibtex/utilities.rb +5 -10
- data/lib/bibtex/value.rb +28 -34
- data/lib/bibtex/version.rb +6 -6
- data/test/benchmark.rb +20 -22
- data/test/bibtex/entry/test_rdf_converter.rb +3 -5
- data/test/bibtex/test_bibliography.rb +22 -35
- data/test/bibtex/test_elements.rb +7 -15
- data/test/bibtex/test_entry.rb +78 -87
- data/test/bibtex/test_filters.rb +8 -7
- data/test/bibtex/test_lexer.rb +10 -13
- data/test/bibtex/test_name_parser.rb +6 -9
- data/test/bibtex/test_names.rb +50 -55
- data/test/bibtex/test_parser.rb +30 -34
- data/test/bibtex/test_string.rb +8 -9
- data/test/bibtex/test_utilities.rb +6 -9
- data/test/bibtex/test_value.rb +41 -43
- data/test/helper.rb +3 -6
- data/test/macruby.rb +12 -13
- data/test/profile.rb +16 -16
- data/test/test_bibtex.rb +10 -15
- data/test/test_export.rb +5 -13
- metadata +4 -4
@@ -1,28 +1,28 @@
|
|
1
1
|
class BibTeX::Entry::CiteProcConverter
|
2
|
-
CSL_FILTER = Hash.new { |
|
3
|
-
date
|
4
|
-
isbn
|
5
|
-
booktitle
|
6
|
-
journal
|
2
|
+
CSL_FILTER = Hash.new { |_h, k| k }.merge(Hash[*%w[
|
3
|
+
date issued
|
4
|
+
isbn ISBN
|
5
|
+
booktitle container-title
|
6
|
+
journal container-title
|
7
7
|
journaltitle container-title
|
8
|
-
series
|
9
|
-
address
|
10
|
-
pages
|
11
|
-
number
|
12
|
-
url
|
13
|
-
doi
|
14
|
-
pmid
|
15
|
-
pmcid
|
16
|
-
year
|
17
|
-
type
|
18
|
-
school
|
19
|
-
institution
|
8
|
+
series collection-title
|
9
|
+
address publisher-place
|
10
|
+
pages page
|
11
|
+
number issue
|
12
|
+
url URL
|
13
|
+
doi DOI
|
14
|
+
pmid PMID
|
15
|
+
pmcid PMCID
|
16
|
+
year issued
|
17
|
+
type genre
|
18
|
+
school publisher
|
19
|
+
institution publisher
|
20
20
|
organization publisher
|
21
21
|
howpublished publisher
|
22
|
-
type
|
23
|
-
|
22
|
+
type genre
|
23
|
+
].map(&:intern)]).freeze
|
24
24
|
|
25
|
-
CSL_FIELDS = %w
|
25
|
+
CSL_FIELDS = %w[
|
26
26
|
abstract annote archive archive_location archive-place
|
27
27
|
authority call-number chapter-number citation-label citation-number
|
28
28
|
collection-title container-title DOI edition event event-place
|
@@ -33,22 +33,22 @@ class BibTeX::Entry::CiteProcConverter
|
|
33
33
|
year-suffix accessed container event-date issued original-date
|
34
34
|
author editor translator recipient interviewer publisher composer
|
35
35
|
original-publisher original-author container-author collection-editor
|
36
|
-
|
37
|
-
|
38
|
-
CSL_TYPES = Hash.new { |
|
39
|
-
booklet
|
40
|
-
conference
|
41
|
-
inbook
|
42
|
-
incollection
|
43
|
-
inproceedings
|
44
|
-
manual
|
45
|
-
mastersthesis
|
46
|
-
phdthesis
|
47
|
-
proceedings
|
48
|
-
techreport
|
49
|
-
unpublished
|
50
|
-
article
|
51
|
-
|
36
|
+
].map(&:intern).freeze
|
37
|
+
|
38
|
+
CSL_TYPES = Hash.new { |_h, k| k }.merge(Hash[*%w[
|
39
|
+
booklet pamphlet
|
40
|
+
conference paper-conference
|
41
|
+
inbook chapter
|
42
|
+
incollection chapter
|
43
|
+
inproceedings paper-conference
|
44
|
+
manual book
|
45
|
+
mastersthesis thesis
|
46
|
+
phdthesis thesis
|
47
|
+
proceedings book
|
48
|
+
techreport report
|
49
|
+
unpublished manuscript
|
50
|
+
article article-journal
|
51
|
+
].map(&:intern)]).freeze
|
52
52
|
|
53
53
|
def self.convert(bibtex, options = {})
|
54
54
|
new(bibtex, options).convert!
|
@@ -71,40 +71,38 @@ class BibTeX::Entry::CiteProcConverter
|
|
71
71
|
convert key, bibtex.parent.provide(key)
|
72
72
|
end
|
73
73
|
|
74
|
-
methods = self.class.instance_methods(false) - [
|
74
|
+
methods = self.class.instance_methods(false) - %i[convert! hash]
|
75
75
|
methods.each { |m| send(m) }
|
76
76
|
|
77
77
|
hash
|
78
78
|
end
|
79
79
|
|
80
80
|
def conferences
|
81
|
-
return unless [
|
81
|
+
return unless %i[conference proceedings inproceedings].include?(bibtex.type)
|
82
82
|
|
83
83
|
if bibtex.field?(:organization) && bibtex.field?(:publisher)
|
84
84
|
hash['authority'] = bibtex[:organization]
|
85
85
|
hash['publisher'] = bibtex[:publisher]
|
86
86
|
end
|
87
87
|
|
88
|
-
if bibtex.field? :address
|
89
|
-
hash['event-place'] = bibtex[:address]
|
90
|
-
end
|
88
|
+
hash['event-place'] = bibtex[:address] if bibtex.field? :address
|
91
89
|
end
|
92
90
|
|
93
91
|
def techreport
|
94
|
-
return unless [
|
92
|
+
return unless %i[techreport report].include?(bibtex.type)
|
93
|
+
|
95
94
|
hash['number'] = bibtex[:number].to_s if bibtex.field? :number
|
96
95
|
end
|
97
96
|
|
98
97
|
def date
|
99
|
-
|
100
|
-
when bibtex.field?(:date)
|
98
|
+
if bibtex.field?(:date)
|
101
99
|
hash['issued'] = {
|
102
|
-
'date-parts' => bibtex.date.to_s.split('/').map
|
100
|
+
'date-parts' => bibtex.date.to_s.split('/').map do |part|
|
103
101
|
part.split('-').map(&:to_i)
|
104
|
-
|
102
|
+
end
|
105
103
|
}
|
106
104
|
|
107
|
-
|
105
|
+
elsif bibtex.field?(:year)
|
108
106
|
case bibtex[:year].to_s
|
109
107
|
when /^\d+$/
|
110
108
|
parts = [bibtex[:year].to_s]
|
@@ -113,9 +111,7 @@ class BibTeX::Entry::CiteProcConverter
|
|
113
111
|
parts.push BibTeX::Entry::MONTHS.find_index(bibtex[:month].to_s.intern)
|
114
112
|
parts[1] = parts[1] + 1 unless parts[1].nil?
|
115
113
|
|
116
|
-
if bibtex.field?(:day)
|
117
|
-
parts.push bibtex[:day]
|
118
|
-
end
|
114
|
+
parts.push bibtex[:day] if bibtex.field?(:day)
|
119
115
|
end
|
120
116
|
|
121
117
|
hash['issued'] = { 'date-parts' => [parts.compact.map(&:to_i)] }
|
@@ -123,8 +119,6 @@ class BibTeX::Entry::CiteProcConverter
|
|
123
119
|
hash['issued'] = { 'literal' => bibtex[:year].to_s }
|
124
120
|
end
|
125
121
|
|
126
|
-
else
|
127
|
-
# no date present
|
128
122
|
end
|
129
123
|
end
|
130
124
|
|
@@ -136,6 +130,7 @@ class BibTeX::Entry::CiteProcConverter
|
|
136
130
|
hash['type'] = CSL_TYPES[bibtex.type].to_s
|
137
131
|
|
138
132
|
return if hash.key?('genre')
|
133
|
+
|
139
134
|
case bibtex.type
|
140
135
|
when :mastersthesis
|
141
136
|
hash['genre'] = "Master's thesis"
|
@@ -7,35 +7,35 @@ rescue LoadError
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class BibTeX::Entry::RDFConverter
|
10
|
-
DEFAULT_REMOVE_FROM_FALLBACK = %w
|
10
|
+
DEFAULT_REMOVE_FROM_FALLBACK = %w[
|
11
11
|
bdsk-file-1
|
12
12
|
bdsk-file-2
|
13
13
|
bdsk-file-3
|
14
14
|
bdsk-file-4
|
15
|
-
|
16
|
-
|
17
|
-
BIBO_TYPES = Hash[*%w
|
18
|
-
article
|
19
|
-
book
|
20
|
-
booklet
|
21
|
-
collection
|
22
|
-
conference
|
23
|
-
inbook
|
24
|
-
incollection
|
25
|
-
inproceedings
|
26
|
-
journal
|
27
|
-
manual
|
28
|
-
mastersthesis
|
29
|
-
online
|
30
|
-
patent
|
31
|
-
periodical
|
32
|
-
phdthesis
|
33
|
-
proceedings
|
34
|
-
standard
|
35
|
-
techreport
|
36
|
-
thesis
|
37
|
-
unpublished
|
38
|
-
|
15
|
+
].map(&:intern).freeze
|
16
|
+
|
17
|
+
BIBO_TYPES = Hash[*%w[
|
18
|
+
article Article
|
19
|
+
book Book
|
20
|
+
booklet Book
|
21
|
+
collection Collection
|
22
|
+
conference AcademicArticle
|
23
|
+
inbook BookSection
|
24
|
+
incollection BookSection
|
25
|
+
inproceedings AcademicArticle
|
26
|
+
journal Journal
|
27
|
+
manual Manual
|
28
|
+
mastersthesis Thesis
|
29
|
+
online Website
|
30
|
+
patent Patent
|
31
|
+
periodical Periodical
|
32
|
+
phdthesis Thesis
|
33
|
+
proceedings Proceedings
|
34
|
+
standard Standard
|
35
|
+
techreport Report
|
36
|
+
thesis Thesis
|
37
|
+
unpublished Manuscript
|
38
|
+
].map(&:intern)].freeze
|
39
39
|
|
40
40
|
# converts a BibTeX entry to RDF
|
41
41
|
# @return [RDF::Graph] the RDF graph of this entry
|
@@ -66,6 +66,7 @@ class BibTeX::Entry::RDFConverter
|
|
66
66
|
|
67
67
|
def abstract
|
68
68
|
return unless bibtex.field?(:abstract)
|
69
|
+
|
69
70
|
remove_from_fallback(:abstract)
|
70
71
|
|
71
72
|
graph << [entry, RDF::Vocab::DC.abstract, bibtex[:abstract].to_s]
|
@@ -74,6 +75,7 @@ class BibTeX::Entry::RDFConverter
|
|
74
75
|
|
75
76
|
def annote
|
76
77
|
return unless bibtex.field?(:annote)
|
78
|
+
|
77
79
|
remove_from_fallback(:annote)
|
78
80
|
|
79
81
|
pub = RDF::Node.new
|
@@ -85,6 +87,7 @@ class BibTeX::Entry::RDFConverter
|
|
85
87
|
|
86
88
|
def author
|
87
89
|
return unless bibtex.field?(:author)
|
90
|
+
|
88
91
|
remove_from_fallback(:author)
|
89
92
|
|
90
93
|
seq = RDF::Node.new
|
@@ -102,24 +105,25 @@ class BibTeX::Entry::RDFConverter
|
|
102
105
|
|
103
106
|
def bdsk_url
|
104
107
|
count = 1
|
105
|
-
while bibtex.field?("bdsk-url-#{count}".to_sym)
|
108
|
+
while bibtex.field?("bdsk-url-#{count}".to_sym)
|
106
109
|
field = "bdsk-url-#{count}".to_sym
|
107
110
|
remove_from_fallback(field)
|
108
111
|
graph << [entry, RDF::Vocab::DC.URI, bibtex[field].to_s]
|
109
112
|
graph << [entry, bibo[:uri], bibtex[field].to_s]
|
110
|
-
count
|
113
|
+
count += 1
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
117
|
def booktitle
|
115
118
|
return unless bibtex.field?(:booktitle)
|
119
|
+
|
116
120
|
remove_from_fallback(:booktitle)
|
117
121
|
return if bibtex.has_parent? &&
|
118
|
-
|
122
|
+
bibtex.parent[:title] == bibtex[:booktitle]
|
119
123
|
return if bibtex.has_parent? &&
|
120
|
-
|
124
|
+
bibtex.parent[:booktitle] == bibtex[:booktitle]
|
121
125
|
return if bibtex.has_parent? &&
|
122
|
-
|
126
|
+
bibtex.parent[:isbn] == bibtex[:isbn]
|
123
127
|
return if bibtex[:title] == bibtex[:booktitle]
|
124
128
|
|
125
129
|
series = RDF::Node.new
|
@@ -131,6 +135,7 @@ class BibTeX::Entry::RDFConverter
|
|
131
135
|
|
132
136
|
def chapter
|
133
137
|
return unless bibtex.field?(:chapter)
|
138
|
+
|
134
139
|
remove_from_fallback(:chapter)
|
135
140
|
|
136
141
|
graph << [entry, bibo[:chapter], bibtex[:chapter].to_s]
|
@@ -148,6 +153,7 @@ class BibTeX::Entry::RDFConverter
|
|
148
153
|
|
149
154
|
def copyright
|
150
155
|
return unless bibtex.field?(:copyright)
|
156
|
+
|
151
157
|
remove_from_fallback(:copyright)
|
152
158
|
|
153
159
|
graph << [entry, RDF::Vocab::DC.rightsHolder, bibtex[:copyright].to_s]
|
@@ -155,6 +161,7 @@ class BibTeX::Entry::RDFConverter
|
|
155
161
|
|
156
162
|
def date_added
|
157
163
|
return unless bibtex.field?(:'date-added')
|
164
|
+
|
158
165
|
remove_from_fallback(:'date-added')
|
159
166
|
|
160
167
|
graph << [entry, RDF::Vocab::DC.created, bibtex[:'date-added'].to_s]
|
@@ -162,6 +169,7 @@ class BibTeX::Entry::RDFConverter
|
|
162
169
|
|
163
170
|
def date_modified
|
164
171
|
return unless bibtex.field?(:'date-modified')
|
172
|
+
|
165
173
|
remove_from_fallback(:'date-modified')
|
166
174
|
|
167
175
|
graph << [entry, RDF::Vocab::DC.modified, bibtex[:'date-modified'].to_s]
|
@@ -169,14 +177,16 @@ class BibTeX::Entry::RDFConverter
|
|
169
177
|
|
170
178
|
def doi
|
171
179
|
return unless bibtex.field?(:doi)
|
180
|
+
|
172
181
|
remove_from_fallback(:doi)
|
173
182
|
|
174
183
|
graph << [entry, bibo[:doi], bibtex[:doi].to_s]
|
175
|
-
graph << [entry, RDF::Vocab::DC.identifier, "doi:#{bibtex[:doi]
|
184
|
+
graph << [entry, RDF::Vocab::DC.identifier, "doi:#{bibtex[:doi]}"]
|
176
185
|
end
|
177
186
|
|
178
187
|
def edition
|
179
188
|
return unless bibtex.field?(:edition)
|
189
|
+
|
180
190
|
remove_from_fallback(:edition)
|
181
191
|
|
182
192
|
graph << [entry, bibo[:edition], bibtex[:edition].to_s]
|
@@ -184,6 +194,7 @@ class BibTeX::Entry::RDFConverter
|
|
184
194
|
|
185
195
|
def editor
|
186
196
|
return unless bibtex.field?(:editor)
|
197
|
+
|
187
198
|
remove_from_fallback(:editor)
|
188
199
|
|
189
200
|
seq = RDF::Node.new
|
@@ -205,7 +216,8 @@ class BibTeX::Entry::RDFConverter
|
|
205
216
|
|
206
217
|
def howpublished
|
207
218
|
return unless bibtex.field?(:howpublished)
|
208
|
-
return unless bibtex[:howpublished] =~ /^#{URI.
|
219
|
+
return unless bibtex[:howpublished] =~ /^#{URI::DEFAULT_PARSER.make_regexp}$/
|
220
|
+
|
209
221
|
remove_from_fallback(:howpublished)
|
210
222
|
|
211
223
|
graph << [entry, RDF::Vocab::DC.URI, bibtex[:howpublished].to_s]
|
@@ -214,6 +226,7 @@ class BibTeX::Entry::RDFConverter
|
|
214
226
|
|
215
227
|
def institution
|
216
228
|
return unless bibtex.field?(:institution)
|
229
|
+
|
217
230
|
remove_from_fallback(:institution)
|
218
231
|
|
219
232
|
org = agent(bibtex[:institution].to_s) { create_agent(bibtex[:institution].to_s, :Organization) }
|
@@ -223,39 +236,42 @@ class BibTeX::Entry::RDFConverter
|
|
223
236
|
|
224
237
|
def isbn
|
225
238
|
return unless bibtex.field?(:isbn)
|
239
|
+
|
226
240
|
remove_from_fallback(:isbn)
|
227
241
|
|
228
242
|
graph << [entry, bibo[:isbn], bibtex[:isbn].to_s]
|
229
243
|
|
230
|
-
if bibtex.contained?
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
244
|
+
graph << if bibtex.contained?
|
245
|
+
[entry, RDF::Vocab::DC.isPartOf, "urn:isbn:#{bibtex[:isbn]}"]
|
246
|
+
else
|
247
|
+
[entry, RDF::Vocab::DC.identifier, "urn:isbn:#{bibtex[:isbn]}"]
|
248
|
+
end
|
235
249
|
end
|
236
250
|
|
237
251
|
def issn
|
238
252
|
return unless bibtex.field?(:issn)
|
253
|
+
|
239
254
|
remove_from_fallback(:issn)
|
240
255
|
|
241
256
|
graph << [entry, bibo[:issn], bibtex[:issn].to_s]
|
242
|
-
if bibtex.contained?
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
257
|
+
graph << if bibtex.contained?
|
258
|
+
[entry, RDF::Vocab::DC.isPartOf, "urn:issn:#{bibtex[:issn]}"]
|
259
|
+
else
|
260
|
+
[entry, RDF::Vocab::DC.identifier, "urn:issn:#{bibtex[:issn]}"]
|
261
|
+
end
|
247
262
|
end
|
248
263
|
|
249
264
|
def journal_dc_source
|
250
265
|
return unless bibtex.field?(:journal)
|
266
|
+
|
251
267
|
remove_from_fallback(:journal)
|
252
268
|
|
253
269
|
source = []
|
254
270
|
source << bibtex[:journal].to_s
|
255
|
-
source << "Vol. #{bibtex[:volume]
|
256
|
-
source << "No. #{bibtex[:number]
|
271
|
+
source << "Vol. #{bibtex[:volume]}" if bibtex.field?(:volume)
|
272
|
+
source << "No. #{bibtex[:number]}" if bibtex.field?(:number)
|
257
273
|
pagination = bibtex[:pagination] || 'pp.'
|
258
|
-
source << "#{pagination
|
274
|
+
source << "#{pagination} #{bibtex[:pages]}" if bibtex.field?(:pages)
|
259
275
|
graph << [entry, RDF::Vocab::DC.source, source.join(', ')]
|
260
276
|
end
|
261
277
|
|
@@ -277,6 +293,7 @@ class BibTeX::Entry::RDFConverter
|
|
277
293
|
|
278
294
|
def keywords
|
279
295
|
return unless bibtex.field?(:keywords)
|
296
|
+
|
280
297
|
remove_from_fallback(:keywords)
|
281
298
|
|
282
299
|
bibtex[:keywords].to_s.split(/\s*[,;]\s*/).each do |keyword|
|
@@ -286,6 +303,7 @@ class BibTeX::Entry::RDFConverter
|
|
286
303
|
|
287
304
|
def language
|
288
305
|
return unless bibtex.field?(:language)
|
306
|
+
|
289
307
|
remove_from_fallback(:language)
|
290
308
|
|
291
309
|
bibtex[:language] = 'german' if bibtex[:language] == 'ngerman'
|
@@ -295,10 +313,11 @@ class BibTeX::Entry::RDFConverter
|
|
295
313
|
|
296
314
|
def location
|
297
315
|
return unless bibtex.field?(:location)
|
316
|
+
|
298
317
|
remove_from_fallback(:location)
|
299
318
|
|
300
319
|
graph << [entry, RDF::Vocab::DC.Location, bibtex[:location].to_s]
|
301
|
-
if [
|
320
|
+
if %i[proceedings inproceedings conference].include?(bibtex.type)
|
302
321
|
event = RDF::Vocabulary.new('http://purl.org/NET/c4dm/event.owl')
|
303
322
|
graph << [entry, event[:place], org]
|
304
323
|
end
|
@@ -306,6 +325,7 @@ class BibTeX::Entry::RDFConverter
|
|
306
325
|
|
307
326
|
def lccn
|
308
327
|
return unless bibtex.field?(:lccn)
|
328
|
+
|
309
329
|
remove_from_fallback(:lccn)
|
310
330
|
|
311
331
|
graph << [entry, bibo[:lccn], bibtex[:lccn].to_s]
|
@@ -313,6 +333,7 @@ class BibTeX::Entry::RDFConverter
|
|
313
333
|
|
314
334
|
def note
|
315
335
|
return unless bibtex.field?(:note)
|
336
|
+
|
316
337
|
remove_from_fallback(:note)
|
317
338
|
|
318
339
|
pub = RDF::Node.new
|
@@ -324,28 +345,31 @@ class BibTeX::Entry::RDFConverter
|
|
324
345
|
|
325
346
|
def number
|
326
347
|
return unless bibtex.field?(:number)
|
348
|
+
|
327
349
|
remove_from_fallback(:number)
|
328
350
|
|
329
|
-
case bibtex.type
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
351
|
+
graph << case bibtex.type
|
352
|
+
when :techreport || :manual || :unpublished
|
353
|
+
[entry, bibo[:number], bibtex[:number].to_s]
|
354
|
+
else
|
355
|
+
[entry, bibo[:issue], bibtex[:number].to_s]
|
356
|
+
end
|
335
357
|
end
|
336
358
|
|
337
359
|
def organization
|
338
360
|
return unless bibtex.field?(:organization)
|
361
|
+
|
339
362
|
remove_from_fallback(:organization)
|
340
363
|
|
341
364
|
org = agent(bibtex[:organization].to_s) { create_agent(bibtex[:organization].to_s, :Organization) }
|
342
365
|
|
343
366
|
graph << [entry, RDF::Vocab::DC.contributor, org]
|
344
|
-
graph << [entry, bibo[:organizer], org] if [
|
367
|
+
graph << [entry, bibo[:organizer], org] if %i[proceedings inproceedings conference].include?(bibtex.type)
|
345
368
|
end
|
346
369
|
|
347
370
|
def pages
|
348
371
|
return unless bibtex.field?(:pages)
|
372
|
+
|
349
373
|
remove_from_fallback(:pages)
|
350
374
|
|
351
375
|
if bibtex[:pages].to_s =~ /^\s*(\d+)\s*-+\s*(\d+)\s*$/
|
@@ -358,6 +382,7 @@ class BibTeX::Entry::RDFConverter
|
|
358
382
|
|
359
383
|
def pagetotal
|
360
384
|
return unless bibtex.field?(:pagetotal)
|
385
|
+
|
361
386
|
remove_from_fallback(:pagetotal)
|
362
387
|
|
363
388
|
graph << [entry, bibo[:numPages], bibtex[:pagetotal].to_s]
|
@@ -365,6 +390,7 @@ class BibTeX::Entry::RDFConverter
|
|
365
390
|
|
366
391
|
def parent
|
367
392
|
return unless bibtex.has_parent?
|
393
|
+
|
368
394
|
remove_from_fallback(:crossref)
|
369
395
|
|
370
396
|
parent_id = RDF::URI.new(bibtex.parent.identifier)
|
@@ -374,17 +400,17 @@ class BibTeX::Entry::RDFConverter
|
|
374
400
|
|
375
401
|
def publisher
|
376
402
|
return unless bibtex.field?(:publisher, :organization, :school, :institution)
|
403
|
+
|
377
404
|
remove_from_fallback(:publisher, :address)
|
378
405
|
|
379
406
|
org =
|
380
|
-
|
381
|
-
when bibtex.field?(:publisher)
|
407
|
+
if bibtex.field?(:publisher)
|
382
408
|
agent(bibtex[:publisher].to_s) { create_agent(bibtex[:publisher].to_s, :Organization) }
|
383
|
-
|
409
|
+
elsif bibtex.field?(:organization)
|
384
410
|
agent(bibtex[:organization].to_s) { create_agent(bibtex[:organization].to_s, :Organization) }
|
385
|
-
|
411
|
+
elsif bibtex.field?(:school)
|
386
412
|
agent(bibtex[:school].to_s) { create_agent(bibtex[:school].to_s, :Organization) }
|
387
|
-
|
413
|
+
elsif bibtex.field?(:institution)
|
388
414
|
agent(bibtex[:institution].to_s) { create_agent(bibtex[:institution].to_s, :Organization) }
|
389
415
|
end
|
390
416
|
|
@@ -399,6 +425,7 @@ class BibTeX::Entry::RDFConverter
|
|
399
425
|
|
400
426
|
def school
|
401
427
|
return unless bibtex.field?(:school)
|
428
|
+
|
402
429
|
remove_from_fallback(:school)
|
403
430
|
|
404
431
|
org = agent(bibtex[:school].to_s) { create_agent(bibtex[:school].to_s, :Organization) }
|
@@ -408,6 +435,7 @@ class BibTeX::Entry::RDFConverter
|
|
408
435
|
|
409
436
|
def series
|
410
437
|
return unless bibtex.field?(:series)
|
438
|
+
|
411
439
|
remove_from_fallback(:series)
|
412
440
|
return if bibtex.has_parent? && bibtex.parent[:title] == bibtex[:series]
|
413
441
|
return if bibtex.has_parent? && bibtex.parent[:series] == bibtex[:series]
|
@@ -450,17 +478,19 @@ class BibTeX::Entry::RDFConverter
|
|
450
478
|
|
451
479
|
def title
|
452
480
|
return unless bibtex.field?(:title)
|
481
|
+
|
453
482
|
remove_from_fallback(:title)
|
454
483
|
|
455
484
|
title = [bibtex[:title].to_s, bibtex[:subtitle].to_s]
|
456
|
-
|
457
|
-
|
485
|
+
.reject { |t| t.nil? || t.empty? }
|
486
|
+
.join(': ')
|
458
487
|
graph << [entry, RDF::Vocab::DC.title, title]
|
459
488
|
graph << [entry, bibo[:shortTitle], bibtex[:title].to_s] if bibtex.field?(:subtitle)
|
460
489
|
end
|
461
490
|
|
462
491
|
def translator
|
463
492
|
return unless bibtex.field?(:translator)
|
493
|
+
|
464
494
|
remove_from_fallback(:translator)
|
465
495
|
|
466
496
|
node = agent(bibtex[:translator].to_s) do
|
@@ -484,6 +514,7 @@ class BibTeX::Entry::RDFConverter
|
|
484
514
|
|
485
515
|
def url
|
486
516
|
return unless bibtex.field?(:url)
|
517
|
+
|
487
518
|
remove_from_fallback(:url)
|
488
519
|
|
489
520
|
graph << [entry, RDF::Vocab::DC.URI, bibtex[:url].to_s]
|
@@ -492,6 +523,7 @@ class BibTeX::Entry::RDFConverter
|
|
492
523
|
|
493
524
|
def volume
|
494
525
|
return unless bibtex.field?(:volume)
|
526
|
+
|
495
527
|
remove_from_fallback(:volume)
|
496
528
|
|
497
529
|
graph << [entry, bibo[:volume], bibtex[:volume].to_s]
|
@@ -499,6 +531,7 @@ class BibTeX::Entry::RDFConverter
|
|
499
531
|
|
500
532
|
def volumes
|
501
533
|
return unless bibtex.field?(:volumes)
|
534
|
+
|
502
535
|
remove_from_fallback(:volumes)
|
503
536
|
|
504
537
|
graph << [entry, bibo[:numVolumes], bibtex[:volumes].to_s]
|
@@ -506,6 +539,7 @@ class BibTeX::Entry::RDFConverter
|
|
506
539
|
|
507
540
|
def year
|
508
541
|
return unless bibtex.field?(:year)
|
542
|
+
|
509
543
|
remove_from_fallback(:year, :month)
|
510
544
|
|
511
545
|
year = bibtex[:year].to_s
|
@@ -536,7 +570,7 @@ class BibTeX::Entry::RDFConverter
|
|
536
570
|
@entry ||= RDF::URI.new(bibtex.identifier)
|
537
571
|
end
|
538
572
|
|
539
|
-
def agent(key = nil
|
573
|
+
def agent(key = nil)
|
540
574
|
if key.nil?
|
541
575
|
@agent
|
542
576
|
else
|
@@ -552,7 +586,7 @@ class BibTeX::Entry::RDFConverter
|
|
552
586
|
graph << [node, RDF::Vocab::FOAF.name, name.to_s]
|
553
587
|
|
554
588
|
if name.is_a?(BibTeX::Name)
|
555
|
-
[
|
589
|
+
%i[given family prefix suffix].each do |part|
|
556
590
|
value = name.send(part)
|
557
591
|
graph << [node, bibo["#{part}Name"], value.to_s] unless value.nil?
|
558
592
|
end
|
@@ -566,7 +600,7 @@ class BibTeX::Entry::RDFConverter
|
|
566
600
|
pattern [uri, nil, nil]
|
567
601
|
end
|
568
602
|
|
569
|
-
solutions.
|
603
|
+
!solutions.empty?
|
570
604
|
end
|
571
605
|
|
572
606
|
def fallback
|