lib/rdf/microdata/expansion.rb in rdf-microdata-2.0.2 vs lib/rdf/microdata/expansion.rb in rdf-microdata-2.0.3.beta1
- old
+ new
@@ -25,30 +25,32 @@
def expand
repo = RDF::Repository.new
repo << self # Add default graph
count = repo.count
- add_debug("expand") {"Loaded #{repo.size} triples into 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
def rule(name, &block)
- Rule.new(name, block)
+ Rule.new(name, @options, block)
end
##
# An entailment rule
#
# Takes a list of antecedent patterns used to find solutions against a queryable
# object. Yields each consequent with bindings from the solution
class Rule
+ include RDF::Util::Logger
+
# @!attribute [r]
# @return [Array<RDF::Query::Pattern>] patterns necessary to invoke this rule
attr_reader :antecedents
# @!attribute [r] consequents
@@ -68,13 +70,14 @@
# end
#
# r.execute(queryable) {|statement| puts statement.inspect}
#
# @param [String] name
- def initialize(name, &block)
+ def initialize(name, options = {}, &block)
@antecedents = []
@consequents = []
+ @options = options.dup
@name = name
if block_given?
case block.arity
when 1 then block.call(self)
@@ -142,21 +145,21 @@
# @return [RDF::Enumerable]
def owl_entailment(repo)
old_count = 0
while old_count < (count = repo.count)
- add_debug("entailment", "old: #{old_count} count: #{count}")
+ log_debug("entailment", "old: #{old_count} count: #{count}")
old_count = count
RULES.each do |rule|
rule.execute(repo) do |statement|
- add_debug("entailment(#{rule.name})") {statement.inspect}
+ log_debug("entailment(#{rule.name})") {statement.inspect}
repo << statement
end
end
end
- add_debug("entailment", "final count: #{count}")
+ log_debug("entailment", "final count: #{count}")
repo
end
end
end