rdf-reasoner 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: f519d63f62d46294c8c459b62ffa5cc0ec678f2c
4
- data.tar.gz: 8987fe2050be4cf328b5749df311f15e514fba2d
3
+ metadata.gz: 64e3d93ea967347ff094db2d1844e3447471a118
4
+ data.tar.gz: 7f5c88de9746a69ad9b492a977c9e2ce869c90f9
5
5
  SHA512:
6
- metadata.gz: 6fbea5eecc04728ae65f46d9aca05dd5abb1324cc9296bc1e173c3f65dd4f227486ce4664a0bfdd0a8b35fcc3d334f154e87603cd2a1a200f325bf428196d877
7
- data.tar.gz: 92ba7bd1e699fe8b1c97d1c835c9b4f37667621abfb937be6aac2274c6721a77a086b5a6d692f86dc3c744bce64aee40fc247c0ea5cdee6164fb452929d1db46
6
+ metadata.gz: 5c79cca368ea71ed8362adaef2a9a68b75ea6bbf1ae58c5d2c98470fbfe7fae1f9127dc709ee5e8c2b027f946e98c1d3fdb4b4cfe12bad7e6e6c73ec4016ac99
7
+ data.tar.gz: a565dc38bb2d0c13f22d3da6a7f34e52347eb571f8f499930f1e1c65c62aea7af05c76b0d7d60b31d662c6c1def9ece0792a02bf6a43c8acbaf72f612aae1c73
data/README.md CHANGED
@@ -98,10 +98,13 @@ Domain and Range entailment include specific rules for schema.org vocabularies.
98
98
  end
99
99
  end
100
100
 
101
+ ## Command-Line interface
102
+ The `rdf` command-line interface is extended with `entail` and `lint` commands. `Entail` can be used in combination, with `serialize` to generate an output graph representation including entailed triples.
103
+
101
104
  ## Dependencies
102
105
 
