Class PhraseScoreModifier

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

    public class PhraseScoreModifier
    extends java.lang.Object
    implements DocumentScoreModifier
    This is the class performs the re-scoring for a phrase queries. If the block distance (window size) is greater than 1 then ProximityIterablePosting is used, else PhraseIterablePosting is used.
    Author:
    Richard McCreadie
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int blockDistance
      The maximum distance, in blocks, that is allowed between the phrase terms.
      protected static org.slf4j.Logger logger
      the logger for this class
      protected java.util.List<Query> phraseTerms
      A list of the strings of the phrase terms.
      protected boolean required
      Indicates whether the phrase should appear in the retrieved documents, or not.
    • Constructor Summary

      Constructors 
      Constructor Description
      PhraseScoreModifier​(java.util.List<Query> pTerms)
      Constructs a phrase score modifier for a given set of query terms.
      PhraseScoreModifier​(java.util.List<Query> pTerms, boolean r)
      Constructs a phrase score modifier for a given set of query terms.
      PhraseScoreModifier​(java.util.List<Query> pTerms, boolean r, int bDist)
      Constructs a phrase score modifier for a given set of query terms, whether they are required to appear in a document, and the allowed distance between the phrase terms.
      PhraseScoreModifier​(java.util.List<Query> pTerms, int bDist)
      Constructs a phrase score modifier for a given set of query terms and the allowed distance between them.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clones this DSM.
      java.lang.String getName()
      Returns the name of the document score modifier.
      boolean modifyScores​(Index index, MatchingQueryTerms terms, ResultSet resultSet)
      Modifies the scores of the documents for a given query.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
        the logger for this class
      • blockDistance

        protected int blockDistance
        The maximum distance, in blocks, that is allowed between the phrase terms. The default value of one corresponds to phrase search, while any higher value enables proximity search.
      • phraseTerms

        protected java.util.List<Query> phraseTerms
        A list of the strings of the phrase terms.
      • required

        protected boolean required
        Indicates whether the phrase should appear in the retrieved documents, or not. The default value is true.
    • Constructor Detail

      • PhraseScoreModifier

        public PhraseScoreModifier​(java.util.List<Query> pTerms)
        Constructs a phrase score modifier for a given set of query terms.
        Parameters:
        pTerms - ArrayList the terms that make up the query.
      • PhraseScoreModifier

        public PhraseScoreModifier​(java.util.List<Query> pTerms,
                                   int bDist)
        Constructs a phrase score modifier for a given set of query terms and the allowed distance between them.
        Parameters:
        pTerms - ArrayList the terms that make up the query.
        bDist - int the allowed distance between phrase terms.
      • PhraseScoreModifier

        public PhraseScoreModifier​(java.util.List<Query> pTerms,
                                   boolean r)
        Constructs a phrase score modifier for a given set of query terms.
        Parameters:
        pTerms - ArrayList the terms that make up the query.
        r - boolean indicates whether the phrase is required.
      • PhraseScoreModifier

        public PhraseScoreModifier​(java.util.List<Query> pTerms,
                                   boolean r,
                                   int bDist)
        Constructs a phrase score modifier for a given set of query terms, whether they are required to appear in a document, and the allowed distance between the phrase terms.
        Parameters:
        pTerms - ArrayList the terms that make up the query.
        r - boolean indicates whether the phrase is required.
        bDist - int the allowed distance between the phrase terms.
    • Method Detail

      • modifyScores

        public boolean modifyScores​(Index index,
                                    MatchingQueryTerms terms,
                                    ResultSet resultSet)
        Description copied from interface: DocumentScoreModifier
        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.
        terms - MatchingQueryTerms[] the query terms
        resultSet - ResultSet the current set of results.
        Returns:
        true if any scores have been altered
      • getName

        public java.lang.String getName()
        Description copied from interface: DocumentScoreModifier
        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()
        Clones this DSM. Note that phraseTerms is shallow copied, because Strings are immutable
        Specified by:
        clone in interface DocumentScoreModifier
        Overrides:
        clone in class java.lang.Object