com.fxpal.search
Class DocumentMatch

java.lang.Object
  extended by com.fxpal.search.DocumentMatch

public class DocumentMatch
extends java.lang.Object

An instance of DocumentMatch represents a document in a ranked list of results from a query. Instances are typically created by an Searcher based on the raw search results. The purpose of this class is to abstract search engine-specific postings.

Instances carry enough state to recover the retrieved document in the context of a particular search engine. They also include the score assigned by the ranking algorithm and a RelevanceRating that can be assigned manually. RelevanceRatings are used for relevance feedback by the RevertedQuerying object. By default, a DocumentMatch is neither RELEVANT nor NON_RELEVANT; its value is shown as NOT_JUDGED.

Author:
Gene Golovchinsky (c) 2011 FX Palo Alto Laboratory, Inc.

Nested Class Summary
static class DocumentMatch.RawScoreComparator
          Implements Comparator for DocumentMatch instances based on raw scores.
 
Constructor Summary
DocumentMatch(java.lang.String externalId, long internalId, float rawScore)
          Creates a new instance of DocumentMatch with the specified information.
DocumentMatch(java.lang.String externalId, long internalId, float rawScore, float score, RelevanceRating rating)
          Creates a new instance of DocumentMatch with the specified information, include a relevance judgment.
 
Method Summary
 java.lang.String getDocid()
          Gets the document id of the match.
 long getInternalId()
          Gets the internal id of the retrieved document.
 float getRawScore()
          Gets the score that was assigned to the document in response to a query.
 RelevanceRating getRelevanceRating()
          Gets the relevance rating
 float getScore()
          Gets the score that was assigned to the document in response to a query.
 boolean isNotRelevant()
          Tests whether the associated document has been marked as non-relevant.
 boolean isRelevant()
          Tests whether the associated document has been marked as relevant.
 void setRawScore(float value)
          Sets the score associated with the document.
 void setRelevanceRating(RelevanceRating r)
          Assigns a RelevanceRating value to the instance.
 void setScore(float value)
          Sets the score associated with the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentMatch

public DocumentMatch(java.lang.String externalId,
                     long internalId,
                     float rawScore)
Creates a new instance of DocumentMatch with the specified information. The score is set to 0.0f, and should be updated during a subsequent normalization step.

Parameters:
externalId - External id of the associated document
internalId - Internal id of the associated document
rawScore - Score assigned to the associated document

DocumentMatch

public DocumentMatch(java.lang.String externalId,
                     long internalId,
                     float rawScore,
                     float score,
                     RelevanceRating rating)
Creates a new instance of DocumentMatch with the specified information, include a relevance judgment. Sets raw score to -1.0f to indicate that no organic value was available.

Parameters:
externalId - External id of the associated document
internalId - Internal id of the associated document
rawScore - Score assigned to the associated document
score - Normalized score
rating - RelevanceRating assigned to the associated document
Method Detail

getDocid

public java.lang.String getDocid()
Gets the document id of the match. When examining the results of a search on a reverted index, this value is the string representation of a basis query that can serve as an expansion term in a query against an inverted index.

Returns:
External document id of the retrieved document.

getInternalId

public long getInternalId()
Gets the internal id of the retrieved document. This value is meaningful only to the search engine that retrieved the result, and to the index from which it was retrieved.

Returns:
Internal document id meaningful to the search engine that retrieved the document.

getScore

public float getScore()
Gets the score that was assigned to the document in response to a query.

Returns:
Score assigned by the ranking algorithm to the associated document.

setScore

public void setScore(float value)
Sets the score associated with the document. Typically used by a normalization algorithm to adjust scores for an entire RankedList. May also be used in conjunction with setRelevanceRating(com.fxpal.search.RelevanceRating) when setting up input for a relevance feedback query.

Parameters:
value - New score

getRawScore

public float getRawScore()
Gets the score that was assigned to the document in response to a query.

Returns:
Score assigned by the ranking algorithm to the associated document.

setRawScore

public void setRawScore(float value)
Sets the score associated with the document.

Parameters:
value - New score

getRelevanceRating

public RelevanceRating getRelevanceRating()
Gets the relevance rating

Returns:
RelevanceRating associated with the retrieved document

setRelevanceRating

public void setRelevanceRating(RelevanceRating r)
Assigns a RelevanceRating value to the instance. May be used in conjunction with setScore(float) to set the strength of relevance for pseudo-relevance feedback or relevance feedback.

Parameters:
r - User-assigned rating

isRelevant

public boolean isRelevant()
Tests whether the associated document has been marked as relevant.

Returns:
true if the instance has been marked as RELEVANT

isNotRelevant

public boolean isNotRelevant()
Tests whether the associated document has been marked as non-relevant.

Returns:
true if the instance has been marked as NON_RELEVANT