rdf-reasoner 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 651a1431487e77d50420f0c33506df9d756e7eab48790589bdfacdc404b88fea
4
- data.tar.gz: 66c536de0f20de0fe2f50be36e8a712d24efd4e1ea7674b4bff234d91a827272
3
+ metadata.gz: 911fc7c40f3afc055e166946ff41a65d061cd08aa8b028401f85357b61b62617
4
+ data.tar.gz: 9702cd3e837fcc9abba925f154a40257a6d49cd8b28db990c6bd57147324049e
5
5
  SHA512:
6
- metadata.gz: 551d92044542d411803d75619a6f0d38d5cae5ae4331f7b11109006518a5db6c1fe8f7589d343e915b2e8187997a20fb68917771ebf5eba9297d0cc721e76be3
7
- data.tar.gz: 47ee7417fdf42130820419558718332ad77748386cec3d8ef4513e5e711b299fd4bdabe5500a12eb1effdc55acb19ba5a9bce41e3e4ef63ec2510ace662c9a0b
6
+ metadata.gz: 827da1634fe249c21598824019f785d3efdbb8a94afad1dcf7d3c8852d87a41ec2a3ee59ced83d2705c33a480be719065caf0dc115104e290e0f28d44bec0088
7
+ data.tar.gz: 9d5010b729d25351bfec0efba6fd90c0789080a7a56fac8f829c3f56fc80fad712291acbd8c9a5eb728451c0c36077e8abe23ef7cd39e17d308934bcf9dcf5c2
data/README.md CHANGED
@@ -104,8 +104,8 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
104
104
 
105
105
  ## Dependencies
106
106
 
