Package org.terrier.matching.dsms
Class SimpleStaticScoreModifier
- java.lang.Object
-
- 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:- "oos" (default) - an ObjectInputStream array of doubles, floats or shorts.
- "docno2score" - a text file with format "docno value\n"
- "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.
- "listofscores" - a text file with format "value\n", for each document.
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 Summary
Fields Modifier and Type Field Description protected org.slf4j.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
Constructors Constructor Description SimpleStaticScoreModifier()
Constructs an instance of SimpleStaticScoreModifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static double[]
castToDoubleArr(float[] f)
protected static double[]
castToDoubleArr(short[] f)
java.lang.Object
clone()
Creates the close of this objectjava.lang.String
getName()
Returns the name of the document score modifier.void
init(Index index)
initprotected void
initialise_parameters()
protected void
loadDocno2score(Index index)
protected void
loadDocno2score_seq(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)
-
-
-
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.
-
-
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 interfaceDocumentScoreModifier
- Parameters:
index
- Index the data structures used for retrieval.queryTerms
- MatchingQueryTerms[] the query termsset
- 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 interfaceDocumentScoreModifier
- 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 interfaceDocumentScoreModifier
- Overrides:
clone
in classjava.lang.Object
-
-