info.ephyra.search
Class Result

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

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

A Result is a data structure representing a result returned by the QA engine.

It comprises the following elements:

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 answer
          The answer string.
private  java.lang.String cacheID
          The ID of the document in the search engine cache (optional).
private  boolean correct
          A flag indicating whether the answer was judged correct (optional).
private  java.util.ArrayList<java.lang.String> coveredNuggets
          If this is an answer to an 'other' question, list to keep the IDs of covered nugget (optional).
private  java.lang.String docID
          The ID (e.g. a URL) of a document containing the answer (optional).
private  java.lang.String[] extractionTechniques
          If this is a factoid answer, the techniques used to extract it (optional).
private  java.util.HashMap<java.lang.String,java.lang.Float> extraScores
          Hashmap holding intermediate scores so they don't influence sorting
private  int hitPos
          The hit position of the answer, starting from 0 (optional).
private  java.util.Map<java.lang.String,java.lang.String[]> nes
          If this is a sentence-level answer, named entities extracted from the sentence and their types (optional).
private  java.lang.String[] neTypes
          If this is a factoid answer, the named entity types (optional).
private  float normScore
          A normalized confidence measure for the answer (optional).
private  Predicate predicate
          If this is a sentence-level answer, a predicate extracted from the sentence (optional).
private  Query query
          The Query that was used to obtain the answer (optional).
private  float score
          A confidence measure for the answer, initially 0.
private  java.lang.String sentence
          If this is a factoid answer, a sentence in the supporting document the answer was extracted from (optional).
private static long serialVersionUID
          Version number used during deserialization.
private  Term[] terms
          If this is a sentence-level answer, terms extracted from the sentence (optional).
 
Constructor Summary
Result(java.lang.String answer)
          Creates a Result object and sets the answer string.
Result(java.lang.String answer, Query query)
          Creates a Result object and sets the answer string and the Query that was used to obtain the answer.
Result(java.lang.String answer, Query query, java.lang.String docID)
          Creates a Result object and sets the answer string, the Query that was used to obtain the answer and the ID of a document that contains it.
Result(java.lang.String answer, Query query, java.lang.String docID, int hitPos)
          Creates a Result object and sets the answer string, the Query that was used to obtain the answer, the ID of a document that contains it and the hit position.
 
Method Summary
 void addCoveredNuggetID(java.lang.String nuggetID)
          Adds the ID of a nugget covered by an answer to an 'other' question.
 boolean addExtractionTechnique(java.lang.String technique)
          Adds an answer extraction technique for a factoid answer.
 void addExtraScore(java.lang.String sourceName, float score)
          add an extra score to this Result for storage, extra score will not influence sorting
 boolean addNeType(java.lang.String neType)
          Adds a named entity type for a factoid answer.
 int compareTo(Result result)
          Compares two results by comparing their scores.
 boolean equals(java.lang.Object o)
          Indicates whether an other result is equal to this one.
 boolean extractedWith(java.lang.String technique)
          Checks if a factoid answer was extracted with the given technique.
 java.lang.String getAnswer()
          Returns the answer string.
 java.lang.String getCacheID()
          Returns the ID of the document in the search engine cache or null if it is not set.
 Result getCopy()
          Returns a copy of this Result object.
 java.lang.String[] getCoveredNuggetIDs()
          Returns the IDs of all nuggets covered by an answer to an 'other' question.
 java.lang.String getDocID()
          Returns the ID of a document that contains the answer or null if it is not set.
 java.lang.String[] getExtractionTechniques()
          Returns the techniques a factoid answer was extracted with.
 float getExtraScore(java.lang.String sourceName)
          retrieve the extra score set by some source
 float[] getExtraScores()
          retrieve all extra scores set for this Result
 int getHitPos()
          Returns the hit position of the result, starting from 0, or -1 if it is not set.
 java.util.Map<java.lang.String,java.lang.String[]> getNes()
          Returns named entities extracted from a sentence-level answer and their types.
 java.lang.String[] getNeTypes()
          Gets the named entity types if the answer is a named entity.
 float getNormScore()
          Returns the normalized score of the result.
 Predicate getPredicate()
          Returns a predicate extracted from a sentence-level answer.
 Query getQuery()
          Returns the Query that was used to obtain this result, or null if it is not set.
 float getScore()
          Returns the confidence score of the result.
 java.lang.String getSentence()
          Returns the supporting sentence of a factoid answer.
 Term[] getTerms()
          Returns terms extracted from a sentence-level answer.
 int hashCode()
          Returns the hash code of the answer string as a hash code for the result.
 void incScore(float value)
          Increments the confidence score by the given value.
 boolean isCorrect()
          Checks if the answer was judged correct.
 boolean isNamedEntity()
          Checks if a factoid answer is a named entity.
 void setAnswer(java.lang.String answer)
          Sets the answer string.
 void setCacheID(java.lang.String cacheID)
          Sets the ID of the document in the search engine cache.
 void setCorrect()
          Judges the answer as correct.
 void setDocID(java.lang.String docID)
          Sets the ID of a document that contains the answer.
 void setExtractionTechniques(java.lang.String[] techniques)
          Sets the techniques a factoid answer was extracted with.
 void setNes(java.util.Map<java.lang.String,java.lang.String[]> nes)
          Sets named entities extracted from a sentence-level answer and their types.
 void setNormScore(float normScore)
          Sets the normalized score of this result.
 void setPredicate(Predicate predicate)
          Sets a predicate extracted from a sentence-level answer.
 void setScore(float score)
          Sets the confidence score of this result.
 void setSentence(java.lang.String sentence)
          Sets the supporting sentence of a factoid answer.
 void setTerms(Term[] terms)
          Sets terms extracted from a sentence-level answer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Version number used during deserialization.

