Terrier IR Platform
2.2.1

uk.ac.gla.terrier.matching.models
Class WeightingModel

java.lang.Object
  extended by uk.ac.gla.terrier.matching.models.WeightingModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Model
Direct Known Subclasses:
BB2, BM25, DFR_BM25, DFRee, DFRWeightingModel, DLH, DLH13, Hiemstra_LM, IFB2, In_expB2, In_expC2, InL2, LemurTF_IDF, PL2, TF_IDF

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.

Version:
$Revision: 1.30 $
Author:
Gianni Amati, Ben He, Vassilis Plachouras
See Also:
Serialized Form

Constructor Summary
WeightingModel()
          A default constructor that initialises the idf i attribute
 
Method Summary
 java.lang.Object clone()
          Clone this weighting model
abstract  java.lang.String getInfo()
          Returns the name of the model.
 double getParameter()
          Returns the parameter as set by setParameter()
abstract  double score(double tf, double docLength)
          This method provides the contract for implementing weighting models.
abstract  double score(double tf, double docLength, double n_t, double F_t, double keyFrequency)
          This method provides the contract for implementing weighting models.
 void setAverageDocumentLength(double avgDocLength)
          Sets the average length of documents in the collection.
 void setDocumentFrequency(double docFreq)
          Sets the document frequency of the term in the collection.
 void setKeyFrequency(double keyFreq)
          Sets the term's frequency in the query.
 void setNumberOfDocuments(double numOfDocs)
          Sets the number of documents in the collection.
 void setNumberOfPointers(double number)
          Set the number of pointers in the collection.
 void setNumberOfTokens(double value)
          Set the number of tokens in the collection.
 void setNumberOfUniqueTerms(double number)
          Set the number of unique terms in the collection.
 void setParameter(double c)
          Sets the c value
 void setTermFrequency(double termFreq)
          Sets the term's frequency in the collection.
 double stirlingPower(double n, double m)
          This method provides the contract for implementing the Stirling formula for the power series.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightingModel

public WeightingModel()
A default constructor that initialises the idf i attribute

Method Detail

clone

public java.lang.Object clone()
Clone this weighting model

Overrides:
clone in class java.lang.Object

getInfo

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

Specified by:
getInfo in interface Model
Returns:
java.lang.String

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 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 abstract double score(double tf,
                             double docLength,
                             double n_t,
                             double F_t,
                             double keyFrequency)
This method provides the contract for implementing weighting models.

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 returned by the implemented weighting model.

setAverageDocumentLength

public void setAverageDocumentLength(double avgDocLength)
Sets the average length of documents in the collection.

Specified by:
setAverageDocumentLength in interface Model
Parameters:
avgDocLength - The documents' average length.

setParameter

public void setParameter(double c)
Sets the c value

Specified by:
setParameter in interface Model
Parameters:
c - the term frequency normalisation parameter value.

getParameter

public double getParameter()
Returns the parameter as set by setParameter()

Specified by:
getParameter in interface Model

setDocumentFrequency

public void setDocumentFrequency(double docFreq)
Sets the document frequency of the term in the collection.

Parameters:
docFreq - the document frequency of the term in the collection.

setKeyFrequency

public void setKeyFrequency(double keyFreq)
Sets the term's frequency in the query.

Parameters:
keyFreq - the term's frequency in the query.

setNumberOfTokens

public void setNumberOfTokens(double value)
Set the number of tokens in the collection.

Specified by:
setNumberOfTokens in interface Model
Parameters:
value - The number of tokens in the collection.

setNumberOfDocuments

public void setNumberOfDocuments(double numOfDocs)
Sets the number of documents in the collection.

Specified by:
setNumberOfDocuments in interface Model
Parameters:
numOfDocs - the number of documents in the collection.

setTermFrequency

public void setTermFrequency(double termFreq)
Sets the term's frequency in the collection.

Parameters:
termFreq - the term's frequency in the collection.

setNumberOfUniqueTerms

public void setNumberOfUniqueTerms(double number)
Set the number of unique terms in the collection.

Specified by:
setNumberOfUniqueTerms in interface Model
Parameters:
number - double The number of unique terms in the collection.

setNumberOfPointers

public void setNumberOfPointers(double number)
Set the number of pointers in the collection.

Specified by:
setNumberOfPointers in interface 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

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow