org.terrier.matching.tsms
Class TermInFieldModifier

java.lang.Object
  extended by org.terrier.matching.models.WeightingModel
      extended by org.terrier.matching.tsms.TermInFieldModifier
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Model, TermScoreModifier, IndexConfigurable

public class TermInFieldModifier
extends WeightingModel
implements TermScoreModifier, 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
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, documentFrequency, i, keyFrequency, numberOfDocuments, numberOfPointers, numberOfTokens, numberOfUniqueTerms, termFrequency
 
Constructor Summary
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
 java.lang.Object clone()
          Clone this weighting model
 java.lang.String getInfo()
          Returns the name of the model.
 java.lang.String getName()
          Returns the name of the modifier.
 int modifyScores(double[] scores, int[][] pointers)
          Resets the scores of documents for a particular term, based on the fields a term appears in documents.
 void prepare()
          prepare
 double score(double tf, double docLength)
          This method provides the contract for implementing weighting models.
 double score(double tf, double docLength, double n_t, double F_t, double keyFrequency)
          This method provides the contract for implementing weighting models.
 double score(Posting _p)
          Returns score
 void setIndex(Index i)
          Tell the implementer which Index object it is associated with.
 
Methods inherited from class org.terrier.matching.models.WeightingModel
getOverflowed, getParameter, setAverageDocumentLength, setCollectionStatistics, setDocumentFrequency, setEntryStatistics, setKeyFrequency, setNumberOfDocuments, setNumberOfPointers, setNumberOfTokens, setNumberOfUniqueTerms, setParameter, setRequest, setTermFrequency, stirlingPower
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.terrier.matching.tsms.TermScoreModifier
hashCode
 

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 field
req - 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

modifyScores

public int modifyScores(double[] scores,
                        int[][] pointers)
Resets the scores of documents for a particular term, based on the fields a term appears in documents.

Specified by:
modifyScores in interface TermScoreModifier
Parameters:
scores - double[] the scores of the documents.
pointers - int[][] the pointers read from the inverted file for a particular query term.
Returns:
the number of documents for which the scores were modified.

prepare

public void prepare()
prepare

Overrides:
prepare in class WeightingModel

score

public double score(Posting _p)
Returns score

Overrides:
score in class WeightingModel
Returns:
score

getName

public java.lang.String getName()
Returns the name of the modifier.

Specified by:
getName in interface TermScoreModifier
Returns:
String the name of the modifier.

clone

public java.lang.Object clone()
Clone this weighting model

Specified by:
clone in interface TermScoreModifier
Overrides:
clone in class WeightingModel

getInfo

public java.lang.String getInfo()
Description copied from class: WeightingModel
Returns the name of the model.

Specified by:
getInfo in interface Model
Specified by:
getInfo in class WeightingModel
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 class WeightingModel
Parameters:
tf - The term frequency in the document
docLength - the document's length
Returns:
the score assigned to a document with the given tf and docLength, and other preset parameters

score

public double score(double tf,
                    double docLength,
                    double n_t,
                    double F_t,
                    double keyFrequency)
Description copied from class: WeightingModel
This method provides the contract for implementing weighting models.

Specified by:
score in class WeightingModel
Parameters:
tf - The term frequency in the document
docLength - the document's length
n_t - The document frequency of the term
F_t - the term frequency in the collection
keyFrequency - the term frequency in the query
Returns:
the score returned by the implemented weighting model.

setIndex

public void setIndex(Index i)
Tell the implementer which Index object it is associated with.

Specified by:
setIndex in interface IndexConfigurable
Parameters:
i - Index object to use


Terrier 3.5. Copyright © 2004-2011 University of Glasgow