<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;&lt;a name=&quot;ActiveSesame::Ontology::Term&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Ontology::Term&lt;/h2&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;h3&gt;Relationships&lt;/h3&gt;
&lt;p&gt;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&amp;#8217;s confusing without seeing it&amp;#8230;&lt;/p&gt;

&lt;pre&gt;
term = ActiveSesame::Ontology::Term.new(&quot;http://fakeontology.org/ontology#myTerm&quot;) # 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
&lt;/pre&gt;
&lt;h3&gt;Memoization&lt;/h3&gt;
&lt;p&gt;The sparql query is run on initialization and memoized until the reset method is called.  When chaining methods relationship calls are memoized as well.&lt;/p&gt;
&lt;pre&gt;
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 &quot;relation2&quot; 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
&lt;/pre&gt;
&lt;h3&gt;Creating Triples&lt;/h3&gt;
&lt;p&gt;place holder&lt;/p&gt;</body>
  <created-at type="datetime">2009-11-27T00:45:09-08:00</created-at>
  <id type="integer">263248</id>
  <permalink>ontology</permalink>
  <repository-id type="integer">11798</repository-id>
  <title>Ontology</title>
  <updated-at type="datetime">2009-11-02T04:54:06-08:00</updated-at>
  <user-id type="integer">8178</user-id>
</wiki>
