Terrier IR Platform
2.2.1

uk.ac.gla.terrier.matching
Class MatchingQueryTerms

java.lang.Object
  extended by uk.ac.gla.terrier.matching.MatchingQueryTerms
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class MatchingQueryTerms
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Models a query used for matching documents. It is created by creating an instance of this class, and then passing it as an argument to the method obtainQueryTerms of a Query. It contains the query terms, their weights, optionally the corresponding term identifiers and the assocciated term score modifiers. It also stores the document score modifiers for the query.

Version:
$Revision: 1.24 $
Author:
Vassilis Plachouras, Craig Macdonald.
See Also:
Serialized Form

Constructor Summary
MatchingQueryTerms()
          Generate a MatchingQueryTerms object.
MatchingQueryTerms(java.lang.String qid)
          Generate a MatchingQueryTerms object, with the specified query id.
 
Method Summary
 void addDocumentScoreModifier(DocumentScoreModifier dsm)
          Adds a document score modifier for the query.
 void addTermPropertyWeight(java.lang.String term, double w)
          Adds the given weight for an already existing term in the query.
 java.lang.Object clone()
          Performs a deep clone of this object, and all objects it contains.
 DocumentScoreModifier[] getDocumentScoreModifiers()
          Returns the document score modifiers used for the query.
 Query getQuery()
          Returns guess what?
 java.lang.String getQueryId()
          Returns the query id specified when constructing this object.
 int getTermCode(java.lang.String term)
          Returns the assocciated code of the given query term.
 java.lang.String[] getTerms()
          Currently uses Array.sort(Object[]), will retain order of query terms // in future.
 TermScoreModifier[] getTermScoreModifiers(java.lang.String term)
          Returns the term score modifiers assocciated with the given query term.
 double getTermWeight(java.lang.String term)
          Returns the assocciated weight of the given query term.
 double[] getTermWeights()
          Returns the associated weights of the given query terms.
 int length()
          Returns the number of unique terms in the query.
 void normaliseTermWeights()
          This method normalises the term weights by dividing each term weight by the maximum of the terms.
 void setQuery(Query q)
          Allows the manager to set the query that was used to query the system.
 void setQueryId(java.lang.String newId)
          Sets the query id
 void setTermProperty(java.lang.String term)
          Adds a term to the query.
 void setTermProperty(java.lang.String term, double weight)
          Adds a term to the query with a given weight.
 void setTermProperty(java.lang.String term, double weight, TermScoreModifier tsm)
          Sets the weight and a term score modifier for the given query term.
 void setTermProperty(java.lang.String term, int code)
          Sets the term integer identifier for the given query term.
 void setTermProperty(java.lang.String term, TermScoreModifier tsm)
          Sets a term score modifier for the given query term.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatchingQueryTerms

public MatchingQueryTerms()
Generate a MatchingQueryTerms object. Query id will be null.


MatchingQueryTerms

public MatchingQueryTerms(java.lang.String qid)
Generate a MatchingQueryTerms object, with the specified query id.

Parameters:
qid - A string representation of the query id
Method Detail

addDocumentScoreModifier

public void addDocumentScoreModifier(DocumentScoreModifier dsm)
Adds a document score modifier for the query.

Parameters:
dsm - DocumentScoreModifier a document score modifier for the query.

getDocumentScoreModifiers

public DocumentScoreModifier[] getDocumentScoreModifiers()
Returns the document score modifiers used for the query.

Returns:
DocumentScoreModifiers[] an array of the registered document score modifiers for the query. If there are no document score modifiers, then it returns null.

setQuery

public void setQuery(Query q)
Allows the manager to set the query that was used to query the system.

Parameters:
q - The Query, duh

getQuery

public Query getQuery()
Returns guess what?

Returns:
the query

getQueryId

public java.lang.String getQueryId()
Returns the query id specified when constructing this object.

Returns:
String query id, or null if none was specified.

setQueryId

public void setQueryId(java.lang.String newId)
Sets the query id


setTermProperty

public void setTermProperty(java.lang.String term)
Adds a term to the query.

Parameters:
term - String the term to add.

setTermProperty

public void setTermProperty(java.lang.String term,
                            double weight)
Adds a term to the query with a given weight.

Parameters:
term - String the term to add.
weight - double the weight of the added term.

addTermPropertyWeight

public void addTermPropertyWeight(java.lang.String term,
                                  double w)
Adds the given weight for an already existing term in the query. If the term does not exist, it is added to the arraylist, with weight w

Parameters:
term - String the term for which we add the weight.
w - double the added weight.

setTermProperty

public void setTermProperty(java.lang.String term,
                            int code)
Sets the term integer identifier for the given query term.

Parameters:
term - String the term for which the term identifier is set.
code - int the term identifier.

normaliseTermWeights

public void normaliseTermWeights()
This method normalises the term weights by dividing each term weight by the maximum of the terms.


setTermProperty

public void setTermProperty(java.lang.String term,
                            TermScoreModifier tsm)
Sets a term score modifier for the given query term.

Parameters:
term - String the term for which to add a term score modifier.
tsm - TermScoreModifier the term score modifier to apply for the given term.

setTermProperty

public void setTermProperty(java.lang.String term,
                            double weight,
                            TermScoreModifier tsm)
Sets the weight and a term score modifier for the given query term.

Parameters:
term - String the term for which we set the properties.
weight - int the weight of the query term.
tsm - TermScoreModifier the term score modifier applied for the query term.

getTermWeight

public double getTermWeight(java.lang.String term)
Returns the assocciated weight of the given query term.

Parameters:
term - String the query term for which the weight is returned.
Returns:
double the weight of the given query term. If the term is not part of the query, then it returns 0.

getTermWeights

public double[] getTermWeights()
Returns the associated weights of the given query terms.

Returns:
double The weights of the given terms in a double array.

getTermCode

public int getTermCode(java.lang.String term)
Returns the assocciated code of the given query term.

Parameters:
term - String the query term for which the weight is returned.
Returns:
int the term code of the given query term, or -1 if the term does not appear in the query.

getTermScoreModifiers

public TermScoreModifier[] getTermScoreModifiers(java.lang.String term)
Returns the term score modifiers assocciated with the given query term.

Parameters:
term - String a query term.
Returns:
TermScoreModifiers[] the term score modifiers associated with the given query term, or null if the query term is not part of the query.

getTerms

public java.lang.String[] getTerms()
Currently uses Array.sort(Object[]), will retain order of query terms // in future. TODO return and rewrite this method


length

public int length()
Returns the number of unique terms in the query.

Returns:
int the number of unique terms in the query.

clone

public java.lang.Object clone()
Performs a deep clone of this object, and all objects it contains. This allows a MQT to be copied, and changed without affecting the original object.

Overrides:
clone in class java.lang.Object

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow