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 double
averageDocumentLength
The average length of documents in the collection.protected double
c
The parameter c.protected CollectionStatistics
cs
protected double
documentFrequency
The document frequency of the term in the collection.protected EntryStatistics
es
protected Idf
i
The class used for computing the idf values.protected double
keyFrequency
The term frequency in the query.protected double
numberOfDocuments
The number of documents in the collection.protected double
numberOfPointers
Deprecated.protected double
numberOfPostings
The number of distinct entries in the inverted file.protected double
numberOfTokens
The number of tokens in the collections.protected double
numberOfUniqueTerms
Number of unique terms in the collectionprotected Request
rq
protected double
termFrequency
The 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 WeightingModel
clone()
Clone this weighting modelabstract java.lang.String
getInfo()
Returns the name of the model.static long
getOverflowed(int o)
Returns overflowdouble
getParameter()
Returns the parameter as set by setParameter()void
prepare()
prepareabstract double
score(double tf, double docLength)
This method provides the contract for implementing weighting models.double
score(Posting p)
Returns scorevoid
setCollectionStatistics(CollectionStatistics _cs)
Sets collection statisticsvoid
setEntryStatistics(EntryStatistics _es)
Sets entry statistics.void
setKeyFrequency(double keyFreq)
Sets the term's frequency in the query.void
setParameter(double _c)
Sets the c valuevoid
setRequest(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:
clone
in 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:
setParameter
in interfaceModel
- Parameters:
_c
- the term frequency normalisation parameter value.
-
getParameter
public double getParameter()
Returns the parameter as set by setParameter()- Specified by:
getParameter
in interfaceModel
-
setKeyFrequency
public void setKeyFrequency(double keyFreq)
Sets the term's frequency in the query.- Parameters:
keyFreq
- the term's frequency in the query.
-
-