Package org.terrier.matching.models
Class StaticScoreModifierWeightingModel
- java.lang.Object
-
- org.terrier.matching.models.WeightingModel
-
- org.terrier.matching.models.StaticScoreModifierWeightingModel
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Model
- Direct Known Subclasses:
StaticFeature
public abstract class StaticScoreModifierWeightingModel extends WeightingModel
Base abstract class for query independent features loaded from file. For types of file are supported:- oos/ois: an
ObjectOutputStreamfile of float[] or double[] array. - docid2score: a text file containing [docid] [score]. An optional parameter after the filename specifies the column of interest.
- listofscores: a text file containing one score per line. An optional parameter after the filename specifies the column of interest.
- tmap: a
TIntDoubleHashMapsaved in anObjectOutputStreamfile
QI:StaticFeature(OOS,/path/to/index/data.inlinks.oos.gz) QI:StaticFeature(docid2score,/path/to/index/data.pagerank.txt.gz) QI:StaticFeature(listofscores,/path/to/index/data.pagerank.txt.gz,2) #examine columns 2 (starting from 1)
- Since:
- 4.0
- Author:
- Craig Macdonald
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanasFloatprotected gnu.trove.TIntFloatHashMapFstaticMapprotected float[]FstaticScoresprotected booleanmapprotected java.lang.Stringsourceprotected gnu.trove.TIntDoubleHashMapstaticMapprotected double[]staticScores-
Fields inherited from class org.terrier.matching.models.WeightingModel
averageDocumentLength, c, cs, documentFrequency, es, i, keyFrequency, numberOfDocuments, numberOfPointers, numberOfPostings, numberOfTokens, numberOfUniqueTerms, rq, termFrequency
-
-
Constructor Summary
Constructors Constructor Description StaticScoreModifierWeightingModel(java.lang.String[] params)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static double[]castToDoubleArr(float[] f)protected static double[]castToDoubleArr(short[] f)protected static float[]castToFloatArr(double[] f)protected static float[]castToFloatArr(short[] f)java.lang.StringgetInfo()Returns the name of the model.doublegetScoreD(int docid)floatgetScoreF(int docid)java.lang.StringgetSource()protected voidloadDocid2score(int numDocs, java.lang.String inputFile, int column)protected voidloadfloatOOS(java.lang.String inputFile)protected voidloadOOS(java.lang.String inputFile)protected voidloadScorefile(int numDocs, java.lang.String inputFile, int column)static floatmax(float[] a)Return the max of the specified arraystatic floatmin(float[] a)Return the min of the specified arrayprotected static voidprintStats(double[] ar)doublescore(double tf, double docLength)This method provides the contract for implementing weighting models.abstract doublescore(Posting p)Returns scorestatic float[]standardNormalisation(float[] data)Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum.-
Methods inherited from class org.terrier.matching.models.WeightingModel
clone, getOverflowed, getParameter, prepare, setCollectionStatistics, setEntryStatistics, setKeyFrequency, setParameter, setRequest
-
-
-
-
Field Detail
-
staticScores
protected double[] staticScores
-
FstaticScores
protected float[] FstaticScores
-
asFloat
protected final boolean asFloat
-
map
protected final boolean map
-
staticMap
protected gnu.trove.TIntDoubleHashMap staticMap
-
FstaticMap
protected gnu.trove.TIntFloatHashMap FstaticMap
-
source
protected java.lang.String source
-
-
Method Detail
-
getScoreD
public final double getScoreD(int docid)
-
getScoreF
public final float getScoreF(int docid)
-
getSource
public final java.lang.String getSource()
-
score
public abstract double score(Posting p)
Description copied from class:WeightingModelReturns score- Overrides:
scorein classWeightingModel- Returns:
- score
-
getInfo
public java.lang.String getInfo()
Description copied from class:WeightingModelReturns the name of the model.- Specified by:
getInfoin interfaceModel- Specified by:
getInfoin classWeightingModel- Returns:
- java.lang.String
-
score
public double score(double tf, double docLength)Description copied from class:WeightingModelThis method provides the contract for implementing weighting models.- Specified by:
scorein classWeightingModel- Parameters:
tf- The term frequency in the documentdocLength- the document's length- Returns:
- the score assigned to a document with the given tf and docLength, and other preset parameters
-
loadDocid2score
protected void loadDocid2score(int numDocs, java.lang.String inputFile, int column)
-
loadScorefile
protected void loadScorefile(int numDocs, java.lang.String inputFile, int column)
-
loadOOS
protected void loadOOS(java.lang.String inputFile)
-
loadfloatOOS
protected void loadfloatOOS(java.lang.String inputFile)
-
printStats
protected static void printStats(double[] ar)
-
castToDoubleArr
protected static double[] castToDoubleArr(float[] f)
-
castToDoubleArr
protected static double[] castToDoubleArr(short[] f)
-
castToFloatArr
protected static float[] castToFloatArr(double[] f)
-
castToFloatArr
protected static float[] castToFloatArr(short[] f)
-
standardNormalisation
public static float[] standardNormalisation(float[] data)
Normalises the data in the specified array to be in range [0,1], with 0 as the minimum, and 1 as the maximum. RETURNS THE SAME ARRAY OBJECT - i.e. changes are made in place.- Parameters:
data-
-
min
public static final float min(float[] a)
Return the min of the specified array- Parameters:
a- the array- Returns:
- the minimum value in the arrays
-
max
public static final float max(float[] a)
Return the max of the specified array- Parameters:
a- the array- Returns:
- the maximum value in the arrays
-
-