ch.uzh.ifi.attempto.acewiki.core
Class CachingReasoner

java.lang.Object
  extended by ch.uzh.ifi.attempto.acewiki.core.CachingReasoner
All Implemented Interfaces:
AceWikiReasoner

public class CachingReasoner
extends java.lang.Object
implements AceWikiReasoner

This reasoner class wraps another reasoner and adds caching functionality.

Author:
Tobias Kuhn

Method Summary
 boolean areCachedConceptsUpToDate(Individual ind)
          Returns true if the concepts of the given individual are cached and up-to-date and thus do not have to be recalculated.
 boolean areCachedIndividualsUpToDate(Concept concept)
          Returns true if the individuals of the given concept are cached and up-to-date and thus do not have to be recalculated.
 boolean areCachedSubConceptsUpToDate(Concept concept)
          Returns true if the sub-concepts of the given concept are cached and up-to-date and thus do not have to be recalculated.
 boolean areCachedSuperConceptsUpToDate(Concept concept)
          Returns true if the suber-concepts of the given concept are cached and up-to-date and thus do not have to be recalculated.
 void flushElements()
          This method can finalize the loading or unloading of elements.
 java.util.List<AnswerElement> getAnswer(Question question)
          Returns the answer for the given question.
 java.util.List<AnswerElement> getCachedAnswer(Question question)
          Returns the cached answer for the given question, or null if no cached answer exists.
 java.util.List<Concept> getCachedConcepts(Individual ind)
          Returns the cached concepts for the given individual or null if there are no cached concepts.
 java.util.List<Individual> getCachedIndividuals(Concept concept)
          Returns the cached individuals for the given concept or null if there are no cached individuals.
 java.util.List<Concept> getCachedSubConcepts(Concept concept)
          Returns the cached sub-concepts for the given concept or null if there are no cached sub-concepts.
 java.util.List<Concept> getCachedSuperConcepts(Concept concept)
          Returns the cached super-concepts for the given concept or null if there are no cached super-concepts.
 java.util.List<Concept> getConcepts(Individual ind)
          Should return all concepts the given individual belongs to.
 java.util.List<Individual> getIndividuals(Concept concept)
          Should return all individuals that belong to the given concept.
 java.util.Map<java.lang.String,java.lang.String> getInfo()
          This method can return a map of name/value pairs with information about the reasoner.
 java.lang.String getReasonerName()
          Returns the name of the reasoner.
 java.lang.String getReasonerType()
          Return the type of the reasoner.
 java.lang.String getReasonerVersion()
          Return the version of the reasoner.
 java.util.List<Concept> getSubConcepts(Concept concept)
          Should return all the sub-concepts of the given concept.
 java.util.List<Concept> getSuperConcepts(Concept concept)
          Should return all super-concepts of the given concept.
 AceWikiReasoner getWrappedReasoner()
          Returns the wrapped reasoner.
 void init(Ontology ontology)
          This is the first method to be called and provides the ontology object.
 boolean isCachedAnswerUpToDate(Question question)
          Returns whether the there is an up-to-date cached answer for the given question.
 boolean isConsistent()
          Should return true if the ontology is consistent.
 boolean isSatisfiable(Concept concept)
          Should check if the given concept is satisfiable.
 void load()
          Loads the reasoner or reasoner interface.
 void loadElement(OntologyElement element)
          Loads the given ontology element.
 void loadSentence(Sentence sentence)
          Loads the given sentence.
 void unloadElement(OntologyElement element)
          Unloads the given ontology element.
 void unloadSentence(Sentence sentence)
          Unloads the given sentence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public void init(Ontology ontology)
Description copied from interface: AceWikiReasoner
This is the first method to be called and provides the ontology object.

Specified by:
init in interface AceWikiReasoner
Parameters:
ontology - The ontology object.

getWrappedReasoner

public AceWikiReasoner getWrappedReasoner()
Returns the wrapped reasoner.

Returns:
The wrapped reasoner.

isCachedAnswerUpToDate

public boolean isCachedAnswerUpToDate(Question question)
Returns whether the there is an up-to-date cached answer for the given question.

Parameters:
question - The question.
Returns:
true if there is an up-to-date cached answer.

getCachedAnswer

public java.util.List<AnswerElement> getCachedAnswer(Question question)
Returns the cached answer for the given question, or null if no cached answer exists. The answer might not be up-to-date.

Parameters:
question - The question.
Returns:
The cached answer.

getAnswer

public java.util.List<AnswerElement> getAnswer(Question question)
Returns the answer for the given question. The cache is used if it is up-to-date.

Specified by:
getAnswer in interface AceWikiReasoner
Parameters:
question - The question to be answered.
Returns:
A list of ontology elements that are the answer to the question.

areCachedConceptsUpToDate

public boolean areCachedConceptsUpToDate(Individual ind)
Returns true if the concepts of the given individual are cached and up-to-date and thus do not have to be recalculated.

Parameters:
ind - The individual.
Returns:
true if the cached concepts are up-to-date.

getCachedConcepts

public java.util.List<Concept> getCachedConcepts(Individual ind)
Returns the cached concepts for the given individual or null if there are no cached concepts. The returned concepts might not be up-to-date.

Parameters:
ind - The individual.
Returns:
A list of the cached concepts for the given individual.

getConcepts

public java.util.List<Concept> getConcepts(Individual ind)
Description copied from interface: AceWikiReasoner
Should return all concepts the given individual belongs to.

Specified by:
getConcepts in interface AceWikiReasoner
Parameters:
ind - The individual.
Returns:
A list of all concepts of the individual.

areCachedIndividualsUpToDate

