Class: RDF::URI

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/reasoner/extensions.rb

Constant Summary collapse

@@entailments =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_entailment(method, proc) ⇒ Object

Add an entailment method. The method accepts no arguments, and returns or yields an array of values associated with the particular entailment method

Parameters:

  • method (Symbol)
  • proc (Proc)


13
14
15
# File 'lib/rdf/reasoner/extensions.rb', line 13

def add_entailment(method, proc)
  @@entailments[method] = proc
end

Instance Method Details

#domain_compatible?(resource, queryable, options = {}) ⇒ Boolean

Determine if the domain of a property term is consistent with the specified resource in ‘queryable`.

Parameters:

  • resource (RDF::Resource)
  • queryable (RDF::Queryable)
  • options (Hash{Symbol => Object}) (defaults to: {})

    ({})

Options Hash (options):

  • :types (Array<RDF::Vocabulary::Term>)

    Fully entailed types of resource, if not provided, they are queried

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/rdf/reasoner/extensions.rb', line 37

def domain_compatible?(resource, queryable, options = {})
  %w(owl rdfs schema).map {|r| "domain_compatible_#{r}?".to_sym}.all? do |meth|
    !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
  end
end

#entail(method) {|term| ... } ⇒ Array<Term>

Perform an entailment on this term.

Parameters:

  • method (Symbol)

    A registered entailment method

Yields:

  • term

Yield Parameters:

  • term (Term)

Returns:

  • (Array<Term>)


25
26
27
# File 'lib/rdf/reasoner/extensions.rb', line 25

def entail(method, &block)
  self.send(@@entailments.fetch(method), &block)
end

#range_compatible?(resource, queryable, options = {}) ⇒ Boolean

Determine if the range of a property term is consistent with the specified resource in ‘queryable`.

Specific entailment regimes should insert themselves before this to apply the appropriate semantic condition

Parameters:

  • resource (RDF::Resource)
  • queryable (RDF::Queryable)
  • options (Hash{Symbol => Object}) (defaults to: {})

    ({})

Options Hash (options):

  • :types (Array<RDF::Vocabulary::Term>)

    Fully entailed types of resource, if not provided, they are queried

Returns:

  • (Boolean)


53
54
55
56
57
# File 'lib/rdf/reasoner/extensions.rb', line 53

def range_compatible?(resource, queryable, options = {})
  %w(owl rdfs schema).map {|r| "range_compatible_#{r}?".to_sym}.all? do |meth|
    !self.respond_to?(meth) || self.send(meth, resource, queryable, options)
  end
end