See Also:
Constant Field Values

answer

private java.lang.String answer
The answer string.


score

private float score
A confidence measure for the answer, initially 0.


normScore

private float normScore
A normalized confidence measure for the answer (optional).


query

private Query query
The Query that was used to obtain the answer (optional).


docID

private java.lang.String docID
The ID (e.g. a URL) of a document containing the answer (optional).


cacheID

private java.lang.String cacheID
The ID of the document in the search engine cache (optional).


hitPos

private int hitPos
The hit position of the answer, starting from 0 (optional).


correct

private boolean correct
A flag indicating whether the answer was judged correct (optional).


extraScores

private java.util.HashMap<java.lang.String,java.lang.Float> extraScores
Hashmap holding intermediate scores so they don't influence sorting


nes

private java.util.Map<java.lang.String,java.lang.String[]> nes
If this is a sentence-level answer, named entities extracted from the sentence and their types (optional).


terms

private Term[] terms
If this is a sentence-level answer, terms extracted from the sentence (optional).


predicate

private Predicate predicate
If this is a sentence-level answer, a predicate extracted from the sentence (optional).


sentence

private java.lang.String sentence
If this is a factoid answer, a sentence in the supporting document the answer was extracted from (optional).


neTypes

private java.lang.String[] neTypes
If this is a factoid answer, the named entity types (optional).


extractionTechniques

private java.lang.String[] extractionTechniques
If this is a factoid answer, the techniques used to extract it (optional).


coveredNuggets

private java.util.ArrayList<java.lang.String> coveredNuggets
If this is an answer to an 'other' question, list to keep the IDs of covered nugget (optional).

Constructor Detail

Result

public Result(java.lang.String answer)
Creates a Result object and sets the answer string.

Parameters:
answer - answer string

Result

public Result(java.lang.String answer,
              Query query)
Creates a Result object and sets the answer string and the Query that was used to obtain the answer.

Parameters:
answer - answer string
query - Query object

Result

public Result(java.lang.String answer,
              Query query,
              java.lang.String docID)
Creates a Result object and sets the answer string, the Query that was used to obtain the answer and the ID of a document that contains it.

Parameters:
answer - answer string
query - Query object
docID - document ID

Result

public Result(java.lang.String answer,
              Query query,
              java.lang.String docID,
              int hitPos)
Creates a Result object and sets the answer string, the Query that was used to obtain the answer, the ID of a document that contains it and the hit position.

Parameters:
answer - answer string
query - Query object
docID - document ID
hitPos - hit position, starting from 0
Method Detail

compareTo

public int compareTo(Result result)
Compares two results by comparing their scores.

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

equals

public boolean equals(java.lang.Object o)
Indicates whether an other result is equal to this one. Two results are considered equal if the answer strings are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to be compared
Returns:
true iff the objects are equal

hashCode

public int hashCode()
Returns the hash code of the answer string as a hash code for the result.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code

getAnswer

public java.lang.String getAnswer()
Returns the answer string.

Returns:
answer string

getScore

public float getScore()
Returns the confidence score of the result.

Returns:
confidence score

getNormScore

public float getNormScore()
Returns the normalized score of the result.

Returns:
normalized score

getQuery

public Query getQuery()
Returns the Query that was used to obtain this result, or null if it is not set.

Returns:
Query used to obtain this result or null

getDocID

public java.lang.String getDocID()
Returns the ID of a document that contains the answer or null if it is not set.

Returns:
document ID or null

getCacheID

public java.lang.String getCacheID()
Returns the ID of the document in the search engine cache or null if it is not set.

Returns:
ID of the cached document or null

