Class SimpleStaticScoreModifier

  • All Implemented Interfaces:
    java.lang.Cloneable, DocumentScoreModifier

    public class SimpleStaticScoreModifier
    extends java.lang.Object
    implements DocumentScoreModifier
    Provides a way to integrate a static (query independent) document (prior) feature into the document scores. The feature scores are loaded from a file. The filename is specified by the property ssa.input.file. It can take several forms, as specified by the property ssa.input.type:
    1. "oos" (default) - an ObjectInputStream array of doubles, floats or shorts.
    2. "docno2score" - a text file with format "docno value\n"
    3. "docno2score_seq" - a text file with format "docno value\n", where docno is sorted in the same order as the docno fields in the MetaIndex.
    4. "listofscores" - a text file with format "value\n", for each document.
    The static feature score is added to the document score as score(d) += w*prior(d). w is controlled by the property ssa.w.

    Properties:

    • ssa.input.file - input file
    • ssa.input.type - type of input file - one of "oos", "docno2score", "docno2score_seq", "listofscores". Default is oos.
    • ssa.modified.length - how much of the top-ranked documents to alter. 0 means all documents, defaults to 1000.
    • ssa.w - combination weight of the feature.
    • ssa.normalise - if defined, available options are "mean1" or "maxmin". Default is no normalisation.
    Since:
    3.0
    Author:
    Craig Macdonald, Vassilis Plachouras
    • Field Detail

      • logger

        protected org.slf4j.Logger logger
      • modifiedLength

        protected int modifiedLength
        The number of top-ranked documents for which the scores will be modified.
      • w

        protected double w
        weight for this feature
      • staticScores

        protected double[] staticScores
        The array that contains the statically computed scores.
    • Constructor Detail

      • SimpleStaticScoreModifier

        public SimpleStaticScoreModifier()
        Constructs an instance of SimpleStaticScoreModifier.
    • Method Detail

      • makeAverage1

        protected static void makeAverage1​(double[] ar)
      • init

        public void init​(Index index)
        init
        Parameters:
        index -
      • normalise

        protected void normalise​(double[] scores)
      • loadScorefile

        protected void loadScorefile​(Index index)
      • loadOOS

        protected void loadOOS()
      • makeMaxMin

        protected static void makeMaxMin​(double[] staticScores2)
      • loadDocno2score_seq

        protected void loadDocno2score_seq​(Index index)
      • loadDocno2score

        protected void loadDocno2score​(Index index)
      • negate

        protected static void negate​(double[] staticScores2)
      • printStats

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

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

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

        protected void initialise_parameters()
      • modifyScores

        public boolean modifyScores​(Index index,
                                    MatchingQueryTerms queryTerms,
                                    ResultSet set)
        Modifies the scores of the documents for a given query. This returns a boolean that allows the Matching class to determine if the scores of the documents have actually been altered. This is because the resultset has to be resorted after each one.
        Specified by:
        modifyScores in interface DocumentScoreModifier
        Parameters:
        index - Index the data structures used for retrieval.
        queryTerms - MatchingQueryTerms[] the query terms
        set - ResultSet the current set of results.
        Returns:
        true if any scores have been altered
      • getName

        public java.lang.String getName()
        Returns the name of the document score modifier.
        Specified by:
        getName in interface DocumentScoreModifier
        Returns:
        String the name of the document score modifier.
      • clone

        public java.lang.Object clone()
        Creates the close of this object
        Specified by:
        clone in interface DocumentScoreModifier
        Overrides:
        clone in class java.lang.Object