Class 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

      Fields 
      Modifier and Type Field Description
      static double LOG_E_OF_2
      Deprecated.
      static double REC_LOG_2_OF_E
      Deprecated.
    • Constructor Summary

      Constructors 
      Constructor Description
      Idf()
      A default constructor.
      Idf​(double docs)
      A constructor specifying the number of documents in the collection.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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)
      Deprecated.
      static double log​(double d1, double d2)
      Deprecated.
      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_E_OF_2

        @Deprecated
        public static final double LOG_E_OF_2
        Deprecated.
        The natural logarithm of 2, used to change the base of logarithms. Do not use, moved to WeightingModelLibrary
      • REC_LOG_2_OF_E

        @Deprecated
        public static final double REC_LOG_2_OF_E
        Deprecated.
        The logarithm in base 2 of e, used to change the base of logarithms. Do not use, moved to WeightingModelLibrary
    • 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
      • main

        public static void main​(java.lang.String[] args)
        main
        Parameters:
        args -
      • log

        @Deprecated
        public static double log​(double d)
        Deprecated.
        Returns the base 2 log of the given double precision number. Method has been moved to WeightingModelLibrary
        Parameters:
        d - The number of which the log we will compute
        Returns:
        the base 2 log of the given numbers
      • log

        @Deprecated
        public static double log​(double d1,
                                 double d2)
        Deprecated.
        Returns the base 2 log of d1 over d2. Do not use, moved to WeightingModelLibrary
        Parameters:
        d1 - the numerator
        d2 - the denominator
        Returns:
        the base 2 log of d1/d2