public boolean areCachedIndividualsUpToDate(Concept concept)
Returns true if the individuals of the given concept are cached and up-to-date and thus do not have to be recalculated.

Parameters:
concept - The concept.
Returns:
true if the cached individuals are up-to-date.

getCachedIndividuals

public java.util.List<Individual> getCachedIndividuals(Concept concept)
Returns the cached individuals for the given concept or null if there are no cached individuals. The returned individuals might not be up-to-date.

Parameters:
concept - The concept.
Returns:
A list of the cached individuals for the given concept.

getIndividuals

public java.util.List<Individual> getIndividuals(Concept concept)
Description copied from interface: AceWikiReasoner
Should return all individuals that belong to the given concept.

Specified by:
getIndividuals in interface AceWikiReasoner
Parameters:
concept - The concept.
Returns:
A list of all individuals of the concept.

areCachedSuperConceptsUpToDate

public boolean areCachedSuperConceptsUpToDate(Concept concept)
Returns true if the suber-concepts of the given concept are cached and up-to-date and thus do not have to be recalculated.

Parameters:
concept - The concept.
Returns:
true if the cached super-concepts are up-to-date.

getCachedSuperConcepts

public java.util.List<Concept> getCachedSuperConcepts(Concept concept)
Returns the cached super-concepts for the given concept or null if there are no cached super-concepts. The returned super-concepts might not be up-to-date.

Parameters:
concept - The concept.
Returns:
A list of the cached super-concepts for the given concept.

getSuperConcepts

public java.util.List<Concept> getSuperConcepts(Concept concept)
Description copied from interface: AceWikiReasoner
Should return all super-concepts of the given concept.

Specified by:
getSuperConcepts in interface AceWikiReasoner
Parameters:
concept - The concept for which all super-concepts should be returned.
Returns:
A list of all super-concepts.

areCachedSubConceptsUpToDate

public boolean areCachedSubConceptsUpToDate(Concept concept)
Returns true if the sub-concepts of the given concept are cached and up-to-date and thus do not have to be recalculated.

Parameters:
concept - The concept.
Returns:
true if the cached sub-concepts are up-to-date.

getCachedSubConcepts

public java.util.List<Concept> getCachedSubConcepts(Concept concept)
Returns the cached sub-concepts for the given concept or null if there are no cached sub-concepts. The returned sub-concepts might not be up-to-date.

Parameters:
concept - The concept.
Returns:
A list of the cached sub-concepts for the given concept.

getSubConcepts

public java.util.List<Concept> getSubConcepts(Concept concept)
Description copied from interface: AceWikiReasoner
Should return all the sub-concepts of the given concept.

Specified by:
getSubConcepts in interface AceWikiReasoner
Parameters:
concept - The concept for which all sub-concepts should be returned.
Returns:
A list of all sub-concepts.

getReasonerName

public java.lang.String getReasonerName()
Returns the name of the reasoner.

Specified by:
getReasonerName in interface AceWikiReasoner
Returns:
The name of the reasoner.

getReasonerVersion

public java.lang.String getReasonerVersion()
Return the version of the reasoner.

Specified by:
getReasonerVersion in interface AceWikiReasoner
Returns:
The version of the reasoner.

getReasonerType

public java.lang.String getReasonerType()
Return the type of the reasoner.

Specified by:
getReasonerType in interface AceWikiReasoner
Returns:
The reasoner type.

getInfo

public java.util.Map<java.lang.String,java.lang.String> getInfo()
Description copied from interface: AceWikiReasoner
This method can return a map of name/value pairs with information about the reasoner. To retain the insertion order, a map implementation like LinkedHashMap should be used. It is allowed to return null for no information.

Specified by:
getInfo in interface AceWikiReasoner
Returns:
A map of name/value pairs with reasoner information.

load

public void load()
Loads the reasoner or reasoner interface.

Specified by:
load in interface AceWikiReasoner

loadElement

public void loadElement(OntologyElement element)
Description copied from interface: AceWikiReasoner
Loads the given ontology element. The method flushElements is called after each sequence of one or more loadElement-calls.

Specified by:
loadElement in interface AceWikiReasoner
Parameters:
element - The ontology element.

unloadElement

public void unloadElement(OntologyElement element)
Description copied from interface: AceWikiReasoner
Unloads the given ontology element. The method flushElements is called after each sequence of one or more unloadElement-calls.

Specified by:
unloadElement in interface AceWikiReasoner
Parameters:
element - The ontology element.

isConsistent

public boolean isConsistent()
Description copied from interface: AceWikiReasoner
Should return true if the ontology is consistent.

Specified by:
isConsistent in interface AceWikiReasoner
Returns:
true if the ontology is consistent.

isSatisfiable

public boolean isSatisfiable(Concept concept)
Description copied from interface: AceWikiReasoner
Should check if the given concept is satisfiable.

Specified by:
isSatisfiable in interface AceWikiReasoner
Parameters:
concept - The concept.
Returns:
true if the concept is satisfiable.

loadSentence

public void loadSentence(Sentence sentence)
Description copied from interface: AceWikiReasoner
Loads the given sentence.

Specified by:
loadSentence in interface AceWikiReasoner
Parameters:
sentence - The sentence.

unloadSentence

public void unloadSentence(Sentence sentence)
Description copied from interface: AceWikiReasoner
Unloads the given sentence.

Specified by:
unloadSentence in interface AceWikiReasoner
Parameters:
sentence - The sentence.

flushElements

public void flushElements()
Description copied from interface: AceWikiReasoner
This method can finalize the loading or unloading of elements. It is always called after a sequence of one or more loadElement- or unloadElement-calls.

Specified by:
flushElements in interface AceWikiReasoner


Copyright 2008-2012, AceWiki developers