rdf-reasoner 0.5.1 → 0.6.2
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.
- checksums.yaml +4 -4
- data/README.md +27 -18
- data/UNLICENSE +1 -1
- data/VERSION +1 -1
- data/lib/rdf/reasoner.rb +3 -3
- data/lib/rdf/reasoner/extensions.rb +6 -6
- data/lib/rdf/reasoner/format.rb +1 -1
- data/lib/rdf/reasoner/owl.rb +2 -2
- data/lib/rdf/reasoner/rdfs.rb +67 -8
- data/lib/rdf/reasoner/schema.rb +7 -7
- metadata +35 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07635fa242cf39764de458b06e4afe87fbaddf311a37fb67c4e2a1137389ab20
|
4
|
+
data.tar.gz: 654c79cfc3d28e9ac29f890f264552c9c9af13d19aca0361cb79dfca19c38002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b303be11f5f865989558acb9865c5a5cf55f2a16f464e14ad049b30ff316b87eec2006fa3ad6f13fd081332ae12a11fd1500d6cb66d75acebc59d1b95c351212
|
7
|
+
data.tar.gz: 5406d22674e0fe00252c6b26c60265e1e0dd8340317fae6c8f7cf2b2dd3223152a0fa065f47644878613e076754b6cd76de21b182047f0e272ed161e4f82af28
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Reasons over RDFS/OWL vocabularies and schema.org to generate statements which a
|
|
8
8
|
* Entail `rdfs:subPropertyOf` generating an array of terms which are ancestors of the subject.
|
9
9
|
* Entail `rdfs:domain` and `rdfs:range` adding `rdf:type` assertions on the subject or object.
|
10
10
|
* Inverse `rdfs:subClassOf` entailment, to find descendant classes of the subject term.
|
11
|
+
* Inverse `rdfs:subPropertyOf` entailment, to find descendant properties of the subject term.
|
11
12
|
* Entail `owl:equivalentClass` generating an array of terms equivalent to the subject.
|
12
13
|
* Entail `owl:equivalentProperty` generating an array of terms equivalent to the subject.
|
13
14
|
* `domainCompatible?` determines if a particular resource is compatible with the domain definition of a given predicate, based on the intersection of entailed subclasses with the property domain.
|
@@ -21,6 +22,14 @@ Domain and Range entailment include specific rules for schema.org vocabularies.
|
|
21
22
|
* If `resource` is of type `schema:Role`, it is range acceptable if it has the same property with an acceptable value.
|
22
23
|
* If `resource` is of type `rdf:List` (must be previously entailed), it is range acceptable if all members of the list are otherwise range acceptable on the same property.
|
23
24
|
|
25
|
+
### Limiting vocabularies used for reasoning
|
26
|
+
|
27
|
+
As loading vocabularies can dominate processing time, the `RDF::Vocabulary.limit_vocabs` method can be used to set a specific set of vocabularies over which to reason. For example:
|
28
|
+
|
29
|
+
RDF::Vocabulary.limit_vocabs(:rdf, :rdf, :schema)
|
30
|
+
|
31
|
+
will limit the vocabularies which are returned from `RDF::Vocabulary.each`, which is used for reasoning and other operations over vocabularies and terms.
|
32
|
+
|
24
33
|
## Examples
|
25
34
|
### Determine super-classes of a class
|
26
35
|
|
@@ -51,7 +60,7 @@ Domain and Range entailment include specific rules for schema.org vocabularies.
|
|
51
60
|
|
52
61
|
RDF::Reasoner.apply(:rdfs)
|
53
62
|
graph = RDF::Graph.load("etc/doap.ttl")
|
54
|
-
subj = RDF::URI("
|
63
|
+
subj = RDF::URI("https://rubygems.org/gems/rdf-reasoner")
|
55
64
|
RDF::Vocab::DOAP.name.domain_compatible?(subj, graph) # => true
|
56
65
|
|
57
66
|
### Determine if a resource is compatible with the ranges of a property
|
@@ -103,16 +112,16 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
|
|
103
112
|
|
104
113
|
## Dependencies
|
105
114
|
|
106
|
-
* [Ruby](
|
107
|
-
* [RDF.rb](
|
115
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.4)
|
116
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
|
108
117
|
|
109
118
|
## Mailing List
|
110
119
|
|
111
|
-
* <
|
120
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
112
121
|
|
113
122
|
## Authors
|
114
123
|
|
115
|
-
* [Gregg Kellogg](
|
124
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
|
116
125
|
|
117
126
|
## Contributing
|
118
127
|
|
@@ -132,17 +141,17 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
|
|
132
141
|
## License
|
133
142
|
|
134
143
|
This is free and unencumbered public domain software. For more information,
|
135
|
-
see <
|
136
|
-
|
137
|
-
[Ruby]:
|
138
|
-
[RDF]:
|
139
|
-
[YARD]:
|
140
|
-
[YARD-GS]:
|
141
|
-
[PDD]:
|
142
|
-
[SPARQL]:
|
143
|
-
[SPARQL Query]:
|
144
|
-
[SPARQL Entailment]:
|
145
|
-
[RDF 1.1]:
|
146
|
-
[RDF.rb]:
|
147
|
-
[RDF Schema]:
|
144
|
+
see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
145
|
+
|
146
|
+
[Ruby]: https://ruby-lang.org/
|
147
|
+
[RDF]: https://www.w3.org/RDF/
|
148
|
+
[YARD]: https://yardoc.org/
|
149
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
150
|
+
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
151
|
+
[SPARQL]: https://en.wikipedia.org/wiki/SPARQL
|
152
|
+
[SPARQL Query]: https://www.w3.org/TR/2013/REC-sparql11-query-20130321/
|
153
|
+
[SPARQL Entailment]:https://www.w3.org/TR/sparql11-entailment/
|
154
|
+
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts
|
155
|
+
[RDF.rb]: https://www.rubydoc.info/github/ruby-rdf/rdf/
|
156
|
+
[RDF Schema]: https://www.w3.org/TR/rdf-schema/
|
148
157
|
[Rack]: https://rack.github.io/
|
data/UNLICENSE
CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
21
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
22
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
For more information, please refer to <
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.2
|
data/lib/rdf/reasoner.rb
CHANGED
@@ -6,8 +6,8 @@ module RDF
|
|
6
6
|
##
|
7
7
|
# RDFS/OWL reasonsing for RDF.rb.
|
8
8
|
#
|
9
|
-
# @see
|
10
|
-
# @author [Gregg Kellogg](
|
9
|
+
# @see https://www.w3.org/TR/2013/REC-sparql11-entailment-20130321/
|
10
|
+
# @author [Gregg Kellogg](https://greggkellogg.net/)
|
11
11
|
module Reasoner
|
12
12
|
require 'rdf/reasoner/format'
|
13
13
|
autoload :OWL, 'rdf/reasoner/owl'
|
@@ -15,7 +15,7 @@ module RDF
|
|
15
15
|
autoload :Schema, 'rdf/reasoner/schema'
|
16
16
|
autoload :VERSION, 'rdf/reasoner/version'
|
17
17
|
|
18
|
-
# See
|
18
|
+
# See https://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/
|
19
19
|
#
|
20
20
|
#
|
21
21
|
ISO_8601 = %r(^
|
@@ -91,7 +91,7 @@ module RDF
|
|
91
91
|
# Fully entailed types of resource, if not provided, they are queried
|
92
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
|
|
@@ -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
|
@@ -264,7 +264,7 @@ module RDF
|
|
264
264
|
end
|
265
265
|
|
266
266
|
# Must be a defined property
|
267
|
-
if term && term.property?
|
267
|
+
if term.respond_to?(:property?) && term.property?
|
268
268
|
# Warn against using a deprecated term
|
269
269
|
superseded = term.attributes[:'schema:supersededBy']
|
270
270
|
superseded = superseded.pname if superseded.respond_to?(: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
|
')'
|
data/lib/rdf/reasoner/format.rb
CHANGED
data/lib/rdf/reasoner/owl.rb
CHANGED
@@ -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?
|
data/lib/rdf/reasoner/rdfs.rb
CHANGED
@@ -34,6 +34,20 @@ module RDF::Reasoner
|
|
34
34
|
@@subPropertyOf_cache ||= RDF::Util::Cache.new(-1)
|
35
35
|
end
|
36
36
|
|
37
|
+
##
|
38
|
+
# @return [RDF::Util::Cache]
|
39
|
+
# @private
|
40
|
+
def subProperty_cache
|
41
|
+
@@subProperty_cache ||= RDF::Util::Cache.new(-1)
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @return [RDF::Util::Cache]
|
46
|
+
# @private
|
47
|
+
def descendant_property_cache
|
48
|
+
@@descendant_property_cache ||= RDF::Util::Cache.new(-1)
|
49
|
+
end
|
50
|
+
|
37
51
|
##
|
38
52
|
# For a Term: yield or return inferred subClassOf relationships by recursively applying to named super classes to get a complete set of classes in the ancestor chain of this class
|
39
53
|
# For a Statement: if predicate is `rdf:types`, yield or return inferred statements having a subClassOf relationship to the type of this statement
|
@@ -60,7 +74,7 @@ module RDF::Reasoner
|
|
60
74
|
if term = (RDF::Vocabulary.find_term(self.object) rescue nil)
|
61
75
|
term._entail_subClassOf do |t|
|
62
76
|
next if t.node? # Don't entail BNodes
|
63
|
-
statements << RDF::Statement(self.to_h.merge(object: t, inferred: true))
|
77
|
+
statements << RDF::Statement(**self.to_h.merge(object: t, inferred: true))
|
64
78
|
end
|
65
79
|
end
|
66
80
|
#$stderr.puts("subClassf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
|
@@ -108,7 +122,7 @@ module RDF::Reasoner
|
|
108
122
|
|
109
123
|
##
|
110
124
|
# For a Term: yield or return inferred subPropertyOf relationships by recursively applying to named super classes to get a complete set of classes in the ancestor chain of this class
|
111
|
-
# For a Statement: yield or return inferred statements having a subPropertyOf relationship to predicate of this
|
125
|
+
# For a Statement: yield or return inferred statements having a subPropertyOf relationship to predicate of this statements
|
112
126
|
# @private
|
113
127
|
def _entail_subPropertyOf
|
114
128
|
case self
|
@@ -129,7 +143,7 @@ module RDF::Reasoner
|
|
129
143
|
statements = []
|
130
144
|
if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
|
131
145
|
term._entail_subPropertyOf do |t|
|
132
|
-
statements << RDF::Statement(self.to_h.merge(predicate: t, inferred: true))
|
146
|
+
statements << RDF::Statement(**self.to_h.merge(predicate: t, inferred: true))
|
133
147
|
end
|
134
148
|
#$stderr.puts("subPropertyOf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
|
135
149
|
end
|
@@ -139,6 +153,50 @@ module RDF::Reasoner
|
|
139
153
|
end
|
140
154
|
end
|
141
155
|
|
156
|
+
##
|
157
|
+
# For a Term: yield or return inferred subProperty relationships
|
158
|
+
# by recursively applying to named subproperties to get a complete
|
159
|
+
# set of properties in the descendant chain of this property
|
160
|
+
#
|
161
|
+
# For a Statement: this is a no-op, as it's not useful in this context
|
162
|
+
# @private
|
163
|
+
|
164
|
+
def _entail_subProperty
|
165
|
+
case self
|
166
|
+
when RDF::URI, RDF::Node
|
167
|
+
unless property?
|
168
|
+
yield self if block_given?
|
169
|
+
return Array(self)
|
170
|
+
end
|
171
|
+
|
172
|
+
terms = descendant_property_cache[self] ||= (
|
173
|
+
Array(self.subProperty).map do |c|
|
174
|
+
c._entail_subProperty rescue c
|
175
|
+
end.flatten + Array(self)).compact
|
176
|
+
|
177
|
+
terms.each {|t| yield t } if block_given?
|
178
|
+
terms
|
179
|
+
else []
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
##
|
184
|
+
# Get the immediate subproperties of this property.
|
185
|
+
#
|
186
|
+
# This iterates over terms defined in the vocabulary of this term,
|
187
|
+
# as well as the vocabularies imported by this vocabulary.
|
188
|
+
# @return [Array<RDF::Vocabulary::Term>]
|
189
|
+
def subProperty
|
190
|
+
raise RDF::Reasoner::Error,
|
191
|
+
"#{self} Can't entail subProperty" unless property?
|
192
|
+
vocabs = [self.vocab] + self.vocab.imported_from
|
193
|
+
subProperty_cache[self] ||= vocabs.map do |v|
|
194
|
+
Array(v.properties).select do |p|
|
195
|
+
p.property? && Array(p.subPropertyOf).include?(self)
|
196
|
+
end
|
197
|
+
end.flatten.compact
|
198
|
+
end
|
199
|
+
|
142
200
|
##
|
143
201
|
# For a Statement: yield or return inferred statements having an rdf:type of the domain of the statement predicate
|
144
202
|
# @todo Should be able to entail owl:unionOf, which is a BNode. This should be allowed, and also add BNode values of that node, recursively, similar to SPARQL concise_bounded_description.uu
|
@@ -150,7 +208,7 @@ module RDF::Reasoner
|
|
150
208
|
if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
|
151
209
|
term.domain.each do |t|
|
152
210
|
next if t.node? # Don't entail BNodes
|
153
|
-
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))
|
154
212
|
end
|
155
213
|
end
|
156
214
|
#$stderr.puts("domain(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
|
@@ -171,7 +229,7 @@ module RDF::Reasoner
|
|
171
229
|
if object.resource? && term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
|
172
230
|
term.range.each do |t|
|
173
231
|
next if t.node? # Don't entail BNodes
|
174
|
-
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))
|
175
233
|
end
|
176
234
|
end
|
177
235
|
#$stderr.puts("range(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}")
|
@@ -197,7 +255,7 @@ module RDF::Reasoner
|
|
197
255
|
|
198
256
|
# Fully entailed types of the resource
|
199
257
|
types = options.fetch(:types) do
|
200
|
-
queryable.query(subject: resource, predicate: RDF.type).
|
258
|
+
queryable.query({subject: resource, predicate: RDF.type}).
|
201
259
|
map {|s| (t = (RDF::Vocabulary.find_term(s.object)) rescue nil) && t.entail(:subClassOf)}.
|
202
260
|
flatten.
|
203
261
|
uniq.
|
@@ -279,7 +337,7 @@ module RDF::Reasoner
|
|
279
337
|
else
|
280
338
|
# Fully entailed types of the resource
|
281
339
|
types = options.fetch(:types) do
|
282
|
-
queryable.query(subject: resource, predicate: RDF.type).
|
340
|
+
queryable.query({subject: resource, predicate: RDF.type}).
|
283
341
|
map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
|
284
342
|
flatten.
|
285
343
|
uniq.
|
@@ -303,6 +361,7 @@ module RDF::Reasoner
|
|
303
361
|
mod.add_entailment :subClassOf, :_entail_subClassOf
|
304
362
|
mod.add_entailment :subClass, :_entail_subClass
|
305
363
|
mod.add_entailment :subPropertyOf, :_entail_subPropertyOf
|
364
|
+
mod.add_entailment :subProperty, :_entail_subProperty
|
306
365
|
mod.add_entailment :domain, :_entail_domain
|
307
366
|
mod.add_entailment :range, :_entail_range
|
308
367
|
end
|
@@ -319,4 +378,4 @@ module RDF::Reasoner
|
|
319
378
|
|
320
379
|
# Extend Mutable with these methods
|
321
380
|
::RDF::Mutable.send(:include, RDFS)
|
322
|
-
end
|
381
|
+
end
|
data/lib/rdf/reasoner/schema.rb
CHANGED
@@ -27,7 +27,7 @@ module RDF::Reasoner
|
|
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
|
##
|
@@ -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.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -16,90 +16,96 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.1.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
29
|
+
version: '3.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.1.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rdf-vocab
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
39
|
+
version: '3.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.1.5
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - "~>"
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
49
|
+
version: '3.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.1.5
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: rdf-xsd
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
57
|
- - "~>"
|
46
58
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
59
|
+
version: '3.1'
|
48
60
|
type: :runtime
|
49
61
|
prerelease: false
|
50
62
|
version_requirements: !ruby/object:Gem::Requirement
|
51
63
|
requirements:
|
52
64
|
- - "~>"
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
66
|
+
version: '3.1'
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: rdf-spec
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
71
|
- - "~>"
|
60
72
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
73
|
+
version: '3.1'
|
62
74
|
type: :development
|
63
75
|
prerelease: false
|
64
76
|
version_requirements: !ruby/object:Gem::Requirement
|
65
77
|
requirements:
|
66
78
|
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
80
|
+
version: '3.1'
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: rdf-turtle
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
85
|
- - "~>"
|
74
86
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
87
|
+
version: '3.1'
|
76
88
|
type: :development
|
77
89
|
prerelease: false
|
78
90
|
version_requirements: !ruby/object:Gem::Requirement
|
79
91
|
requirements:
|
80
92
|
- - "~>"
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
94
|
+
version: '3.1'
|
83
95
|
- !ruby/object:Gem::Dependency
|
84
96
|
name: json-ld
|
85
97
|
requirement: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
|
-
- - "
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.2'
|
90
|
-
- - "<"
|
99
|
+
- - "~>"
|
91
100
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
101
|
+
version: '3.1'
|
93
102
|
type: :development
|
94
103
|
prerelease: false
|
95
104
|
version_requirements: !ruby/object:Gem::Requirement
|
96
105
|
requirements:
|
97
|
-
- - "
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '2.2'
|
100
|
-
- - "<"
|
106
|
+
- - "~>"
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
108
|
+
version: '3.1'
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: equivalent-xml
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,28 +126,28 @@ dependencies:
|
|
120
126
|
requirements:
|
121
127
|
- - "~>"
|
122
128
|
- !ruby/object:Gem::Version
|
123
|
-
version: '3.
|
129
|
+
version: '3.9'
|
124
130
|
type: :development
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
127
133
|
requirements:
|
128
134
|
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
136
|
+
version: '3.9'
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
138
|
name: yard
|
133
139
|
requirement: !ruby/object:Gem::Requirement
|
134
140
|
requirements:
|
135
141
|
- - "~>"
|
136
142
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.9.
|
143
|
+
version: 0.9.20
|
138
144
|
type: :development
|
139
145
|
prerelease: false
|
140
146
|
version_requirements: !ruby/object:Gem::Requirement
|
141
147
|
requirements:
|
142
148
|
- - "~>"
|
143
149
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.9.
|
150
|
+
version: 0.9.20
|
145
151
|
description: Reasons over RDFS/OWL vocabularies to generate statements which are entailed
|
146
152
|
based on base RDFS/OWL rules along with vocabulary information. It can also be used
|
147
153
|
to ask specific questions, such as if a given object is consistent with the vocabulary
|
@@ -162,7 +168,7 @@ files:
|
|
162
168
|
- lib/rdf/reasoner/rdfs.rb
|
163
169
|
- lib/rdf/reasoner/schema.rb
|
164
170
|
- lib/rdf/reasoner/version.rb
|
165
|
-
homepage:
|
171
|
+
homepage: https://github.com/ruby-rdf/rdf-reasoner
|
166
172
|
licenses:
|
167
173
|
- Unlicense
|
168
174
|
metadata: {}
|
@@ -174,15 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
180
|
requirements:
|
175
181
|
- - ">="
|
176
182
|
- !ruby/object:Gem::Version
|
177
|
-
version: 2.
|
183
|
+
version: '2.4'
|
178
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
185
|
requirements:
|
180
186
|
- - ">="
|
181
187
|
- !ruby/object:Gem::Version
|
182
188
|
version: '0'
|
183
189
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.7.3
|
190
|
+
rubygems_version: 3.1.3
|
186
191
|
signing_key:
|
187
192
|
specification_version: 4
|
188
193
|
summary: RDFS/OWL Reasoner for RDF.rb
|