107
- * [Ruby](https://ruby-lang.org/) (>= 2.2.2)
108
- * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.0)
107
+ * [Ruby](https://ruby-lang.org/) (>= 2.4)
108
+ * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
109
109
 
110
110
  ## Mailing List
111
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.6.0
@@ -34,9 +34,9 @@ module RDF
34
34
  # @param [Hash{Symbol => Object}] options ({})
35
35
  # @option options [Array<RDF::Vocabulary::Term>] :types
36
36
  # Fully entailed types of resource, if not provided, they are queried
37
- def domain_compatible?(resource, queryable, options = {})
37
+ def domain_compatible?(resource, queryable, **options)
38
38
  %w(owl rdfs schema).map {|r| "domain_compatible_#{r}?".to_sym}.all? do |meth|
39
- !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
39
+ !self.respond_to?(meth) || self.send(meth, resource, queryable, **options)
40
40
  end
41
41
  end
42
42
 
@@ -50,9 +50,9 @@ module RDF
50
50
  # @param [Hash{Symbol => Object}] options ({})
51
51
  # @option options [Array<RDF::Vocabulary::Term>] :types
52
52
  # Fully entailed types of resource, if not provided, they are queried
53
- def range_compatible?(resource, queryable, options = {})
53
+ def range_compatible?(resource, queryable, **options)
54
54
  %w(owl rdfs schema).map {|r| "range_compatible_#{r}?".to_sym}.all? do |meth|
55
- !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
55
+ !self.respond_to?(meth) || self.send(meth, resource, queryable, **options)
56
56
  end
57
57
  end
58
58
  end
@@ -89,9 +89,9 @@ module RDF
89
89
  # @param [Hash{Symbol => Object}] options ({})
90
90
  # @option options [Array<RDF::Vocabulary::Term>] :types
91
91
  # Fully entailed types of resource, if not provided, they are queried
92
- def domain_compatible?(resource, queryable, options = {})
92
+ def domain_compatible?(resource, queryable, **options)
93
93
  %w(owl rdfs schema).map {|r| "domain_compatible_#{r}?".to_sym}.all? do |meth|
94
- !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
94
+ !self.respond_to?(meth) || self.send(meth, resource, queryable, **options)
95
95
  end
96
96
  end
97
97
 
@@ -105,9 +105,9 @@ module RDF
105
105
  # @param [Hash{Symbol => Object}] options ({})
106
106
  # @option options [Array<RDF::Vocabulary::Term>] :types
107
107
  # Fully entailed types of resource, if not provided, they are queried
108
- def range_compatible?(resource, queryable, options = {})
108
+ def range_compatible?(resource, queryable, **options)
109
109
  %w(owl rdfs schema).map {|r| "range_compatible_#{r}?".to_sym}.all? do |meth|
110
- !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
110
+ !self.respond_to?(meth) || self.send(meth, resource, queryable, **options)
111
111
  end
112
112
  end
113
113
  end
@@ -233,7 +233,7 @@ module RDF
233
233
  messages = {}
234
234
 
235
235
  # Check for defined classes in known vocabularies
236
- self.query(predicate: RDF.type) do |stmt|
236
+ self.query({predicate: RDF.type}) do |stmt|
237
237
  vocab = RDF::Vocabulary.find(stmt.object)
238
238
  term = (RDF::Vocabulary.find_term(stmt.object) rescue nil) if vocab
239
239
  pname = term ? term.pname : stmt.object.pname
@@ -275,7 +275,7 @@ module RDF
275
275
  end
276
276
 
277
277
  # See if type of the subject is in the domain of this predicate
278
- resource_types[stmt.subject] ||= self.query(subject: stmt.subject, predicate: RDF.type).
278
+ resource_types[stmt.subject] ||= self.query({subject: stmt.subject, predicate: RDF.type}).
279
279
  map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
280
280
  flatten.
281
281
  uniq.
@@ -290,7 +290,7 @@ module RDF
290
290
  end
291
291
 
292
292
  # Make sure that if ranges are defined, the object has an appropriate type
293
- resource_types[stmt.object] ||= self.query(subject: stmt.object, predicate: RDF.type).
293
+ resource_types[stmt.object] ||= self.query({subject: stmt.object, predicate: RDF.type}).
294
294
  map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
295
295
  flatten.
296
296
  uniq.
@@ -316,7 +316,7 @@ module RDF
316
316
  def show_resource(resource)
317
317
  if resource.node?
318
318
  resource.to_ntriples + '(' +
319
- self.query(subject: resource, predicate: RDF.type).
319
+ self.query({subject: resource, predicate: RDF.type}).
320
320
  map {|s| s.object.uri? ? s.object.pname : s.object.to_ntriples}
321
321
  .join(',') +
322
322
  ')'
@@ -50,7 +50,7 @@ module RDF::Reasoner
50
50
  if self.predicate == RDF.type
51
51
  if term = (RDF::Vocabulary.find_term(self.object) rescue nil)
52
52
  term._entail_equivalentClass do |t|
53
- statements << RDF::Statement(self.to_h.merge(object: t, inferred: true))
53
+ statements << RDF::Statement(**self.to_h.merge(object: t, inferred: true))
54
54
  end
55
55
  end
56
56
  end
@@ -89,7 +89,7 @@ module RDF::Reasoner
89
89
  statements = []
90
90
  if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
91
91
  term._entail_equivalentProperty do |t|
92
- statements << RDF::Statement(self.to_h.merge(predicate: t, inferred: true))
92
+ statements << RDF::Statement(**self.to_h.merge(predicate: t, inferred: true))
93
93
  end
94
94
  end
95
95
  statements.each {|s| yield s} if block_given?
@@ -74,7 +74,7 @@ module RDF::Reasoner
74
74
  if term = (RDF::Vocabulary.find_term(self.object) rescue nil)
75
75
  term._entail_subClassOf do |t|
76
76
  next if t.node? # Don't entail BNodes
77
- statements << RDF::Statement(self.to_h.merge(object: t, inferred: true))
77
+ statements << RDF::Statement(**self.to_h.merge(object: t, inferred: true))
78
78
  end
79
79
  end
80
80
  #$stderr.puts("subClassf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
@@ -143,7 +143,7 @@ module RDF::Reasoner
143
143
  statements = []
144
144
  if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
145
145
  term._entail_subPropertyOf do |t|
146
- statements << RDF::Statement(self.to_h.merge(predicate: t, inferred: true))
146
+ statements << RDF::Statement(**self.to_h.merge(predicate: t, inferred: true))
147
147
  end
148
148
  #$stderr.puts("subPropertyOf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
149
149
  end
@@ -208,7 +208,7 @@ module RDF::Reasoner
208
208
  if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
209
209
  term.domain.each do |t|
210
210
  next if t.node? # Don't entail BNodes
211
- statements << RDF::Statement(self.to_h.merge(predicate: RDF.type, object: t, inferred: true))
211
+ statements << RDF::Statement(**self.to_h.merge(predicate: RDF.type, object: t, inferred: true))
212
212
  end
213
213
  end
214
214
  #$stderr.puts("domain(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
@@ -229,7 +229,7 @@ module RDF::Reasoner
229
229
  if object.resource? && term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
230
230
  term.range.each do |t|
231
231
  next if t.node? # Don't entail BNodes
232
- statements << RDF::Statement(self.to_h.merge(subject: self.object, predicate: RDF.type, object: t, inferred: true))
232
+ statements << RDF::Statement(**self.to_h.merge(subject: self.object, predicate: RDF.type, object: t, inferred: true))
233
233
  end
234
234
  end
235
235
  #$stderr.puts("range(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}")
@@ -249,13 +249,13 @@ module RDF::Reasoner
249
249
  # @param [Hash{Symbol => Object}] options ({})
250
250
  # @option options [Array<RDF::Vocabulary::Term>] :types
251
251
  # Fully entailed types of resource, if not provided, they are queried
252
- def domain_compatible_rdfs?(resource, queryable, options = {})
252
+ def domain_compatible_rdfs?(resource, queryable, **options)
253
253
  raise RDF::Reasoner::Error, "#{self} can't get domains" unless property?
254
254
  domains = Array(self.domain).reject(&:node?) - [RDF::OWL.Thing, RDF::RDFS.Resource]
255
255
 
256
256
  # Fully entailed types of the resource
257
257
  types = options.fetch(:types) do
258
- queryable.query(subject: resource, predicate: RDF.type).
258
+ queryable.query({subject: resource, predicate: RDF.type}).
259
259
  map {|s| (t = (RDF::Vocabulary.find_term(s.object)) rescue nil) && t.entail(:subClassOf)}.
260
260
  flatten.
261
261
  uniq.
@@ -276,7 +276,7 @@ module RDF::Reasoner
276
276
  # @param [Hash{Symbol => Object}] options ({})
277
277
  # @option options [Array<RDF::Vocabulary::Term>] :types
278
278
  # Fully entailed types of resource, if not provided, they are queried
279
- def range_compatible_rdfs?(resource, queryable, options = {})
279
+ def range_compatible_rdfs?(resource, queryable, **options)
280
280
  raise RDF::Reasoner::Error, "#{self} can't get ranges" unless property?
281
281
  if !(ranges = Array(self.range).reject(&:node?) - [RDF::OWL.Thing, RDF::RDFS.Resource]).empty?
282
282
  if resource.literal?
@@ -337,7 +337,7 @@ module RDF::Reasoner
337
337
  else
338
338
  # Fully entailed types of the resource
339
339
  types = options.fetch(:types) do
340
- queryable.query(subject: resource, predicate: RDF.type).
340
+ queryable.query({subject: resource, predicate: RDF.type}).
341
341
  map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
342
342
  flatten.
343
343
  uniq.
@@ -22,12 +22,12 @@ module RDF::Reasoner
22
22
  # @param [Hash{Symbol => Object}] options
23
23
  # @option options [Array<RDF::Vocabulary::Term>] :types
24
24
  # Fully entailed types of resource, if not provided, they are queried
25
- def domain_compatible_schema?(resource, queryable, options = {})
25
+ def domain_compatible_schema?(resource, queryable, **options)
26
26
  raise RDF::Reasoner::Error, "#{self} can't get domains" unless property?
27
27
  domains = Array(self.domainIncludes) - [RDF::OWL.Thing]
28
28
 
29
29
  # Fully entailed types of the resource
30
- types = entailed_types(resource, queryable, options) unless domains.empty?
30
+ types = entailed_types(resource, queryable, **options) unless domains.empty?
31
31
 
32
32
  # Every domain must match some entailed type
33
33
  resource_acceptable = Array(types).empty? || domains.any? {|d| types.include?(d)}
@@ -35,7 +35,7 @@ module RDF::Reasoner
35
35
  # Resource may still be acceptable if types include schema:Role, and any any other resource references `resource` using this property
36
36
  resource_acceptable ||
37
37
  types.include?(RDF::Vocab::SCHEMA.Role) &&
38
- !queryable.query(predicate: self, object: resource).empty?
38
+ !queryable.query({predicate: self, object: resource}).empty?
39
39
  end
40
40
 
41
41
  ##
@@ -52,7 +52,7 @@ module RDF::Reasoner
52
52
  # @param [Hash{Symbol => Object}] options ({})
53
53
  # @option options [Array<RDF::Vocabulary::Term>] :types
54
54
  # Fully entailed types of resource, if not provided, they are queried
55
- def range_compatible_schema?(resource, queryable, options = {})
55
+ def range_compatible_schema?(resource, queryable, **options)
56
56
  raise RDF::Reasoner::Error, "#{self} can't get ranges" unless property?
57
57
  if !(ranges = Array(self.rangeIncludes) - [RDF::OWL.Thing]).empty?
58
58
  if resource.literal?
@@ -123,12 +123,12 @@ module RDF::Reasoner
123
123
  true # schema:URL matches URI resources
124
124
  elsif ranges == [RDF::Vocab::SCHEMA.Text] && resource.uri?
125
125
  # Allowed if resource is untyped
126
- entailed_types(resource, queryable, options).empty?
126
+ entailed_types(resource, queryable, **options).empty?
127
127
  elsif literal_range?(ranges)
128
128
  false # If resource isn't literal, this is a range violation
129
129
  else
130
130
  # Fully entailed types of the resource
131
- types = entailed_types(resource, queryable, options)
131
+ types = entailed_types(resource, queryable, **options)
132
132
 
133
133
  # Every range must match some entailed type
134
134
  resource_acceptable = Array(types).empty? || ranges.any? {|d| types.include?(d)}
@@ -138,7 +138,7 @@ module RDF::Reasoner
138
138
 
139
139
  # Resource also acceptable if it is a Role, and the Role object contains the same predicate having a compatible object
140
140
  types.include?(RDF::Vocab::SCHEMA.Role) &&
141
- queryable.query(subject: resource, predicate: self).any? do |stmt|
141
+ queryable.query({subject: resource, predicate: self}).any? do |stmt|
142
142
  acc = self.range_compatible_schema?(stmt.object, queryable)
143
143
  acc
144
144
  end ||
@@ -174,9 +174,9 @@ module RDF::Reasoner
174
174
 
175
175
  private
176
176
  # Fully entailed types
177
- def entailed_types(resource, queryable, options = {})
177
+ def entailed_types(resource, queryable, **options)
178
178
  options.fetch(:types) do
179
- queryable.query(subject: resource, predicate: RDF.type).
179
+ queryable.query({subject: resource, predicate: RDF.type}).
180
180
  map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
181
181
  flatten.
182
182
  uniq.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-reasoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-12 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdf-vocab
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdf-xsd
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdf-spec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '3.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '3.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdf-turtle
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '3.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '3.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json-ld
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '3.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
96
+ version: '3.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: equivalent-xml
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.8'
117
+ version: '3.9'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.8'
124
+ version: '3.9'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: yard
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.9.19
131
+ version: 0.9.20
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.9.19
138
+ version: 0.9.20
139
139
  description: Reasons over RDFS/OWL vocabularies to generate statements which are entailed
140
140
  based on base RDFS/OWL rules along with vocabulary information. It can also be used
141
141
  to ask specific questions, such as if a given object is consistent with the vocabulary
@@ -168,14 +168,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - ">="
170
170
  - !ruby/object:Gem::Version
171
- version: 2.2.2
171
+ version: '2.4'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
- rubygems_version: 3.0.4
178
+ rubygems_version: 3.0.6
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: RDFS/OWL Reasoner for RDF.rb