com.languagecomputer.api.query
Class DefaultAnswer

java.lang.Object
  extended by com.languagecomputer.api.text.DefaultText
      extended by com.languagecomputer.api.query.DefaultAnswer
All Implemented Interfaces:
Answer, Text

public class DefaultAnswer
extends DefaultText
implements Answer

Default implementation of a Answer. Alternatively, the Answer interface may be implemented in order to be backed by a different mechanism (i.e., for speed and/or memory performance based on the individual system).

Since:
1.0
Author:
Kirk Roberts

Field Summary
 
Fields inherited from interface com.languagecomputer.api.query.Answer
TYPE
 
Constructor Summary
DefaultAnswer()
          Creates a new DefaultAnswer.
 
Method Summary
 double getConfidence()
          Returns the confidence of this Answer in the range of (0.0-1.0] (optional).
 String getDocumentID()
          Returns the Document ID that identifies this Text. If the Document is attached to this DefaultAnswer, then its ID will be used.
 String getPassage()
          Returns the passage context of this Answer.
 void setAnnotationType(AnnotationType annType)
          Not necessary: defaults to Answer.TYPE.
 void setConfidence(double confidence)
          Sets the confidence to use for this DefaultAnswer.
 void setDocumentID(String docID)
          Explicitly sets the document ID for when no Document is attached to this DefaultAnswer.
 void setPassage(String passage)
          Sets the passage to use for this DefaultAnswer.
 
Methods inherited from class com.languagecomputer.api.text.DefaultText
getAnnotationType, getCongruentAnnotations, getDocument, getEndCharOffset, getIntersectingAnnotations, getRawString, getStartCharOffset, getSubAnnotations, getSuperAnnotations, setDocument, setEndCharOffset, setRawString, setStartCharOffset, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.languagecomputer.api.text.Text
getAnnotationType, getCongruentAnnotations, getDocument, getEndCharOffset, getIntersectingAnnotations, getRawString, getStartCharOffset, getSubAnnotations, getSuperAnnotations
 

Constructor Detail

DefaultAnswer

public DefaultAnswer()
Creates a new DefaultAnswer.

Method Detail

setAnnotationType

public void setAnnotationType(AnnotationType annType)
Not necessary: defaults to Answer.TYPE.

Overrides:
setAnnotationType in class DefaultText
Parameters:
annType - AnnotationType to use for this DefaultEntity.
See Also:
Text.getAnnotationType(), AnnotationType

setConfidence

public void setConfidence(double confidence)
Sets the confidence to use for this DefaultAnswer.

Parameters:
answer - Answer confidence/relevance/weight/score/etc, must be within the range (0.0-1.0].
Throws:
IllegalArgumentException - If the confidence does not fall within the expected range.
See Also:
getConfidence()

getConfidence

public double getConfidence()
Returns the confidence of this Answer in the range of (0.0-1.0] (optional). Confidence can be considered as relevance, score, or any other metric used to rank answers.

Specified by:
getConfidence in interface Answer
Returns:
The confidence/weight/relevance/score of this Answer.

setDocumentID

public void setDocumentID(String docID)
Explicitly sets the document ID for when no Document is attached to this DefaultAnswer. When serialized, the Document is dropped for performance, so the document ID is needed to retrieve the document when/if necessary.

See Also:
getDocumentID()

getDocumentID

public String getDocumentID()
Returns the Document ID that identifies this Text. If the Document is attached to this DefaultAnswer, then its ID will be used. Otherwise, the ID set by setDocumentID(String) is used.

Specified by:
getDocumentID in interface Text
Overrides:
getDocumentID in class DefaultText
Returns:
The ID for the Document that contains this Text.

setPassage

public void setPassage(String passage)
Sets the passage to use for this DefaultAnswer.

Parameters:
passage - The passage String.
See Also:
getPassage()

getPassage

public String getPassage()
Returns the passage context of this Answer. For passage-style answers, this may either be equal to the Text.getRawString() or have even more context. For exact-style answers, getRawString returns the exact answer while this method returns the context.

Specified by:
getPassage in interface Answer


Copyright © 2009. All Rights Reserved.