org.terrier.matching.models
Class BM25

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

public class BM25
extends WeightingModel

This class implements the Okapi BM25 weighting model. The default parameters used are:
k_1 = 1.2d
k_3 = 8d
b = 0.75d
The b parameter can be altered by using the setParameter method.

Author:
Gianni Amati, Ben He, 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
BM25()
          A default constructor.
 
Method Summary
 java.lang.String getInfo()
          Returns the name of the model.
 double getParameter()
          Returns the b parameter to the BM25 ranking formula as set by setParameter()
 double score(double tf, double docLength)
          Uses BM25 to compute a weight for a term in a document.
 double score(double tf, double docLength, double n_t, double F_t, double keyFrequency)
          Uses BM25 to compute a weight for a term in a document.
 void setParameter(double _b)
          Sets the b parameter to BM25 ranking formula
 
Methods inherited from class org.terrier.matching.models.WeightingModel
clone, getOverflowed, prepare, score, setAverageDocumentLength, setCollectionStatistics, setDocumentFrequency, setEntryStatistics, setKeyFrequency, setNumberOfDocuments, setNumberOfPointers, setNumberOfTokens, setNumberOfUniqueTerms, setRequest, setTermFrequency, stirlingPower
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BM25

public BM25()
A default constructor.

Method Detail

getInfo

public final java.lang.String getInfo()
Returns the name of the model.

Specified by:
getInfo in interface Model
Specified by:
getInfo in class WeightingModel
Returns:
the name of the model

score

public double score(double tf,
                    double docLength)
Uses BM25 to compute a weight for a term in a document.

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)
Uses BM25 to compute a weight for a term in a document.

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 assigned by the weighting model BM25.

setParameter

public void setParameter(double _b)
Sets the b parameter to BM25 ranking formula

Specified by:
setParameter in interface Model
Overrides:
setParameter in class WeightingModel
Parameters:
_b - the b parameter value to use.

getParameter

public double getParameter()
Returns the b parameter to the BM25 ranking formula as set by setParameter()

Specified by:
getParameter in interface Model
Overrides:
getParameter in class WeightingModel


Terrier 3.5. Copyright © 2004-2011 University of Glasgow