Terrier IR Platform
1.1.1

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

java.lang.Object
  extended by uk.ac.gla.terrier.matching.models.Idf
All Implemented Interfaces:
java.io.Serializable

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

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
 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
 double log(double d)
          Returns the base 2 log of the given double precision number.
 double log(double d1, double d2)
          Returns the base 2 log of d1 over d2
 void setNumberOfDocuments(double N)
           
 
Methods inherited from class java.lang.Object
equals, 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

idf

public final 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 final 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 final 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 final 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 final 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 final 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)

idfN

public final 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 final 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 final 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 final 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

Terrier IR Platform
1.1.1

Terrier Information Retrieval Platform 1.1.1. Copyright 2004-2007 University of Glasgow