org.terrier.matching.models
Class Idf

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

public final class Idf
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class computes the idf values for specific terms in the collection.

Author:
Gianni Amati, Ben He, Vassilis Plachouras
See Also:
Serialized Form

Field Summary
static double LOG_2_OF_E
          The natural logarithm of 2, used to change the base of logarithms.
static double REC_LOG_2_OF_E
          The reciprocal of CONSTANT, computed for efficiency.
 
Constructor Summary
Idf()
          A default constructor.
Idf(double docs)
          A constructor specifying the number of documents in the collection.
 
Method Summary
 java.lang.Object clone()
          Make a perfect clone of this object
 double idf(double d)
          Returns the idf of d.
 double idf(int d)
          Returns the idf of the given number d.
 double idfDFR(double d)
          Returns the idf of d.
 double idfDFR(int d)
          Returns the idf of the given number d.
 double idfENQUIRY(double d)
          The INQUERY idf formula.
 double idfN(double d)
          Return the normalised idf of the given number.
 double idfN(int d)
          Return the normalised idf of the given number.
 double idfNENQUIRY(double d)
          The normalised INQUERY idf formula
static double log(double d)
          Returns the base 2 log of the given double precision number.
static double log(double d1, double d2)
          Returns the base 2 log of d1 over d2
static void main(java.lang.String[] args)
          main
 void setNumberOfDocuments(double N)
          Set number of documents
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_2_OF_E

public static final double LOG_2_OF_E
The natural logarithm of 2, used to change the base of logarithms.


REC_LOG_2_OF_E

public static final double REC_LOG_2_OF_E
The reciprocal of CONSTANT, computed for efficiency.

Constructor Detail

Idf

public Idf()
A default constructor. NOTE: You must set the number of documents if you intend to use the idf* functions in this class


Idf

public Idf(double docs)
A constructor specifying the number of documents in the collection.

Parameters:
docs - The number of documents.
Method Detail

clone

public java.lang.Object clone()
Make a perfect clone of this object

Overrides:
clone in class java.lang.Object

idf

public double idf(double d)
Returns the idf of d.

Parameters:
d - The given term frequency
Returns:
the base 2 log of numberOfDocuments/d

idf

public double idf(int d)
Returns the idf of the given number d.

Parameters:
d - the number for which the idf will be computed.
Returns:
the idf of the given number d.

idfDFR

public double idfDFR(double d)
Returns the idf of d.

Parameters:
d - The given term frequency
Returns:
the base 2 log of numberOfDocuments/d

idfDFR

public double idfDFR(int d)
Returns the idf of the given number d.

Parameters:
d - the number for which the idf will be computed.
Returns:
the idf of the given number d.

idfENQUIRY

public double idfENQUIRY(double d)
The INQUERY idf formula. We need to check again this formula, as it seems that there is a bug in the expression numberOfDocuments - d / d.

Parameters:
d - the number for which the idf will be computed
Returns:
the INQUERY idf of the number d

idfN

public double idfN(double d)
Return the normalised idf of the given number.

Parameters:
d - The number of which the idf is computed.
Returns:
the normalised idf of d

setNumberOfDocuments

public void setNumberOfDocuments(double N)
Set number of documents

Parameters:
N - the number of ducuments

idfN

public double idfN(int d)
Return the normalised idf of the given number.

Parameters:
d - The number of which the idf is computed.
Returns:
the normalised idf of d

idfNENQUIRY

public double idfNENQUIRY(double d)
The normalised INQUERY idf formula

Parameters:
d - the number for which we will compute the normalised idf
Returns:
the normalised INQUERY idf of d

log

public static double log(double d)
Returns the base 2 log of the given double precision number.

Parameters:
d - The number of which the log we will compute
Returns:
the base 2 log of the given number

log

public static double log(double d1,
                         double d2)
Returns the base 2 log of d1 over d2

Parameters:
d1 - the nominator
d2 - the denominator
Returns:
the base 2 log of d1/d2

main

public static void main(java.lang.String[] args)
main

Parameters:
args -


Terrier 3.5. Copyright © 2004-2011 University of Glasgow