ch.uzh.ifi.attempto.acewiki.core.ontology
Class Ontology

java.lang.Object
  extended by ch.uzh.ifi.attempto.acewiki.core.ontology.Ontology

public class Ontology
extends java.lang.Object

This class represents an AceWiki ontology which consists of ontology element definitions and of ontological statements. Each ontology element has its own article that consists of ontological statements.

Author:
Tobias Kuhn

Method Summary
protected  int commitSentence(Sentence sentence)
          Commits the sentence.
 boolean contains(OntologyElement ontologyElement)
          Returns true if the given ontology element is contained by the ontology (identity check).
 OntologyElement get(java.lang.String name)
          Returns the ontology element with the given name, or null if there is no such element.
 java.lang.String getACEText(boolean onlyConsistentSubset)
          Returns the complete ontology as one ACE text.
 java.util.List<OntologyElement> getAnswer(Sentence questionSentence)
          Returns a list of ontology elements that answer the given question.
 java.util.List<Concept> getConcepts(Individual ind)
          Returns all concepts the given individual belongs to.
 java.util.List<Individual> getIndividuals(Concept concept)
          Returns all individuals that belong to the given concept.
 java.lang.String getLexiconDef()
          Returns the lexicon definition for all ontology elements in the ACE lexicon format.
 java.lang.String getName()
          Returns the name of the ontology.
 java.util.Collection<OntologyElement> getOntologyElements()
          Returns all ontology elements.
 org.semanticweb.owl.model.OWLOntology getOWLOntology(boolean onlyConsistentSubset)
          Returns an OWL ontology object that contains the complete ontology.
 java.lang.String getOWLOntologyAsXML(boolean onlyConsistentSubset)
          Returns the complete ontology as an OWL/XML formatted string.
 java.util.List<Sentence> getReferences(OntologyElement element)
          Returns all the sentences that use the given ontology element (no matter which word form is used).
 java.util.List<Sentence> getReferences(OntologyElement element, int wordNumber)
          Returns all the sentences that use the given word form (by word number) of the given ontology element.
 java.util.List<Concept> getSubConcepts(Concept concept)
          Returns all the sub-concepts of the given concept.
 java.util.List<Concept> getSuperConcepts(Concept concept)
          Returns all super-concepts of the given concept.
 java.lang.String getURI()
          Returns the URI of the ontology (baseURI + name).
 boolean isConsistent()
          Returns true if the ontology is consistent.
 boolean isSatisfiable(Concept concept)
          Checks if the given concept is satisfiable.
static Ontology loadOntology(java.lang.String name, java.lang.String baseURI)
          Loads an ontology (or creates an empty ontology if the ontology cannot be found).
 org.semanticweb.owl.model.OWLOntology readOWLOntology(java.lang.String owlxml)
          Uses the ontology manager to read an OWL ontology from a string (that contains an ontology in OWL-XML format).
 void remove(OntologyElement element)
          Removes the given ontology element from the ontology.
protected  void retractSentence(Sentence sentence)
          Retracts the sentence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadOntology

public static Ontology loadOntology(java.lang.String name,
                                    java.lang.String baseURI)
Loads an ontology (or creates an empty ontology if the ontology cannot be found). The complete URI of the ontology is baseURI + name.

Parameters:
name - The name of the ontology.
baseURI - The base URI that is used to identify the ontology elements.
Returns:
The loaded ontology.

remove

public void remove(OntologyElement element)
Removes the given ontology element from the ontology.

Parameters:
element - The ontology element to be removed.

getReferences

public java.util.List<Sentence> getReferences(OntologyElement element,
                                              int wordNumber)
Returns all the sentences that use the given word form (by word number) of the given ontology element.

Parameters:
element - The ontology element.
wordNumber - The word number.
Returns:
A list of all sentence that contain the word.

getReferences

public java.util.List<Sentence> getReferences(OntologyElement element)
Returns all the sentences that use the given ontology element (no matter which word form is used).

Parameters:
element - The ontology element.
Returns:
A list of all sentence that contain the ontology element.

get

public OntologyElement get(java.lang.String name)
Returns the ontology element with the given name, or null if there is no such element.

Parameters:
name - The name of the ontology element.
Returns:
The ontology element.

getOntologyElements

public java.util.Collection<OntologyElement> getOntologyElements()
Returns all ontology elements.

Returns:
A collection of all ontology elements.

contains

public boolean contains(OntologyElement ontologyElement)
Returns true if the given ontology element is contained by the ontology (identity check).

Parameters:
ontologyElement - The ontology element.
Returns:
true if the ontology element is contained by the ontology.

getName

