Class RequiredTermModifier

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Model

    public class RequiredTermModifier
    extends WeightingModel
    implements java.io.Serializable
    Resets the scores of documents according to whether a term is required or not, and whether it appears in the retrieved documents. This class implements the TermScoreModifier interface.
    Author:
    Vassilis Plachouras
    See Also:
    Serialized Form
    • Constructor Detail

      • RequiredTermModifier

        public RequiredTermModifier​(boolean r)
        Constructs an instance of a TermInFieldModifier given the requirement that the term should, or should not appear in the query.
        Parameters:
        r - boolean indicates whether the term is required to appear in the retrieved documents.
    • Method Detail

      • modifyScores

        public int modifyScores​(double[] scores,
                                int[][] pointers)
        Resets the scores of documents for a particular term, based on the requirement of appearance of the corresponding term.
        Parameters:
        scores - double[] the scores of the documents.
        pointers - int[][] the pointers read from the inverted file for a particular query term.
        Returns:
        the number of documents for which the scores were modified.
      • getName

        public java.lang.String getName()
        Returns the name of the class and whether the query term is required.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • 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