Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Clone this wiki locally
The ActiveSesame::Ontology::Term is an object relational mapping for ontology terms. Given an ontology term it will query the triple store to find all relationships of that term.
When an ontology term is instantiated it runs a sparql statement to find all relationships and terms related to the given term. It stores the results in a relationship map which can be accessed by the relationship_map method. All methods called on the term try to find the method name in the relationship map and return an ontology term built on the related term. Man that’s confusing without seeing it…
term = ActiveSesame::Ontology::Term.new("http://fakeontology.org/ontology#myTerm") # Runs a sparql query to find all relationships related to this term on the default repository term.relationships # returns a list of all the relationships found by the sparql query term.relationship_map # returns a hash of where the key is the relationship and the value is the related ontology term term.relation1 # returns an ontology term built on the value of the relation1 in the relationship_map
The sparql query is run on initialization and memoized until the reset method is called. When chaining methods relationship calls are memoized as well.
term.relationships #Does not rerun the sparql term.relation1 #Get the term referred to in this relationship term.relation1.relation2 #Get the term referred to by "relation2" on the term referred to by relation1 on term term.relation1.relation3 # This does not rerun the sparql for term or relation1 term.reset # Resets all memoization