-
Notifications
You must be signed in to change notification settings - Fork 0
OwlThing
OwlThing is an Object Relational Mapping around the OWL class “Thing.” The ActiveSesame::OwlThing class can be instantiated to create new triples that are of rdf:type owl:Thing. It uses the ActiveSesame::Ontology::Term class to create new triples that can be saved to the triple store. OwlThing can also be used as a parent of a class to create a new Term that is the owl:subClassOf owl:Thing. Below are examples of how to use this class to build an ontology.
Though the w3c recommendation does not dictate how to create ontologies there are some obvious standards that describe a general framework. One of these standards is the rdf:type property and owl:Thing. owl:Thing is a starting point for anything you might want to represent in your mathematical graph. It’s not required that you use them, but it’s not a bad idea. You can think of owl:Thing as a ruby class (which it is in our case) and anything that is an owl thing as an instance or, in semantic web language, an individual. Creating owl:Thing individuals can be done like this:
# Examine the structure of OwlThing (not needed to use it): # OwlThing, its instances and any sub classes will have a term object associated with them ActiveSesame::OwlThing #The abstract class that represents owl:Thing ActiveSesame::OwlThing.term #The term object (based on ActiveSesame::Ontology::Term) in the triples store ActiveSesame::OwlThing.term.term #The string "owl:thing" (might not be prefix notation) #Creating an Individual of OwlThing thing = ActiveSesame::OwlThing.new #Create an "individual" which has an rdf:type of owl:Thing thing.term # The term object created to represent the individual thing.term.term # the unique uri created for this individual (this can be changed using the :uri => "my_uri" option on new) thing.unsaved_triples # The triples created automatically when thing was instantiated that have yet to be saved to the triple store
rdfs:subClassOf is a standard property to define a sub class relationship. To create a subclass relationship using OwlThing use the following code:
class Book < ActiveSesame::OwlThing end Book.term #The term object created for the Book class Book.term.unsaved_triples # A list of triples that were created automatically when the class inherited from OwlThing enders_game = Book.new(:uri => "base:EndersGame") enders_game.term # The term object created for the book instance enders_game.term.unsaved_triples # The triples that were automatically created from the instantiation of book.
Now that a new class was created based on OwlThing you can continue to subclass it. The triples generated (but not saved) will reflect the sub classing. In the case below a triple will be created as base:FictionNovel rdfs:subClassOf base:Book.
class FictionNovel < ActiveSesame::OwlThing end FictionNovel.term.unsaved_triples # A list of triples that were created automatically when the class inherited from Book