Package org.terrier.matching.tsms
Class RequiredTermModifier
- java.lang.Object
-
- org.terrier.matching.models.WeightingModel
-
- org.terrier.matching.tsms.RequiredTermModifier
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Model
public class RequiredTermModifier extends WeightingModel implements 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, cs, documentFrequency, es, i, keyFrequency, numberOfDocuments, numberOfPointers, numberOfPostings, numberOfTokens, numberOfUniqueTerms, rq, termFrequency
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetInfo()Returns the name of the model.java.lang.StringgetName()Returns the name of the class and whether the query term is required.inthashCode()intmodifyScores(double[] scores, int[][] pointers)Resets the scores of documents for a particular term, based on the requirement of appearance of the corresponding term.doublescore(double tf, double docLength)This method provides the contract for implementing weighting models.doublescore(Posting p)Returns score-
Methods inherited from class org.terrier.matching.models.WeightingModel
clone, getOverflowed, getParameter, prepare, setCollectionStatistics, setEntryStatistics, setKeyFrequency, setParameter, setRequest
-
-
-
-
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.- 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 class and whether the query term is required.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getInfo
public java.lang.String getInfo()
Description copied from class:WeightingModelReturns the name of the model.- Specified by:
getInfoin interfaceModel- Specified by:
getInfoin classWeightingModel- Returns:
- java.lang.String
-
score
public double score(Posting p)
Returns score- Overrides:
scorein classWeightingModel- Returns:
- score
-
score
public double score(double tf, double docLength)Description copied from class:WeightingModelThis method provides the contract for implementing weighting models.- Specified by:
scorein classWeightingModel- Parameters:
tf- The term frequency in the documentdocLength- the document's length- Returns:
- the score assigned to a document with the given tf and docLength, and other preset parameters
-
-