Class BasicModel
- java.lang.Object
-
- org.terrier.matching.models.basicmodel.BasicModel
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public abstract class BasicModel extends java.lang.Object implements java.io.Serializable, java.lang.CloneableThis class provides a contract for implementing the basic models for randomness in the DFR framework, for use with the DFRWeightingModel class. This is referred to as the component -log(prob1) in the DFR framework.- Author:
- Ben He
- See Also:
DFRWeightingModel, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected IdfiThe class used for computing the idf values.protected doublenumberOfDocumentsThe number of documents in the whole collection.protected doublenumberOfTokensThe number of tokens in the whole collection
-
Constructor Summary
Constructors Constructor Description BasicModel()A default constructor that initialises the idf i attribute
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BasicModelclone()Clone this weighting modelabstract java.lang.StringgetInfo()Returns the name of the model.abstract doublescore(double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength)This method provides the contract for implementing weighting models.voidsetNumberOfDocuments(double numOfDocs)Sets the number of documents in the collection.voidsetNumberOfTokens(double numTokens)Set the number of tokens in the collection.doublestirlingPower(double n, double m)This method provides the contract for implementing the Stirling formula for the power series.
-
-
-
Field Detail
-
i
protected Idf i
The class used for computing the idf values.
-
numberOfDocuments
protected double numberOfDocuments
The number of documents in the whole collection.
-
numberOfTokens
protected double numberOfTokens
The number of tokens in the whole collection
-
-
Method Detail
-
clone
public BasicModel clone()
Clone this weighting model- Overrides:
clonein classjava.lang.Object
-
getInfo
public abstract java.lang.String getInfo()
Returns the name of the model.- Returns:
- java.lang.String
-
setNumberOfDocuments
public void setNumberOfDocuments(double numOfDocs)
Sets the number of documents in the collection.- Parameters:
numOfDocs- the number of documents in the collection.
-
setNumberOfTokens
public void setNumberOfTokens(double numTokens)
Set the number of tokens in the collection.- Parameters:
numTokens- double The number of tokens in the collection.
-
score
public abstract double score(double tf, double documentFrequency, double termFrequency, double keyFrequency, double documentLength)This method provides the contract for implementing weighting models.- Parameters:
tf- The term frequency in the documentdocumentFrequency- The document frequency of the termtermFrequency- The term frequency of the term in the collectionkeyFrequency- The normalised query term frequency.documentLength- The length of the document.- Returns:
- the score returned by the implemented weighting model.
-
stirlingPower
public double stirlingPower(double n, double m)This method provides the contract for implementing the Stirling formula for the power series.- Parameters:
n- The parameter of the Stirling formula.m- The parameter of the Stirling formula.- Returns:
- the approximation of the power series
-
-