marc2linkeddata 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/lib/marc2linkeddata.rb +16 -1
- data/lib/marc2linkeddata/loc.rb +2 -2
- data/lib/marc2linkeddata/parseMarcAuthority.rb +4 -1
- data/lib/marc2linkeddata/sparql.rb +0 -6
- data/lib/marc2linkeddata/sparql_pubmed.rb +48 -0
- data/lib/marc2linkeddata/viaf.rb +4 -4
- data/marc2linkeddata.gemspec +12 -3
- metadata +36 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54e31c819d0978629746c13c88690d5b2f1f392
|
4
|
+
data.tar.gz: 5325910c217a5e1bd3d45bb0a1f0bdb3b48fa11e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2565a8648875bc22f3b62ccd7cd1aad47ce843d388a93f6e4e363f7bab77644abbf56a1a70f73de9d6ac9aa9be3857578b62c87e5ebc2d4e50b157afaea7c7ae
|
7
|
+
data.tar.gz: a8ba98f07795a0c97f4bd00d9c431ea7a4dd15d39952f1cdbc56a4136d4b6e60f2bb0a6d05cb6f3affe5d5eecd03dc6752b4093dcb8b149f61d36583911af610
|
data/.travis.yml
ADDED
data/lib/marc2linkeddata.rb
CHANGED
@@ -52,7 +52,22 @@ module Marc2LinkedData
|
|
52
52
|
|
53
53
|
def self.http_head_request(url)
|
54
54
|
uri = URI.parse(url)
|
55
|
-
|
55
|
+
begin
|
56
|
+
if RUBY_VERSION =~ /^1\.9/
|
57
|
+
req = Net::HTTP::Head.new(uri.path)
|
58
|
+
else
|
59
|
+
req = Net::HTTP::Head.new(uri)
|
60
|
+
end
|
61
|
+
Net::HTTP.start(uri.host, uri.port) {|http| http.request req }
|
62
|
+
rescue
|
63
|
+
@configuration.logger.error "Net::HTTP::Head failed for #{uri}"
|
64
|
+
begin
|
65
|
+
Net::HTTP.get_response(uri)
|
66
|
+
rescue
|
67
|
+
@configuration.logger.error "Net::HTTP.get_response failed for #{uri}"
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
56
71
|
end
|
57
72
|
|
58
73
|
def self.write_prefixes(file)
|
data/lib/marc2linkeddata/loc.rb
CHANGED
@@ -450,7 +450,10 @@ module Marc2LinkedData
|
|
450
450
|
# Try to find LOC, VIAF, and ISNI IRIs in the MARC record
|
451
451
|
@loc = Loc.new get_iri4loc rescue nil
|
452
452
|
# Try to identify problems in getting an LOC IRI.
|
453
|
-
|
453
|
+
if @loc.nil?
|
454
|
+
binding.pry if @@config.debug
|
455
|
+
raise 'Failed to get authority at LOC'
|
456
|
+
end
|
454
457
|
# might require LOC to get ISNI.
|
455
458
|
@viaf = Viaf.new get_iri4viaf rescue nil
|
456
459
|
# might require VIAF to get ISNI.
|
@@ -37,12 +37,6 @@ module Marc2LinkedData
|
|
37
37
|
# end
|
38
38
|
|
39
39
|
|
40
|
-
# For reference, note that there is an allegrograph ruby gem, see
|
41
|
-
# https://github.com/emk/rdf-agraph
|
42
|
-
|
43
|
-
# For reference, note that there is a ruby gem for RDF on mongodb, see
|
44
|
-
# https://rubygems.org/gems/rdf-mongo
|
45
|
-
|
46
40
|
|
47
41
|
|
48
42
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Marc2LinkedData
|
4
|
+
|
5
|
+
class SparqlPubmed
|
6
|
+
|
7
|
+
attr_reader :sparql
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
# config = Marc2LinkedData.configuration
|
11
|
+
@sparql = SPARQL::Client.new('http://pubmed.bio2rdf.org/sparql')
|
12
|
+
end
|
13
|
+
|
14
|
+
# http://bio2rdf.org/pubmed_vocabulary:Author
|
15
|
+
# dcterms:identifier pubmed_resource:author:a71b95197f579ff09cc6d9a7d4856535
|
16
|
+
# http://bio2rdf.org/pubmed_vocabulary:fore_name Alison
|
17
|
+
# http://bio2rdf.org/pubmed_vocabulary:initials A
|
18
|
+
# http://bio2rdf.org/pubmed_vocabulary:last_name Callahan
|
19
|
+
|
20
|
+
# e.g. run this SPARQL at http://pubmed.bio2rdf.org/sparql
|
21
|
+
# SELECT DISTINCT ?author $fn $ln WHERE {
|
22
|
+
# ?author a <http://bio2rdf.org/pubmed_vocabulary:Author> .
|
23
|
+
# ?author <http://bio2rdf.org/pubmed_vocabulary:fore_name> $fn .
|
24
|
+
# ?author <http://bio2rdf.org/pubmed_vocabulary:last_name> $ln .
|
25
|
+
# }
|
26
|
+
# LIMIT 100
|
27
|
+
|
28
|
+
# Note, might have to use first name initial for matching.
|
29
|
+
|
30
|
+
def find_author(last_name, first_name=nil, middle_initial=nil)
|
31
|
+
q = 'SELECT DISTINCT ?author ?fn WHERE { '
|
32
|
+
q += '?author a <http://bio2rdf.org/pubmed_vocabulary:Author> . '
|
33
|
+
q += '?author <http://bio2rdf.org/pubmed_vocabulary:fore_name> ?fn . '
|
34
|
+
q += "?author <http://bio2rdf.org/pubmed_vocabulary:last_name> \"#{last_name}\"^^<http://www.w3.org/2001/XMLSchema#string> . "
|
35
|
+
q += '}'
|
36
|
+
result = @sparql.query(q)
|
37
|
+
result.each_solution do |s|
|
38
|
+
# match on first_name? or initials?
|
39
|
+
puts s.inspect
|
40
|
+
end
|
41
|
+
binding.pry
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
data/lib/marc2linkeddata/viaf.rb
CHANGED
@@ -7,19 +7,19 @@ module Marc2LinkedData
|
|
7
7
|
PREFIX = 'http://viaf.org/viaf/'
|
8
8
|
|
9
9
|
# def id
|
10
|
-
# return nil if iri.nil?
|
10
|
+
# return nil if @iri.nil?
|
11
11
|
# iri.path.gsub('viaf/','').gsub('/','')
|
12
12
|
# end
|
13
13
|
|
14
14
|
def rdf
|
15
|
-
return nil if iri.nil?
|
15
|
+
return nil if @iri.nil?
|
16
16
|
return @rdf unless @rdf.nil?
|
17
|
-
uri4rdf = iri.to_s + '/rdf.xml'
|
17
|
+
uri4rdf = @iri.to_s + '/rdf.xml'
|
18
18
|
@rdf = get_rdf(uri4rdf)
|
19
19
|
end
|
20
20
|
|
21
21
|
def get_isni
|
22
|
-
return nil if iri.nil?
|
22
|
+
return nil if @iri.nil?
|
23
23
|
return nil unless rdf_valid?
|
24
24
|
return @isni_iri unless @isni_iri.nil?
|
25
25
|
# Try to get ISNI source for VIAF
|
data/marc2linkeddata.gemspec
CHANGED
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'marc2linkeddata'
|
7
|
-
s.version = '0.0.
|
7
|
+
s.version = '0.0.7'
|
8
8
|
s.licenses = ['Apache-2.0']
|
9
9
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
@@ -15,18 +15,27 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.homepage = 'https://github.com/darrenleeweber/marc2linkeddata'
|
16
16
|
|
17
17
|
s.required_rubygems_version = '>= 1.3.6'
|
18
|
-
s.required_ruby_version = '>= 2.1.0'
|
18
|
+
# s.required_ruby_version = '>= 2.1.0'
|
19
19
|
|
20
20
|
s.add_dependency 'addressable'
|
21
21
|
s.add_dependency 'linkeddata'
|
22
22
|
s.add_dependency 'marc'
|
23
|
-
s.add_dependency 'rdf-4store'
|
24
23
|
s.add_dependency 'ruby-progressbar'
|
24
|
+
|
25
|
+
# Use ENV for config
|
25
26
|
s.add_dependency 'dotenv'
|
26
27
|
|
28
|
+
# ruby gem for RDF on 4store, see https://github.com/emk/rdf-4store
|
29
|
+
s.add_dependency 'rdf-4store'
|
30
|
+
# ruby gem for RDF on allegrograph, see https://github.com/emk/rdf-agraph
|
31
|
+
s.add_dependency 'rdf-agraph'
|
32
|
+
# ruby gem for RDF on mongodb, see https://rubygems.org/gems/rdf-mongo
|
33
|
+
s.add_dependency 'rdf-mongo'
|
34
|
+
# cache simple RDF on redis
|
27
35
|
s.add_dependency 'hiredis'
|
28
36
|
s.add_dependency 'redis'
|
29
37
|
|
38
|
+
# Use pry for console and debug config
|
30
39
|
s.add_dependency 'pry'
|
31
40
|
s.add_dependency 'pry-doc'
|
32
41
|
s.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marc2linkeddata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Weber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-progressbar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rdf-4store
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +95,7 @@ dependencies:
|
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: rdf-agraph
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
@@ -81,7 +109,7 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: rdf-mongo
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
@@ -180,6 +208,7 @@ extra_rdoc_files: []
|
|
180
208
|
files:
|
181
209
|
- ".env_example"
|
182
210
|
- ".rspec"
|
211
|
+
- ".travis.yml"
|
183
212
|
- Gemfile
|
184
213
|
- LICENSE
|
185
214
|
- README.md
|
@@ -203,6 +232,7 @@ files:
|
|
203
232
|
- lib/marc2linkeddata/readMarcCatalog.rb
|
204
233
|
- lib/marc2linkeddata/resource.rb
|
205
234
|
- lib/marc2linkeddata/sparql.rb
|
235
|
+
- lib/marc2linkeddata/sparql_pubmed.rb
|
206
236
|
- lib/marc2linkeddata/viaf.rb
|
207
237
|
- marc2linkeddata.gemspec
|
208
238
|
- spec/marc2linkeddata/configuration_spec.rb
|
@@ -223,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
253
|
requirements:
|
224
254
|
- - ">="
|
225
255
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
256
|
+
version: '0'
|
227
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
258
|
requirements:
|
229
259
|
- - ">="
|
@@ -231,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
261
|
version: 1.3.6
|
232
262
|
requirements: []
|
233
263
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
264
|
+
rubygems_version: 2.4.5
|
235
265
|
signing_key:
|
236
266
|
specification_version: 4
|
237
267
|
summary: Convert Marc21 records to linked data, for use in SUL/DLSS projects
|