module RDF::Microdata::Expansion
The Expansion
module performs a subset of OWL entailment rules on the base class, which implementes RDF::Readable.
Constants
- RULES
Public Instance Methods
expand()
click to toggle source
Perform vocabulary expansion on the resulting default graph.
Vocabulary expansion relies on a sub-set of OWL [OWL2-PROFILES](http://www.w3.org/TR/2009/REC-owl2-profiles-20091027/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules) entailment to add triples to the default graph based on rules and property/class relationships described in referenced vocabularies.
For all objects that are the target of an rdfa:usesVocabulary property, load the IRI into a repository.
Subsequently, perform OWL expansion using rules prp-spo1, prp-eqp1, and prp-eqp2 placing resulting triples into the default graph. Iterate on this step until no more triples are added.
@example
scm-spo {pq rdfs:subPropertyOf pw . pw rdfs:subPropertyOf p3} => {p1 rdfs:subPropertyOf p3} rdprp-spo1fs7 {p1 rdfs:subPropertyOf p2 . x p1 y} => {x p2 y}
@return [RDF::Graph] @see [OWL2 PROFILES][]
# File lib/rdf/microdata/expansion.rb, line 25 def expand repo = RDF::Repository.new repo << self # Add default graph log_debug("expand") {"Loaded #{repo.size} triples into default graph"} repo = owl_entailment(repo) # Return graph with default graph graph = RDF::Graph.new repo.statements.each {|st| graph << st} graph end
rule(name, &block)
click to toggle source
# File lib/rdf/microdata/expansion.rb, line 39 def rule(name, &block) Rule.new(name, **@options, &block) end
Private Instance Methods
owl_entailment(repo)
click to toggle source
Perform OWL entailment rules on enumerable @param [RDF::Enumerable] repo @return [RDF::Enumerable]
# File lib/rdf/microdata/expansion.rb, line 145 def owl_entailment(repo) old_count = 0 while old_count < (count = repo.count) log_debug("entailment", "old: #{old_count} count: #{count}") old_count = count RULES.each do |rule| rule.execute(repo) do |statement| log_debug("entailment(#{rule.name})") {statement.inspect} repo << statement end end end log_debug("entailment", "final count: #{count}") repo end