org.terrier.matching.tsms
Class RequiredTermModifier

java.lang.Object
  extended by org.terrier.matching.models.WeightingModel
      extended by org.terrier.matching.tsms.RequiredTermModifier
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Model, TermScoreModifier

public class RequiredTermModifier
extends WeightingModel
implements TermScoreModifier, java.io.Serializable

Resets the scores of documents according to whether a term is required or not, and whether it appears in the retrieved documents. This class implements the TermScoreModifier interface.

Author:
Vassilis Plachouras
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.terrier.matching.models.WeightingModel
averageDocumentLength, c, documentFrequency, i, keyFrequency, numberOfDocuments, numberOfPointers, numberOfTokens, numberOfUniqueTerms, termFrequency
 
Constructor Summary
RequiredTermModifier(boolean r)
          Constructs an instance of a TermInFieldModifier given the requirement that the term should, or should not appear in the query.
 
Method Summary
 java.lang.Object clone()
          Clone this weighting model
 java.lang.String getInfo()
          Returns the name of the model.
 java.lang.String getName()
          Returns the name of the modifier.
 int hashCode()
          Returns a hash code of this object
 int modifyScores(double[] scores, int[][] pointers)
          Resets the scores of documents for a particular term, based on the requirement of appearance of the corresponding term.
 double score(double tf, double docLength)
          This method provides the contract for implementing weighting models.
 double score(double tf, double docLength, double n_t, double F_t, double keyFrequency)
          This method provides the contract for implementing weighting models.
 double score(Posting p)
          Returns score
 
Methods inherited from class org.terrier.matching.models.WeightingModel
getOverflowed, getParameter, prepare, setAverageDocumentLength, setCollectionStatistics, setDocumentFrequency, setEntryStatistics, setKeyFrequency, setNumberOfDocuments, setNumberOfPointers, setNumberOfTokens, setNumberOfUniqueTerms, setParameter, setRequest, setTermFrequency, stirlingPower
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequiredTermModifier

public RequiredTermModifier(boolean r)
Constructs an instance of a TermInFieldModifier given the requirement that the term should, or should not appear in the query.

Parameters:
r - boolean indicates whether the term is required to appear in the retrieved documents.
Method Detail

modifyScores

public int modifyScores(double[] scores,
                        int[][] pointers)
Resets the scores of documents for a particular term, based on the requirement of appearance of the corresponding term.

Specified by:
modifyScores in interface TermScoreModifier
Parameters:
scores - double[] the scores of the documents.
pointers - int[][] the pointers read from the inverted file for a particular query term.
Returns:
the number of documents for which the scores were modified.

getName

public java.lang.String getName()
Returns the name of the modifier.

Specified by:
getName in interface TermScoreModifier
Returns:
String the name of the modifier.

hashCode

public int hashCode()
Returns a hash code of this object

Specified by:
hashCode in interface TermScoreModifier
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
Clone this weighting model

Specified by:
clone in interface TermScoreModifier
Overrides:
clone in class WeightingModel

getInfo

public java.lang.String getInfo()
Description copied from class: WeightingModel
Returns the name of the model.

Specified by:
getInfo in interface Model
Specified by:
getInfo in class WeightingModel
Returns:
java.lang.String

score

public double score(Posting p)
Returns score

Overrides:
score in class WeightingModel
Returns:
score

score

public double score(double tf,
                    double docLength)
Description copied from class: WeightingModel
This method provides the contract for implementing weighting models.

Specified by:
score in class WeightingModel
Parameters:
tf - The term frequency in the document
docLength - the document's length
Returns:
the score assigned to a document with the given tf and docLength, and other preset parameters

score

public double score(double tf,
                    double docLength,
                    double n_t,
                    double F_t,
                    double keyFrequency)
Description copied from class: WeightingModel
This method provides the contract for implementing weighting models.

Specified by:
score in class WeightingModel
Parameters:
tf - The term frequency in the document
docLength - the document's length
n_t - The document frequency of the term
F_t - the term frequency in the collection
keyFrequency - the term frequency in the query
Returns:
the score returned by the implemented weighting model.


Terrier 3.5. Copyright © 2004-2011 University of Glasgow