getHitPos

public int getHitPos()
Returns the hit position of the result, starting from 0, or -1 if it is not set.

Returns:
hit position or -1

isCorrect

public boolean isCorrect()
Checks if the answer was judged correct.

Returns:
true iff the answer was judged as correct

getNes

public java.util.Map<java.lang.String,java.lang.String[]> getNes()
Returns named entities extracted from a sentence-level answer and their types.

Returns:
NEs or null if no NEs have been extracted

getTerms

public Term[] getTerms()
Returns terms extracted from a sentence-level answer.

Returns:
terms or null if no terms have been extracted

getPredicate

public Predicate getPredicate()
Returns a predicate extracted from a sentence-level answer.

Returns:
predicate or null if no predicate has been extracted

getSentence

public java.lang.String getSentence()
Returns the supporting sentence of a factoid answer.

Returns:
supporting sentence or null if it is not set

isNamedEntity

public boolean isNamedEntity()
Checks if a factoid answer is a named entity.

Returns:
true iff the answer is a NE

getNeTypes

public java.lang.String[] getNeTypes()
Gets the named entity types if the answer is a named entity.

Returns:
NE types or null if the answer is not a NE

getExtractionTechniques

public java.lang.String[] getExtractionTechniques()
Returns the techniques a factoid answer was extracted with.

Returns:
answer extraction techniques

extractedWith

public boolean extractedWith(java.lang.String technique)
Checks if a factoid answer was extracted with the given technique.

Parameters:
technique - answer extraction technique
Returns:
true iff the answer was extracted with the technique

getCoveredNuggetIDs

public java.lang.String[] getCoveredNuggetIDs()
Returns the IDs of all nuggets covered by an answer to an 'other' question.

Returns:
IDs of all covered nuggets

setAnswer

public void setAnswer(java.lang.String answer)
Sets the answer string.

Parameters:
answer - the answer string

setScore

public void setScore(float score)
Sets the confidence score of this result.

Parameters:
score - confidence score

incScore

public void incScore(float value)
Increments the confidence score by the given value.

Parameters:
value - the value to be added to the score

setNormScore

public void setNormScore(float normScore)
Sets the normalized score of this result.

Parameters:
normScore - normalized score

setDocID

public void setDocID(java.lang.String docID)
Sets the ID of a document that contains the answer.

Parameters:
docID - document ID

setCacheID

public void setCacheID(java.lang.String cacheID)
Sets the ID of the document in the search engine cache.

Parameters:
cacheID - ID of the cached document

setCorrect

public void setCorrect()
Judges the answer as correct.


setNes

public void setNes(java.util.Map<java.lang.String,java.lang.String[]> nes)
Sets named entities extracted from a sentence-level answer and their types.

Parameters:
nes - NEs and their types

setTerms

public void setTerms(Term[] terms)
Sets terms extracted from a sentence-level answer.

Parameters:
terms - terms extracted from a sentence

setPredicate

public void setPredicate(Predicate predicate)
Sets a predicate extracted from a sentence-level answer.

Parameters:
predicate - predicate extracted from a sentence

setSentence

public void setSentence(java.lang.String sentence)
Sets the supporting sentence of a factoid answer.

Parameters:
sentence - supporting sentence

addNeType

public boolean addNeType(java.lang.String neType)
Adds a named entity type for a factoid answer.

Parameters:
neType - NE type
Returns:
true if a new type was added

setExtractionTechniques

public void setExtractionTechniques(java.lang.String[] techniques)
Sets the techniques a factoid answer was extracted with.

Parameters:
techniques - answer extraction techniques

addExtractionTechnique

public boolean addExtractionTechnique(java.lang.String technique)
Adds an answer extraction technique for a factoid answer.

Parameters:
technique - answer extraction technique
Returns:
true iff a new technique was added

addCoveredNuggetID

public void addCoveredNuggetID(java.lang.String nuggetID)
Adds the ID of a nugget covered by an answer to an 'other' question.

Parameters:
nuggetID - ID of the nugget to add

getCopy

public Result getCopy()
Returns a copy of this Result object.

Returns:
copy of this object

addExtraScore

public void addExtraScore(java.lang.String sourceName,
                          float score)
add an extra score to this Result for storage, extra score will not influence sorting

Parameters:
sourceName - the name of the source of the score
score - the value of the score

getExtraScore

public float getExtraScore(java.lang.String sourceName)
retrieve the extra score set by some source

Parameters:
sourceName - the name of the source who set the required score
Returns:
the extra score set by the source with the specified name, or 0, if the is no suchh extra score

getExtraScores

public float[] getExtraScores()
retrieve all extra scores set for this Result

Returns:
an array holding all the extra scores