Module: RDF::RDFa::Expansion

Included in:
Reader
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/expansion.rb

Overview

The Expansion module performs a subset of OWL entailment rules on the base class, which implementes RDF::Readable.

Defined Under Namespace

Classes: Rule

Instance Method Summary collapse

Instance Method Details

#copy_properties(repository) ⇒ Object

Perform property copying on the resulting default graph.

For all objects of type rdfa:Pattern that are the target of an rdfa:copy property, load the IRI into a repository.

Subsequently, remove reference rdfa:Pattern objects.



49
50
51
52
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/expansion.rb', line 49

def copy_properties(repository)
  add_debug("expand") {"Repository has #{repository.size} statements"}
  fold(repository)
end

#expand(repository) ⇒ Object

Perform vocabulary expansion on the resulting default graph.

Vocabulary expansion uses the built-in reasoner using included vocabularies from RDF.rb.

Parameters:

See Also:

  • PROFILES](https://www.w3.org/TR/2009/REC-owl2-profiles-20091027/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/expansion.rb', line 16

def expand(repository)
  add_debug("expand") {"Repository has #{repository.count} statements"}

  # Load missing vocabularies
  vocabs = repository.query({predicate: RDF::RDFA.usesVocabulary}).to_a.map(&:object)
  vocabs.map! do |vocab|
    begin
      # Create the name with a predictable name so that it is enumerated and can be found
      v = RDF::Vocabulary.find(vocab) || begin
        vg = RDF::Graph.load(vocab)
        RDF::Vocabulary.from_graph(vg, url: vocab, class_name: "D#{Digest::MD5.hexdigest vocab}") unless vg.empty?
      end
    rescue Exception => e
      # indicate the warning if the vocabulary fails to laod
      add_warning("expand", "Error loading vocabulary #{vocab}: #{e.message}", RDF::RDFA.UnresolvedVocabulary)
      nil
    end
  end.compact

  entailment(repository, vocabs)
  add_debug("expand") {"Repository now has #{repository.count} statements"}

end

#rule(name, &block) ⇒ Object



54
55
56
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-ea6265716853/lib/rdf/rdfa/expansion.rb', line 54

def rule(name, &block)
  Rule.new(name, block)
end