Package org.terrier.matching.tsms
Class TermInFieldModifier
- java.lang.Object
-
- org.terrier.matching.models.WeightingModel
-
- org.terrier.matching.tsms.TermInFieldModifier
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Model
,IndexConfigurable
public class TermInFieldModifier extends WeightingModel implements IndexConfigurable
Resets the scores of documents according to whether a term appears in a given set of fields. This class implements the TermScoreModifier interface.- Author:
- Vassilis Plachouras
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
field
The fields that a query term should appear in.protected Index
index
protected boolean
requirement
The requirement.-
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 TermInFieldModifier(java.lang.String _field)
Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.TermInFieldModifier(java.lang.String _field, boolean req)
Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getInfo()
Returns the name of the model.java.lang.String
getName()
Returns the name of the class and whether the query term is required.void
prepare()
preparedouble
score(double tf, double docLength)
This method provides the contract for implementing weighting models.double
score(Posting _p)
Returns scorevoid
setIndex(Index i)
Tell the implementer which Index object it is associated with.-
Methods inherited from class org.terrier.matching.models.WeightingModel
clone, getOverflowed, getParameter, setCollectionStatistics, setEntryStatistics, setKeyFrequency, setParameter, setRequest
-
-
-
-
Field Detail
-
index
protected transient Index index
-
field
protected java.lang.String field
The fields that a query term should appear in.
-
requirement
protected boolean requirement
The requirement. By default it is true.
-
-
Constructor Detail
-
TermInFieldModifier
public TermInFieldModifier(java.lang.String _field)
Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.- Parameters:
_field
- String a field
-
TermInFieldModifier
public TermInFieldModifier(java.lang.String _field, boolean req)
Constructs an instance of a TermInFieldModifier given a field that the corresponding query term should appear in.- Parameters:
_field
- String a fieldreq
- boolean the requirement for this field. If req is true, then the term is required to appear in the field (this is the default behaviour), otherwise the term should not appear in the field.
-
-
Method Detail
-
prepare
public void prepare()
prepare- Overrides:
prepare
in classWeightingModel
-
score
public double score(Posting _p)
Returns score- Overrides:
score
in classWeightingModel
- Returns:
- score
-
getName
public java.lang.String getName()
Returns the name of the class and whether the query term is required.
-
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
-
setIndex
public void setIndex(Index i)
Tell the implementer which Index object it is associated with.- Specified by:
setIndex
in interfaceIndexConfigurable
- Parameters:
i
- Index object to use
-
-