info.ephyra.questionanalysis
Class QuestionInterpretation

java.lang.Object
  extended by info.ephyra.questionanalysis.QuestionInterpretation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<QuestionInterpretation>

public class QuestionInterpretation
extends java.lang.Object
implements java.lang.Comparable<QuestionInterpretation>, java.io.Serializable

A QuestionInterpretation is a data structure comprising the TARGET of a question, the CONTEXT and the PROPERTY the question asks for.

This class implements the interfaces Comparable and Serializable. Note: it has a natural ordering that is inconsistent with equals().

Version:
2008-01-29
Author:
Nico Schlaefer
See Also:
Serialized Form

Field Summary
private  java.lang.String[] context
          The CONTEXT objects of the question.
private  int length
          The LENGTH of this interpretation.
private  java.lang.String property
          The PROPERTY the question asks for.
private static long serialVersionUID
          Version number used during deserialization.
private  java.lang.String target
          The TARGET object of the question.
 
Constructor Summary
QuestionInterpretation(java.lang.String target, java.lang.String[] context, java.lang.String property)
          Creates a new QuestionInterpretation object and sets the TARGET, CONTEXT, PROPERTY and LENGTH fields.
 
Method Summary
private  void calculateLength()
          Calculates the LENGTH of the QuestionInterpretation, which is defined as the sum of the length of the TARGET object and all CONTEXT objects.
 int compareTo(QuestionInterpretation qi)
          Compares this QuestionInterpretation to another QuestionInterpretation object.
 void dropContext()
          Drops the CONTEXT without recalculating the length.
 java.lang.String[] getContext()
          Returns the CONTEXT of the question.
 int getLength()
          Returns the LENGTH of the interpretation.
 java.lang.String getProperty()
          Returns the PROPERTY that the question asks for.
 java.lang.String getTarget()
          Returns the TARGET of the question.
 void setContext(java.lang.String[] context)
          Sets the CONTEXT of the question.
 void setTarget(java.lang.String target)
          Sets the TARGET of the question.
 java.lang.String toString()
          Returns a string representation of the interpretation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Version number used during deserialization.

See Also:
Constant Field Values

target

private java.lang.String target
The TARGET object of the question.


context

private java.lang.String[] context
The CONTEXT objects of the question.


property

private java.lang.String property
The PROPERTY the question asks for.


length

private int length
The LENGTH of this interpretation.

Constructor Detail

QuestionInterpretation

public QuestionInterpretation(java.lang.String target,
                              java.lang.String[] context,
                              java.lang.String property)
Creates a new QuestionInterpretation object and sets the TARGET, CONTEXT, PROPERTY and LENGTH fields.

Parameters:
target - the TARGET of the question
context - the CONTEXT of the question
property - the PROPERTY that the question asks for
Method Detail

calculateLength

private void calculateLength()

Calculates the LENGTH of the QuestionInterpretation, which is defined as the sum of the length of the TARGET object and all CONTEXT objects.

The smaller the value, the more likely it is that the question was interpreted correctly. A smaller value also means a greater abstraction from the original formulation of the question and therefore the search will return more results.

On the other hand, a large value means - if the search does not fail - a high probability of a correct answer.


getTarget

public java.lang.String getTarget()
Returns the TARGET of the question.

Returns:
TARGET

getContext

public java.lang.String[] getContext()
Returns the CONTEXT of the question.

Returns:
CONTEXT

getProperty

public java.lang.String getProperty()
Returns the PROPERTY that the question asks for.

Returns:
PROPERTY

getLength

public int getLength()
Returns the LENGTH of the interpretation.

Returns:
LENGTH

setTarget

public void setTarget(java.lang.String target)
Sets the TARGET of the question.

Parameters:
target - the TARGET object

setContext

public void setContext(java.lang.String[] context)
Sets the CONTEXT of the question.

Parameters:
context - the CONTEXT objects

dropContext

public void dropContext()
Drops the CONTEXT without recalculating the length.


compareTo

public int compareTo(QuestionInterpretation qi)

Compares this QuestionInterpretation to another QuestionInterpretation object.

Specified by:
compareTo in interface java.lang.Comparable<QuestionInterpretation>
Parameters:
qi - the QuestionInterpretation to be compared
Returns:
a negative integer, zero, or a positive integer as this QuestionInterpretation is less than, equal to, or greater than the specified QuestionInterpretation

toString

public java.lang.String toString()
Returns a string representation of the interpretation.

Overrides:
toString in class java.lang.Object
Returns:
readable string