rdf-reasoner

Reasons over RDFS/OWL vocabularies and schema.org to generate statements which are entailed based on base RDFS/OWL rules along with vocabulary information. It can also be used to ask specific questions, such as if a given object is consistent with the vocabulary ruleset. This can be used to implement SPARQL Entailment Regimes and RDF Schema entailment.

Features

Domain and Range entailment include specific rules for schema.org vocabularies.

Examples

Determine super-classes of a class

require 'rdf/reasoner'

RDF::Reasoner.apply(:rdfs)
term = RDF::Vocabulary.find_term("http://xmlns.com/foaf/0.1/Person")
term.entail(:subClassOf)
  # => [
    foaf:Agent,
    http://www.w3.org/2000/10/swap/pim/contact#Person,
    geo:SpatialThing,
    foaf:Person
  ]

Determine sub-classes of a class

require 'rdf/reasoner'

RDF::Reasoner.apply(:rdfs)
term = RDF::FOAF.Person
term.entail(:subClass) # => [foaf:Person, mo:SoloMusicArtist]

Determine if a resource is compatible with the domains of a property

require 'rdf/reasoner'
require 'rdf/turtle'

RDF::Reasoner.apply(:rdfs)
graph = RDF::Graph.load("etc/doap.ttl")
subj = RDF::URI("http://rubygems.org/gems/rdf-reasoner")
RDF::DOAP.name.domain_compatible?(subj, graph) # => true

Determine if a resource is compatible with the ranges of a property

require 'rdf/reasoner'
require 'rdf/turtle'

RDF::Reasoner.apply(:rdfs)
graph = RDF::Graph.load("etc/doap.ttl")
obj = RDF::Literal(Date.new)
RDF::DOAP.created.range_compatible?(obj, graph) # => true

Perform equivalentClass entailment on a graph

require 'rdf/reasoner'
require 'rdf/turtle'

RDF::Reasoner.apply(::owl)
graph = RDF::Graph.load("etc/doap.ttl")
graph.entail!(:equivalentClass)

Yield all entailed statements for all entailment methods

require 'rdf/reasoner'
require 'rdf/turtle'

RDF::Reasoner.apply(:rdfs, :owl)
graph = RDF::Graph.load("etc/doap.ttl")
graph.enum_statement.entail.count # >= graph.enum_statement.count

Dependencies

Mailing List

Authors

Contributing

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying {file:UNLICENSE} file.