Package org.terrier.matching.models
Class WeightingModel
- java.lang.Object
-
- org.terrier.matching.models.WeightingModel
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Model
- Direct Known Subclasses:
BB2,BM25,CoordinateMatch,DFIC,DFIZ,DFR_BM25,DFRee,DFReeKLIM,DFRWeightingModel,DirichletLM,Dl,DLH,DLH13,DPH,Hiemstra_LM,IFB2,In_expB2,In_expC2,InB2,InL2,Js_KLs,LemurTF_IDF,LGD,MDL2,ML2,MRF,Null,pBiL,PerFieldNormWeightingModel,PL2,RequiredTermModifier,SingleFieldModel,StaticScoreModifierWeightingModel,TermInFieldModifier,Tf,TF_IDF,XSqrA_M
public abstract class WeightingModel extends java.lang.Object implements Model, java.io.Serializable, java.lang.Cloneable
This class should be extended by the classes used for weighting terms and documents.- Author:
- Gianni Amati, Ben He, Vassilis Plachouras
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doubleaverageDocumentLengthThe average length of documents in the collection.protected doublecThe parameter c.protected CollectionStatisticscsprotected doubledocumentFrequencyThe document frequency of the term in the collection.protected EntryStatisticsesprotected IdfiThe class used for computing the idf values.protected doublekeyFrequencyThe term frequency in the query.protected doublenumberOfDocumentsThe number of documents in the collection.protected doublenumberOfPointersDeprecated.protected doublenumberOfPostingsThe number of distinct entries in the inverted file.protected doublenumberOfTokensThe number of tokens in the collections.protected doublenumberOfUniqueTermsNumber of unique terms in the collectionprotected Requestrqprotected doubletermFrequencyThe term frequency in the collection.
-
Constructor Summary
Constructors Constructor Description WeightingModel()A default constructor that initialises the idf i attribute
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description WeightingModelclone()Clone this weighting modelabstract java.lang.StringgetInfo()Returns the name of the model.static longgetOverflowed(int o)Returns overflowdoublegetParameter()Returns the parameter as set by setParameter()voidprepare()prepareabstract doublescore(double tf, double docLength)This method provides the contract for implementing weighting models.doublescore(Posting p)Returns scorevoidsetCollectionStatistics(CollectionStatistics _cs)Sets collection statisticsvoidsetEntryStatistics(EntryStatistics _es)Sets entry statistics.voidsetKeyFrequency(double keyFreq)Sets the term's frequency in the query.voidsetParameter(double _c)Sets the c valuevoidsetRequest(Request _rq)Sets request
-
-
-
Field Detail
-
i
protected Idf i
The class used for computing the idf values.
-
averageDocumentLength
protected double averageDocumentLength
The average length of documents in the collection.
-
keyFrequency
protected double keyFrequency
The term frequency in the query.
-
documentFrequency
protected double documentFrequency
The document frequency of the term in the collection.
-
termFrequency
protected double termFrequency
The term frequency in the collection.
-
numberOfDocuments
protected double numberOfDocuments
The number of documents in the collection.
-
numberOfTokens
protected double numberOfTokens
The number of tokens in the collections.
-
c
protected double c
The parameter c. This defaults to 1.0, but should be set using in the constructor of each child weighting model to the sensible default for that weighting model.
-
numberOfUniqueTerms
protected double numberOfUniqueTerms
Number of unique terms in the collection
-
numberOfPointers
@Deprecated protected double numberOfPointers
Deprecated.The number of distinct entries in the inverted file. This figure can be calculated as the sum of all Nt over all terms. Deprecated in favour of numberOfPostings
-
numberOfPostings
protected double numberOfPostings
The number of distinct entries in the inverted file. This figure can be calculated as the sum of all Nt over all terms
-
cs
protected CollectionStatistics cs
-
es
protected EntryStatistics es
-
rq
protected Request rq
-
-
Method Detail
-
clone
public WeightingModel clone()
Clone this weighting model- Overrides:
clonein classjava.lang.Object
-
getInfo
public abstract java.lang.String getInfo()
Returns the name of the model.
-
prepare
public void prepare()
prepare
-
getOverflowed
public static long getOverflowed(int o)
Returns overflow- Parameters:
o-- Returns:
- overflow
-
score
public double score(Posting p)
Returns score- Parameters:
p-- Returns:
- score
-
setCollectionStatistics
public void setCollectionStatistics(CollectionStatistics _cs)
Sets collection statistics- Parameters:
_cs-
-
setEntryStatistics
public void setEntryStatistics(EntryStatistics _es)
Sets entry statistics.- Parameters:
_es-
-
setRequest
public void setRequest(Request _rq)
Sets request- Parameters:
_rq-
-
score
public abstract double score(double tf, double docLength)This method provides the contract for implementing weighting models.- 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
-
setParameter
public void setParameter(double _c)
Sets the c value- Specified by:
setParameterin interfaceModel- Parameters:
_c- the term frequency normalisation parameter value.
-
getParameter
public double getParameter()
Returns the parameter as set by setParameter()- Specified by:
getParameterin interfaceModel
-
setKeyFrequency
public void setKeyFrequency(double keyFreq)
Sets the term's frequency in the query.- Parameters:
keyFreq- the term's frequency in the query.
-
-