public java.lang.String getName()
Returns the name of the ontology.

Returns:
The name of the ontology.

getURI

public java.lang.String getURI()
Returns the URI of the ontology (baseURI + name).

Returns:
The URI of the ontology.

getOWLOntologyAsXML

public java.lang.String getOWLOntologyAsXML(boolean onlyConsistentSubset)
Returns the complete ontology as an OWL/XML formatted string.

Parameters:
onlyConsistentSubset - If true then only the consistent part of the ontology is included.
Returns:
A string that contains the complete ontology in OWL/XML format.

getOWLOntology

public org.semanticweb.owl.model.OWLOntology getOWLOntology(boolean onlyConsistentSubset)
Returns an OWL ontology object that contains the complete ontology.

Parameters:
onlyConsistentSubset - If true then only the consistent part of the ontology is included.
Returns:
An OWL ontology object containing the complete ontology.

getACEText

public java.lang.String getACEText(boolean onlyConsistentSubset)
Returns the complete ontology as one ACE text.

Parameters:
onlyConsistentSubset - If true then only the consistent part of the ontology is included.
Returns:
A string that contains the complete ontology as an ACE text.

getLexiconDef

public java.lang.String getLexiconDef()
Returns the lexicon definition for all ontology elements in the ACE lexicon format.

Returns:
A string that contains the lexicon definition.

readOWLOntology

public org.semanticweb.owl.model.OWLOntology readOWLOntology(java.lang.String owlxml)
                                                      throws org.semanticweb.owl.model.OWLOntologyCreationException
Uses the ontology manager to read an OWL ontology from a string (that contains an ontology in OWL-XML format).

Parameters:
owlxml - The serialized OWL-XML ontology.
Returns:
The OWL ontology object.
Throws:
org.semanticweb.owl.model.OWLOntologyCreationException - If the string cannot be parsed.

commitSentence

protected int commitSentence(Sentence sentence)
Commits the sentence. This means that it is added to the reasoner. An integer value is returned that denotes the success or failure of the operation: 0 is returned if the operation succeeds. 1 is returned if it fails because the sentence introduces inconsistency into the knowledge base. 2 is returned if the reasoner runs out of memory (this can occur sometimes with large ontologies).

Parameters:
sentence - The sentence to be commited.
Returns:
An integer value denoting the success/failure of the operation.

retractSentence

protected void retractSentence(Sentence sentence)
Retracts the sentence. This means that the sentence is removed from the reasoner.

Parameters:
sentence - The sentence to be retracted.

getConcepts

public java.util.List<Concept> getConcepts(Individual ind)
Returns all concepts the given individual belongs to. The reasoner is used for this.

Parameters:
ind - The individual.
Returns:
A list of all concepts of the individual.
See Also:
Individual.getConcepts()

getIndividuals

public java.util.List<Individual> getIndividuals(Concept concept)
Returns all individuals that belong to the given concept. The reasoner is used for this.

Parameters:
concept - The concept.
Returns:
A list of all individuals of the concept.
See Also:
Concept.getIndividuals()

getSuperConcepts

public java.util.List<Concept> getSuperConcepts(Concept concept)
Returns all super-concepts of the given concept. The reasoner is used for this.

Parameters:
concept - The concept for which all super-concepts should be returned.
Returns:
A list of all super-concepts.
See Also:
Concept.getSuperConcepts()

getSubConcepts

public java.util.List<Concept> getSubConcepts(Concept concept)
Returns all the sub-concepts of the given concept. The reasoner is used for this.

Parameters:
concept - The concept for which all sub-concepts should be returned.
Returns:
A list of all sub-concepts.
See Also:
Concept.getSubConcepts()

getAnswer

public java.util.List<OntologyElement> getAnswer(Sentence questionSentence)
Returns a list of ontology elements that answer the given question. The reasoner is used for this. In the case the sentence has the form "what is (Individual)?" then the answer contains all concepts the individual belongs to. Otherwise, the question is processed as a "DL Query" that describes a concept. In this case, the answer consists of all individuals that belong to the concept. The null value is returned if the sentence is not a question.

Parameters:
questionSentence - The question sentence that should be answered.
Returns:
A list of ontology elements that are the answer for the question.
See Also:
Sentence.getAnswer()

isConsistent

public boolean isConsistent()
Returns true if the ontology is consistent. If nothing goes wrong, this should always return true. The reasoner is used for this.

Returns:
true if the ontology is consistent.

isSatisfiable

public boolean isSatisfiable(Concept concept)
Checks if the given concept is satisfiable. The reasoner is used for this.

Parameters:
concept - The concept.
Returns:
true if the concept is satisfiable.


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)