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
ObjectOutputStream
file 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
TIntDoubleHashMap
saved in anObjectOutputStream
file
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 boolean
asFloat
protected gnu.trove.TIntFloatHashMap
FstaticMap
protected float[]
FstaticScores
protected boolean
map
protected java.lang.String
source
protected gnu.trove.TIntDoubleHashMap
staticMap
protected 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.String
getInfo()
Returns the name of the model.double
getScoreD(int docid)
float
getScoreF(int docid)
java.lang.String
getSource()
protected void
loadDocid2score(int numDocs, java.lang.String inputFile, int column)
protected void
loadfloatOOS(java.lang.String inputFile)
protected void
loadOOS(java.lang.String inputFile)
protected void
loadScorefile(int numDocs, java.lang.String inputFile, int column)
static float
max(float[] a)
Return the max of the specified arraystatic float
min(float[] a)
Return the min of the specified arrayprotected static void
printStats(double[] ar)
double
score(double tf, double docLength)
This method provides the contract for implementing weighting models.abstract double
score(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:WeightingModel
Returns score- Overrides:
score
in classWeightingModel
- Returns:
- score
-
getInfo
public java.lang.String getInfo()
Description copied from class:WeightingModel
Returns the name of the model.- Specified by:
getInfo
in interfaceModel
- Specified by:
getInfo
in classWeightingModel
- 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 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
-
-