103
- * [Ruby](http://ruby-lang.org/) (>= 2.0)
104
- * [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.0)
106
+ * [Ruby](http://ruby-lang.org/) (>= 2.2.2)
107
+ * [RDF.rb](http://rubygems.org/gems/rdf) (>= 2.1.1)
105
108
 
106
109
  ## Mailing List
107
110
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -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_hash.merge(object: t))
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_hash.merge(predicate: t))
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?
@@ -58,7 +58,7 @@ module RDF::Reasoner
58
58
  if self.predicate == RDF.type
59
59
  if term = (RDF::Vocabulary.find_term(self.object) rescue nil)
60
60
  term._entail_subClassOf do |t|
61
- statements << RDF::Statement(self.to_hash.merge(object: t))
61
+ statements << RDF::Statement(self.to_h.merge(object: t, inferred: true))
62
62
  end
63
63
  end
64
64
  #$stderr.puts("subClassf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
@@ -127,7 +127,7 @@ module RDF::Reasoner
127
127
  statements = []
128
128
  if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
129
129
  term._entail_subPropertyOf do |t|
130
- statements << RDF::Statement(self.to_hash.merge(predicate: t))
130
+ statements << RDF::Statement(self.to_h.merge(predicate: t, inferred: true))
131
131
  end
132
132
  #$stderr.puts("subPropertyOf(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
133
133
  end
@@ -146,7 +146,7 @@ module RDF::Reasoner
146
146
  statements = []
147
147
  if term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
148
148
  term.domain.each do |t|
149
- statements << RDF::Statement(self.to_hash.merge(predicate: RDF.type, object: t))
149
+ statements << RDF::Statement(self.to_h.merge(predicate: RDF.type, object: t, inferred: true))
150
150
  end
151
151
  end
152
152
  #$stderr.puts("domain(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}}")
@@ -165,7 +165,7 @@ module RDF::Reasoner
165
165
  statements = []
166
166
  if object.resource? && term = (RDF::Vocabulary.find_term(self.predicate) rescue nil)
167
167
  term.range.each do |t|
168
- statements << RDF::Statement(self.to_hash.merge(subject: self.object, predicate: RDF.type, object: t))
168
+ statements << RDF::Statement(self.to_h.merge(subject: self.object, predicate: RDF.type, object: t, inferred: true))
169
169
  end
170
170
  end
171
171
  #$stderr.puts("range(#{self.predicate.pname}): #{statements.map(&:object).map {|r| r.respond_to?(:pname) ? r.pname : r.to_ntriples}}")
@@ -27,13 +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 = options.fetch(:types) do
31
- queryable.query(:subject => resource, :predicate => RDF.type).
32
- map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
33
- flatten.
34
- uniq.
35
- compact
36
- end unless domains.empty?
30
+ types = entailed_types(resource, queryable, options) unless domains.empty?
37
31
 
38
32
  # Every domain must match some entailed type
39
33
  resource_acceptable = Array(types).empty? || domains.any? {|d| types.include?(d)}
@@ -109,7 +103,7 @@ module RDF::Reasoner
109
103
  resource.datatype == RDF::XSD.anyURI ||
110
104
  resource.plain? && RDF::Literal::AnyURI.new(resource.value).valid?
111
105
  else
112
- # If this is an XSD range, look for appropriate literal
106
+ # If may be an XSD range, look for appropriate literal
113
107
  if range.start_with?(RDF::XSD.to_s)
114
108
  if resource.datatype == RDF::URI(range)
115
109
  true
@@ -127,28 +121,14 @@ module RDF::Reasoner
127
121
  true # Special case for schema boolean resources
128
122
  elsif ranges.include?(RDF::Vocab::SCHEMA.URL) && resource.uri?
129
123
  true # schema:URL matches URI resources
130
- elsif ranges.include?(RDF::Vocab::SCHEMA.Text) && resource.uri?
124
+ elsif ranges == [RDF::Vocab::SCHEMA.Text] && resource.uri?
131
125
  # Allowed if resource is untyped
132
- # Fully entailed types of the resource
133
- types = options.fetch(:types) do
134
- queryable.query(:subject => resource, :predicate => RDF.type).
135
- map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
136
- flatten.
137
- uniq.
138
- compact
139
- end
140
- types.empty?
126
+ entailed_types(resource, queryable, options).empty?
141
127
  elsif literal_range?(ranges)
142
128
  false # If resource isn't literal, this is a range violation
143
129
  else
144
130
  # Fully entailed types of the resource
145
- types = options.fetch(:types) do
146
- queryable.query(:subject => resource, :predicate => RDF.type).
147
- map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
148
- flatten.
149
- uniq.
150
- compact
151
- end
131
+ types = entailed_types(resource, queryable, options)
152
132
 
153
133
  # Every range must match some entailed type
154
134
  resource_acceptable = Array(types).empty? || ranges.any? {|d| types.include?(d)}
@@ -191,6 +171,18 @@ module RDF::Reasoner
191
171
 
192
172
  def self.included(mod)
193
173
  end
174
+
175
+ private
176
+ # Fully entailed types
177
+ def entailed_types(resource, queryable, options = {})
178
+ options.fetch(:types) do
179
+ queryable.query(:subject => resource, :predicate => RDF.type).
180
+ map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
181
+ flatten.
182
+ uniq.
183
+ compact
184
+ end
185
+ end
194
186
  end
195
187
 
196
188
  # Extend the Term with this methods
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-10 00:00:00.000000000 Z
11
+ date: 2016-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.1
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: '2.0'
29
+ version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rdf-vocab
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +65,7 @@ dependencies:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
67
  version: '2.0'
62
- type: :runtime
68
+ type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
@@ -168,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
174
  requirements:
169
175
  - - ">="
170
176
  - !ruby/object:Gem::Version
171
- version: '2.0'
177
+ version: 2.2.2
172
178
  required_rubygems_version: !ruby/object:Gem::Requirement
173
179
  requirements:
174
180
  - - ">="
@@ -176,9 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
182
  version: '0'
177
183
  requirements: []
178
184
  rubyforge_project:
179
- rubygems_version: 2.4.8
185
+ rubygems_version: 2.6.8
180
186
  signing_key:
181
187
  specification_version: 4
182
188
  summary: RDFS/OWL Reasoner for RDF.rb
183
189
  test_files: []
184
- has_rdoc: false