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

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

public class Sentence
extends Statement

This class represents an ACE sentence which is either a declarative statement or a question. Some declarative sentences can be translated into OWL and can participate in reasoning. Other sentences have no OWL representation and do not participate in reasoning.

ACE sentences can either have an ontology element as owner (in the case of asserted sentences) or it can be an independent statement that has no owner (in the case of inferred sentences).

Parsing of the sentence is done lasily, i.e. at the first time when a parsing result is required. Parsing fails silently. No exceptions are thrown if a sentence is not ACE compliant.

Author:
Tobias Kuhn

Constructor Summary
Sentence(java.lang.String text, Ontology ontology)
          Creates a new inferred sentence.
Sentence(java.lang.String text, OntologyElement owner)
          Creates a new asserted sentence.
 
Method Summary
 boolean contains(OntologyElement e)
          Checks whether the sentence contains the given ontology element (no matter which word form).
 boolean contains(OntologyElement e, int wordNumber)
          Checks whether the sentence contains the given word form (by word number) of the given ontology element.
static java.util.List<Sentence> generateSentences(TextContainer textContainer, OntologyElement owner)
          Generates sentence objects out of a text container.
 java.util.List<OntologyElement> getAnswer()
          Returns all ontology elements that answer this question.
 java.util.List<OntologyElement> getCachedAnswer()
          Returns the cached answer if the sentence is a question.
 org.semanticweb.owl.model.OWLOntology getOWLOntology()
          Returns the OWL ontology object that contains the OWL representation of this sentence.
 java.lang.String getOWLXML()
          Returns the OWL/XML representation of this sentence as a string.
 ACEParserResult getParserResult()
          Returns the parser result object.
 java.lang.String getPrettyText()
          Returns the sentence text as a string with underscores displayed as blanks.
 java.lang.String getText()
          Returns the sentence text as a string.
 java.util.List<TextElement> getTextElements()
          Returns a list of text elements that represent the tokens of this sentence.
 boolean isAnswerCached()
          Returns true if the sentence is a question and the answer to the question is cached and up-to-date and thus does not have to be recalculated.
 boolean isInferred()
          Checks if the sentence is inferred or asserted.
 boolean isIntegrated()
          Returns true if the sentence is integrated into the ontology.
 boolean isOWL()
          Returns true if this sentence has an OWL representation.
 boolean isOWLSWRL()
          Returns true if this sentence has an OWL or SWRL representation.
 boolean isQuestion()
          Returns true if the sentence is a question.
 boolean isReasonerParticipant()
          Returns true if this sentence participates in reasoning.
 int reassert()
          This method tries to reassert a sentence that is not yet integrated.
 java.lang.String toString()
           
 
Methods inherited from class ch.uzh.ifi.attempto.acewiki.core.ontology.Statement
getOntology, getOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sentence

public Sentence(java.lang.String text,
                OntologyElement owner)
Creates a new asserted sentence. Asserted sentences must have an owner.

Parameters:
text - The sentence text.
owner - The owner ontology element.

Sentence

public Sentence(java.lang.String text,
                Ontology ontology)
Creates a new inferred sentence. Inferred sentence have no owner.

Parameters:
text - The sentence text.
ontology - The ontology.
Method Detail

generateSentences

public static java.util.List<Sentence> generateSentences(TextContainer textContainer,
                                                         OntologyElement owner)
Generates sentence objects out of a text container.

Parameters:
textContainer - The text container.
owner - The owner ontology element of the sentences.
Returns:
A list of sentences.

getTextElements

public java.util.List<TextElement> getTextElements()
Returns a list of text elements that represent the tokens of this sentence.

Returns:
A token list.

getText

public java.lang.String getText()
Returns the sentence text as a string. Underscores are used for compound words, e.g. "credit_card".

Specified by:
getText in class Statement
Returns:
The sentence text as a string.

getPrettyText

public java.lang.String getPrettyText()
Returns the sentence text as a string with underscores displayed as blanks. Compound words containing underscores like "credit_cards" are pretty-printed with blank characters: "credit card".

Returns:
The sentence text as a pretty-printed string.

getParserResult

public ACEParserResult getParserResult()
Returns the parser result object.

Returns:
The parser result object.

getOWLXML

public java.lang.String getOWLXML()
Returns the OWL/XML representation of this sentence as a string.

Returns:
The OWL/XML representation.

isReasonerParticipant

public boolean isReasonerParticipant()
Returns true if this sentence participates in reasoning.

Returns:
true if this sentence participates in reasoning.

isOWL

public boolean isOWL()
Returns true if this sentence has an OWL representation.

Returns:
true if this sentence has an OWL representation.

isOWLSWRL

public boolean isOWLSWRL()
Returns true if this sentence has an OWL or SWRL representation.

Returns:
true if this sentence has an OWL or SWRL representation.

getOWLOntology

public org.semanticweb.owl.model.OWLOntology getOWLOntology()
Returns the OWL ontology object that contains the OWL representation of this sentence. Null is returned if there is no OWL representation of this sentence or if the creation of the OWL ontology object failed.

Returns:
The OWL ontology object.

reassert

public int reassert()
This method tries to reassert a sentence that is not yet integrated. This is used for sentences that have an OWL representation but the integration failed because it introduced an inconsistency. Later, when the ontology has changed, the integration might succeed.

Returns:
An integer value denoting the success/failure of the operation.
See Also:
Ontology.commitSentence(Sentence)

isIntegrated

public boolean isIntegrated()
Returns true if the sentence is integrated into the ontology.

Returns:
true if the sentence is integrated into the ontology.

isQuestion

public boolean isQuestion()
Returns true if the sentence is a question.

Returns:
true if the sentence is a question.

isInferred

public boolean isInferred()
Checks if the sentence is inferred or asserted.

Returns:
true if the sentence is inferred, false if it is asserted.

contains

public boolean contains(OntologyElement e,
                        int wordNumber)
Checks whether the sentence contains the given word form (by word number) of the given ontology element.

Parameters:
e - The ontology element.
wordNumber - The word number.
Returns:
true if the word form occurs in this sentence.

contains

public boolean contains(OntologyElement e)
Checks whether the sentence contains the given ontology element (no matter which word form).

Parameters:
e - The ontology element.
Returns:
true if the ontology element occurs in this sentence.

getAnswer

public java.util.List<OntologyElement> getAnswer()
Returns all ontology elements that answer this question. 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.

Returns:
A list of ontology elements that are the answer for the question.
See Also:
Ontology.getAnswer(Sentence)

getCachedAnswer

public java.util.List<OntologyElement> getCachedAnswer()
Returns the cached answer if the sentence is a question. Null is returned if the the sentence is no question or there is no cached answer. This returned answer might not be up-to-date.

Returns:
A list of ontology elements that are the cached answer for the question.

isAnswerCached

public boolean isAnswerCached()
Returns true if the sentence is a question and the answer to the question is cached and up-to-date and thus does not have to be recalculated.

Returns:
true if the answer is cached.

toString

public java.lang.String toString()
Overrides:
toString in class Statement


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