org.terrier.matching.dsms
Class SimpleStaticScoreModifier

java.lang.Object
  extended by org.terrier.matching.dsms.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:

Since:
3.0
Author:
Craig Macdonald, Vassilis Plachouras

Field Summary
protected  org.apache.log4j.Logger logger
           
protected  int modifiedLength
          The number of top-ranked documents for which the scores will be modified.
protected  double[] staticScores
          The array that contains the statically computed scores.
protected  double w
          weight for this feature
 
Constructor Summary
SimpleStaticScoreModifier()
          Constructs an instance of SimpleStaticScoreModifier.
 
Method Summary
protected static double[] castToDoubleArr(float[] f)
           
protected static double[] castToDoubleArr(short[] f)
           
 java.lang.Object clone()
          Creates the close of this object
 java.lang.String getName()
          Returns the name of the document score modifier.
 void init(Index index)
          init
protected  void initialise_parameters()
           
protected  void loadDocno2score_seq(Index index)
           
protected  void loadDocno2score(Index index)
           
protected  void loadOOS()
           
protected  void loadScorefile(Index index)
           
protected static void makeAverage1(double[] ar)
           
protected static void makeMaxMin(double[] staticScores2)
           
 boolean modifyScores(Index index, MatchingQueryTerms queryTerms, ResultSet set)
          Modifies the scores of the documents for a given query.
protected static void negate(double[] staticScores2)
           
protected  void normalise(double[] scores)
           
protected static void printStats(double[] ar)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.log4j.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 - TermTreeNodes[] 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


Terrier 3.5. Copyright © 2004-2011 University of Glasgow