Class StaticScoreModifierWeightingModel

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Model
    Direct Known Subclasses:
    StaticFeature

    public abstract class StaticScoreModifierWeightingModel
    extends WeightingModel
    Base abstract class for query independent features loaded from file. For types of file are supported:
    • oos/ois: an ObjectOutputStream file of float[] or double[] array.
    • docid2score: a text file containing [docid] [score]. An optional parameter after the filename specifies the column of interest.
    • listofscores: a text file containing one score per line. An optional parameter after the filename specifies the column of interest.
    • tmap: a TIntDoubleHashMap saved in an ObjectOutputStream file
    Examples, in a feature.list file:
     QI:StaticFeature(OOS,/path/to/index/data.inlinks.oos.gz)
     QI:StaticFeature(docid2score,/path/to/index/data.pagerank.txt.gz)
     QI:StaticFeature(listofscores,/path/to/index/data.pagerank.txt.gz,2) #examine columns 2 (starting from 1)
     
    Since:
    4.0
    Author:
    Craig Macdonald
    See Also:
    Serialized Form
    • Field Detail

      • staticScores

        protected double[] staticScores
      • FstaticScores

        protected float[] FstaticScores
      • asFloat

        protected final boolean asFloat
      • map

        protected final boolean map
      • staticMap

        protected gnu.trove.TIntDoubleHashMap staticMap
      • FstaticMap

        protected gnu.trove.TIntFloatHashMap FstaticMap
      • source

        protected java.lang.String source
    • Constructor Detail

      • StaticScoreModifierWeightingModel

        public StaticScoreModifierWeightingModel​(java.lang.String[] params)
    • Method Detail

      • getScoreD

        public final double getScoreD​(int docid)
      • getScoreF

        public final float getScoreF​(int docid)
      • getSource

        public final java.lang.String getSource()
      • getInfo

        public java.lang.String getInfo()
        Description copied from class: WeightingModel
        Returns the name of the model.
        Specified by:
        getInfo in interface Model
        Specified by:
        getInfo in class WeightingModel
        Returns:
        java.lang.String
      • score

        public double score​(double tf,
                            double docLength)
        Description copied from class: WeightingModel
        This method provides the contract for implementing weighting models.
        Specified by:
        score in class WeightingModel
        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
      • loadDocid2score

        protected void loadDocid2score​(int numDocs,
                                       java.lang.String inputFile,
                                       int column)
      • loadScorefile

        protected void loadScorefile​(int numDocs,
                                     java.lang.String inputFile,
                                     int column)
      • loadOOS

        protected void loadOOS​(java.lang.String inputFile)
      • loadfloatOOS

        protected void loadfloatOOS​(java.lang.String inputFile)
      • printStats

        protected static void printStats​(double[] ar)
      • castToDoubleArr

        protected static double[] castToDoubleArr​(float[] f)
      • castToDoubleArr

        protected static double[] castToDoubleArr​(short[] f)
      • castToFloatArr

        protected static float[] castToFloatArr​(double[] f)
      • castToFloatArr

        protected static float[] castToFloatArr​(short[] f)
      • standardNormalisation

        public static float[] standardNormalisation​(float[] data)
        Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum. RETURNS THE SAME ARRAY OBJECT - i.e. changes are made in place.
        Parameters:
        data -
      • min

        public static final float min​(float[] a)
        Return the min of the specified array
        Parameters:
        a - the array
        Returns:
        the minimum value in the arrays
      • max

        public static final float max​(float[] a)
        Return the max of the specified array
        Parameters:
        a - the array
        Returns:
        the maximum value in the arrays