Module: RDF::RDFa::Expansion
- Included in:
- Reader
- Defined in:
- lib/rdf/rdfa/expansion.rb,
lib/rdf/rdfa/expansion/v.rb,
lib/rdf/rdfa/expansion/gr.rb,
lib/rdf/rdfa/expansion/cc.rb,
lib/rdf/rdfa/expansion/dc.rb,
lib/rdf/rdfa/expansion/foaf.rb,
lib/rdf/rdfa/expansion/doap.rb,
lib/rdf/rdfa/expansion/sioc.rb,
lib/rdf/rdfa/expansion/skos.rb,
lib/rdf/rdfa/expansion/skosxl.rb,
lib/rdf/rdfa/expansion/schema.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
Constant Summary
- COOKED_VOCAB_STATEMENTS =
Pre-processed vocabularies used to simplify loading of common vocabularies
[]
Instance Method Summary (collapse)
-
- (RDF::Graph) expand
Perform vocabulary expansion on the resulting default graph.
- - (Object) rule(name, &block)
Instance Method Details
- (RDF::Graph) expand
Perform vocabulary expansion on the resulting default graph.
Vocabulary expansion relies on a sub-set of OWL [OWL2-PROFILES] 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, prp-eqp2, cax-sco, cax-eqc1, and cax-eqc2 placing resulting triples into the default graph. Iterate on this step until no more triples are added.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rdf/rdfa/expansion.rb', line 39 def repo = RDF::Repository.new repo << self # Add default graph count = repo.count add_debug("expand") {"Loaded #{repo.size} triples into default graph"} # Vocabularies managed in vocab_repo, and copied to repo for processing. # This allows for persistent storage of vocabularies @@vocab_repo = @options[:vocab_repository] if @options.has_key?(:vocab_repository) @@vocab_repo ||= RDF::Repository.new.insert(*COOKED_VOCAB_STATEMENTS) vocabs = repo.query(:predicate => RDF::RDFA.usesVocabulary).to_a.map(&:object) vocabs.each do |vocab| begin unless @@vocab_repo.has_context?(vocab) add_debug("expand", "Load #{vocab}") @@vocab_repo.load(vocab, :context => vocab) end rescue Exception => e # XXX: update spec to indicate the error if the vocabulary fails to laod add_warning("expand", "Error loading vocabulary #{vocab}: #{e.}", RDF::RDFA.UnresovedVocabulary) end end @@vocab_repo.each do |statement| if vocabs.include?(statement.context) repo << statement end end if repo.count == count add_debug("expand", "No vocabularies loaded") else repo = owl_entailment(repo) end # Return graph with default context graph = RDF::Graph.new repo.statements.each {|st| graph << st if st.context.nil?} graph end |
- (Object) rule(name, &block)
82 83 84 |
# File 'lib/rdf/rdfa/expansion.rb', line 82 def rule(name, &block) Rule.new(name, block) end |