jsat.text.wordweighting
Class OkapiBM25
- java.lang.Object
-
- jsat.text.wordweighting.OkapiBM25
-
- All Implemented Interfaces:
- java.io.Serializable, Function, IndexFunction, WordWeighting
public class OkapiBM25 extends java.lang.Object implements WordWeighting
Implements the Okapi BM25 word weighting scheme.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description OkapiBM25()Creates a new Okapi objectOkapiBM25(double k1, double b)Creates a new Okapi object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyTo(Vec vec)The implementation may want to pre compute come values based on the vector it is about to be applied to.doubleindexFunc(double value, int index)An index function, meant to be applied to vectors where the value to be computed may vary based on the position in the vector of the value.voidsetWeight(java.util.List<? extends Vec> allDocuments, java.util.List<java.lang.Integer> df)Prepares the word weighting to be performed on a data set.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.math.IndexFunction
f
-
Methods inherited from interface jsat.math.Function
f, f, forwardDifference
-
-
-
-
Constructor Detail
-
OkapiBM25
public OkapiBM25()
Creates a new Okapi object
-
OkapiBM25
public OkapiBM25(double k1, double b)Creates a new Okapi object- Parameters:
k1- the non negative coefficient to apply to the term frequencyb- the coefficient to apply to the document length in the range [0,1]
-
-
Method Detail
-
setWeight
public void setWeight(java.util.List<? extends Vec> allDocuments, java.util.List<java.lang.Integer> df)
Description copied from interface:WordWeightingPrepares the word weighting to be performed on a data set. This should be called once before being applied to any vectors. Different WordWeightings may require different amounts of computation to set up.- Specified by:
setWeightin interfaceWordWeighting- Parameters:
allDocuments- the list of all vectors that make up the set of documents. The word vectors should be unmodified, containing the value of how many times a word appeared in the document for each index.df- a list mapping each integer index of a word to how many times that word occurred in total
-
applyTo
public void applyTo(Vec vec)
Description copied from interface:WordWeightingThe implementation may want to pre compute come values based on the vector it is about to be applied to. This should be called in place ofVec.applyIndexFunction(jsat.math.IndexFunction). The vector should be in a bag-of-words form where each index value indicates how many times the word for that index occurred in the document represented by the vector.- Specified by:
applyToin interfaceWordWeighting- Parameters:
vec- the vector to set up for and then alter by invokingVec.applyIndexFunction(jsat.math.IndexFunction)on
-
indexFunc
public double indexFunc(double value, int index)Description copied from interface:IndexFunctionAn index function, meant to be applied to vectors where the value to be computed may vary based on the position in the vector of the value.- Specified by:
indexFuncin interfaceIndexFunction- Parameters:
value- the value at the specified indexindex- the index the value is from- Returns:
- the computed result. If a negative index was given, the function should return 0.0 if indexFunc(0,indx) would return zero for all valid indices. If this is not the case, any non zero value should be returned.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG