rdf-reasoner 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -18
- data/UNLICENSE +1 -1
- data/VERSION +1 -1
- data/lib/rdf/reasoner.rb +1 -1
- data/lib/rdf/reasoner/format.rb +1 -1
- data/lib/rdf/reasoner/rdfs.rb +60 -1
- metadata +12 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60eee91f9020b95645e085da0bdb5f300639bb393d11b8e197bbe982e1ee8bcd
|
4
|
+
data.tar.gz: 3f281de995bbae445decd9ad8840306d477b9fd47f88289c7fdbcb812c47234b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 181413e24899b1b0a27d6d53e3a3f74c651f3acd990266fc75fe6cc15d3d1b8ebcceb42fbd23dd1a47a9461de263bf4e1bdc70c4f8ab81bc3a924ce71c8529b8
|
7
|
+
data.tar.gz: 1423ab5bc2f0e474ba001f61cf72a881be09d3ef90be4cd5fd81abbc8d091fc83bd2a032445eb04967f0b334e7ab291046945cd81b69cafb9651a3266b70ed83
|
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.
|
@@ -51,7 +52,7 @@ Domain and Range entailment include specific rules for schema.org vocabularies.
|
|
51
52
|
|
52
53
|
RDF::Reasoner.apply(:rdfs)
|
53
54
|
graph = RDF::Graph.load("etc/doap.ttl")
|
54
|
-
subj = RDF::URI("
|
55
|
+
subj = RDF::URI("https://rubygems.org/gems/rdf-reasoner")
|
55
56
|
RDF::Vocab::DOAP.name.domain_compatible?(subj, graph) # => true
|
56
57
|
|
57
58
|
### Determine if a resource is compatible with the ranges of a property
|
@@ -103,16 +104,16 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
|
|
103
104
|
|
104
105
|
## Dependencies
|
105
106
|
|
106
|
-
* [Ruby](
|
107
|
-
* [RDF.rb](
|
107
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.2.2)
|
108
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.0)
|
108
109
|
|
109
110
|
## Mailing List
|
110
111
|
|
111
|
-
* <
|
112
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
112
113
|
|
113
114
|
## Authors
|
114
115
|
|
115
|
-
* [Gregg Kellogg](
|
116
|
+
* [Gregg Kellogg](https://githubhub.com/gkellogg) - <https://greggkellogg.net/>
|
116
117
|
|
117
118
|
## Contributing
|
118
119
|
|
@@ -132,17 +133,17 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
|
|
132
133
|
## License
|
133
134
|
|
134
135
|
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]:
|
136
|
+
see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
137
|
+
|
138
|
+
[Ruby]: https://ruby-lang.org/
|
139
|
+
[RDF]: https://www.w3.org/RDF/
|
140
|
+
[YARD]: https://yardoc.org/
|
141
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
142
|
+
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
143
|
+
[SPARQL]: https://en.wikipedia.org/wiki/SPARQL
|
144
|
+
[SPARQL Query]: https://www.w3.org/TR/2013/REC-sparql11-query-20130321/
|
145
|
+
[SPARQL Entailment]:https://www.w3.org/TR/sparql11-entailment/
|
146
|
+
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts
|
147
|
+
[RDF.rb]: https://www.rubydoc.info/github/ruby-rdf/rdf/
|
148
|
+
[RDF Schema]: https://www.w3.org/TR/rdf-schema/
|
148
149
|
[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.5.
|
1
|
+
0.5.2
|
data/lib/rdf/reasoner.rb
CHANGED
@@ -7,7 +7,7 @@ module RDF
|
|
7
7
|
# RDFS/OWL reasonsing for RDF.rb.
|
8
8
|
#
|
9
9
|
# @see http://www.w3.org/TR/2013/REC-sparql11-entailment-20130321/
|
10
|
-
# @author [Gregg Kellogg](
|
10
|
+
# @author [Gregg Kellogg](https://greggkellogg.net/)
|
11
11
|
module Reasoner
|
12
12
|
require 'rdf/reasoner/format'
|
13
13
|
autoload :OWL, 'rdf/reasoner/owl'
|
data/lib/rdf/reasoner/format.rb
CHANGED
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
|
@@ -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
|
@@ -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
|
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.
|
4
|
+
version: 0.5.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: 2019-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -84,22 +84,16 @@ dependencies:
|
|
84
84
|
name: json-ld
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.2'
|
90
|
-
- - "<"
|
87
|
+
- - "~>"
|
91
88
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
89
|
+
version: '3.0'
|
93
90
|
type: :development
|
94
91
|
prerelease: false
|
95
92
|
version_requirements: !ruby/object:Gem::Requirement
|
96
93
|
requirements:
|
97
|
-
- - "
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '2.2'
|
100
|
-
- - "<"
|
94
|
+
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
96
|
+
version: '3.0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: equivalent-xml
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,28 +114,28 @@ dependencies:
|
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: '3.
|
117
|
+
version: '3.8'
|
124
118
|
type: :development
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
124
|
+
version: '3.8'
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: yard
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - "~>"
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.9.
|
131
|
+
version: 0.9.19
|
138
132
|
type: :development
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
136
|
- - "~>"
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.9.
|
138
|
+
version: 0.9.19
|
145
139
|
description: Reasons over RDFS/OWL vocabularies to generate statements which are entailed
|
146
140
|
based on base RDFS/OWL rules along with vocabulary information. It can also be used
|
147
141
|
to ask specific questions, such as if a given object is consistent with the vocabulary
|
@@ -162,7 +156,7 @@ files:
|
|
162
156
|
- lib/rdf/reasoner/rdfs.rb
|
163
157
|
- lib/rdf/reasoner/schema.rb
|
164
158
|
- lib/rdf/reasoner/version.rb
|
165
|
-
homepage:
|
159
|
+
homepage: https://githubhub.com/gkellogg/rdf-reasoner
|
166
160
|
licenses:
|
167
161
|
- Unlicense
|
168
162
|
metadata: {}
|
@@ -181,8 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
175
|
- !ruby/object:Gem::Version
|
182
176
|
version: '0'
|
183
177
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.7.3
|
178
|
+
rubygems_version: 3.0.3
|
186
179
|
signing_key:
|
187
180
|
specification_version: 4
|
188
181
|
summary: RDFS/OWL Reasoner for RDF.rb
|