Package org.terrier.matching.models
Class DFRWeightingModel
- java.lang.Object
-
- org.terrier.matching.models.WeightingModel
-
- org.terrier.matching.models.DFRWeightingModel
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Model
public class DFRWeightingModel extends WeightingModel
This class implements a modular Divergence from Randomness weighting model. Components in the model are specified individually, with many implementations provided: org.terrier.matching.models.basicmodel; org.terrier.matching.models.aftereffect; and org.terrier.matching.models.normalisation. A class name for each component should be specific in parenthesis after DFRWeightingModel. Moreover, besides the basic model, the other two components can be either specified or disabled.Examples:
- Author:
- Ben He
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AfterEffect
afterEffect
The applied model for after effect (aka.protected java.lang.String
AFTEREFFECT_PREFIX
The prefix of the package of the first normalisation methods by after effect.protected BasicModel
basicModel
The applied basic model for randomness.protected java.lang.String
BASICMODEL_PREFIX
The prefix of the package of the basic models for randomness.protected boolean
ENABLE_AFTEREFFECT
A boolean that indicates if the first normalisation by after effect is enabled.protected boolean
ENABLE_NORMALISATION
A boolean that indicates if the frequency normalisation is enabled.protected static org.slf4j.Logger
logger
protected Normalisation
normalisation
The applied frequency normalisation method.protected java.lang.String
NORMALISATION_PREFIX
The prefix of the package of the frequency normalisation methods.protected double
parameter
The parameter of the frequency normalisation component.-
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 DFRWeightingModel(java.lang.String[] components)
The default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DFRWeightingModel
clone()
Clone this weighting modeljava.lang.String
getInfo()
Returns the name of the model.double
getParameter()
Return the parameter set by setParameter()protected void
initialise(java.lang.String basicModelName, java.lang.String afterEffectName, java.lang.String normalisationName)
Initialise the components in the DFR model.protected void
initialise(java.lang.String basicModelName, java.lang.String afterEffectName, java.lang.String normalisationName, double _parameter)
Initialise the components in the DFR model.double
score(double tf, double docLength)
Compute a weight for a term in a document.void
setCollectionStatistics(CollectionStatistics _cs)
Sets collection statisticsvoid
setEntryStatistics(EntryStatistics _es)
Sets entry statistics.void
setParameter(double value)
Set the frequency normalisation parameter.-
Methods inherited from class org.terrier.matching.models.WeightingModel
getOverflowed, prepare, score, setKeyFrequency, setRequest
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
basicModel
protected BasicModel basicModel
The applied basic model for randomness.
-
afterEffect
protected AfterEffect afterEffect
The applied model for after effect (aka. first normalisation).
-
normalisation
protected Normalisation normalisation
The applied frequency normalisation method.
-
NORMALISATION_PREFIX
protected final java.lang.String NORMALISATION_PREFIX
The prefix of the package of the frequency normalisation methods.- See Also:
- Constant Field Values
-
BASICMODEL_PREFIX
protected final java.lang.String BASICMODEL_PREFIX
The prefix of the package of the basic models for randomness.- See Also:
- Constant Field Values
-
AFTEREFFECT_PREFIX
protected final java.lang.String AFTEREFFECT_PREFIX
The prefix of the package of the first normalisation methods by after effect.- See Also:
- Constant Field Values
-
parameter
protected double parameter
The parameter of the frequency normalisation component.
-
ENABLE_NORMALISATION
protected boolean ENABLE_NORMALISATION
A boolean that indicates if the frequency normalisation is enabled.
-
ENABLE_AFTEREFFECT
protected boolean ENABLE_AFTEREFFECT
A boolean that indicates if the first normalisation by after effect is enabled.
-
-
Constructor Detail
-
DFRWeightingModel
public DFRWeightingModel(java.lang.String[] components)
The default constructor. Takes an array of strings to define the Basic Model, the After Effect component and the Normalisation component. If the array is less than 3 items in length, then empty strings will be passed instead of the After Effect and/or Normalisation components.- Parameters:
components
- Corresponds to the names of the 3 DFR weighting models component names, as passed to initialise().
-
-
Method Detail
-
clone
public DFRWeightingModel clone()
Description copied from class:WeightingModel
Clone this weighting model- Overrides:
clone
in classWeightingModel
-
initialise
protected void initialise(java.lang.String basicModelName, java.lang.String afterEffectName, java.lang.String normalisationName)
Initialise the components in the DFR model. For each component, if a package is not specified, then a prefix will be applied. These are BASICMODEL_PREFIX, AFTEREFFECT_PREFIX and NORMALISATION_PREFIX respectively. Note that NORMALISATION_PREFIX includes a partial class name.- Parameters:
basicModelName
- The name of the applied basic model for randomness. This component must be specified and can NOT be an empty string.afterEffectName
- The name of the applied first normalisation by after effect. An empty string to disable this component.normalisationName
- The name of the applied frequency normalisation component. An empty string to disable this component.
-
initialise
protected void initialise(java.lang.String basicModelName, java.lang.String afterEffectName, java.lang.String normalisationName, double _parameter)
Initialise the components in the DFR model. For each component, if a package is not specified, then a prefix will be applied. These are BASICMODEL_PREFIX, AFTEREFFECT_PREFIX and NORMALISATION_PREFIX respectively. Note that NORMALISATION_PREFIX includes a partial class name.- Parameters:
basicModelName
- The name of the applied basic model for randomness. This component must be specified and can NOT be an empty string.afterEffectName
- The name of the applied first normalisation by after effect. An empty string to disable this component.normalisationName
- The name of the applied frequency normalisation component. An empty string to disable this component._parameter
- The applied parameter value of the frequency normalisation.
-
setParameter
public void setParameter(double value)
Set the frequency normalisation parameter.- Specified by:
setParameter
in interfaceModel
- Overrides:
setParameter
in classWeightingModel
- Parameters:
value
- The given parameter value.
-
getParameter
public double getParameter()
Return the parameter set by setParameter()- Specified by:
getParameter
in interfaceModel
- Overrides:
getParameter
in classWeightingModel
- Returns:
- parameter double value
-
getInfo
public final java.lang.String getInfo()
Returns the name of the model.- Specified by:
getInfo
in interfaceModel
- Specified by:
getInfo
in classWeightingModel
- Returns:
- The name of the model.
-
score
public final double score(double tf, double docLength)
Compute a weight for a term in a document.- 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
-
setCollectionStatistics
public void setCollectionStatistics(CollectionStatistics _cs)
Description copied from class:WeightingModel
Sets collection statistics- Overrides:
setCollectionStatistics
in classWeightingModel
-
setEntryStatistics
public void setEntryStatistics(EntryStatistics _es)
Sets entry statistics.- Overrides:
setEntryStatistics
in classWeightingModel
-
-