org.terrier.querying.parser
Class SingleTermQuery

java.lang.Object
  extended by org.terrier.querying.parser.Query
      extended by org.terrier.querying.parser.SingleTermQuery
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SingleTermQuery
extends Query

Models a query of a single term. The single term queries can be of the forms:
term
+term
-term
field:term
The term can be optionally followed by a weight, as shown below:
term^weight
+term^weight
-term^weight
field:term^weight
where weight is a real number. If no weight is specified, then the default weight is 1.0.

Author:
Vassilis Plachouras
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.terrier.querying.parser.Query
Query.ForEachQueryNode
 
Field Summary
protected static boolean lowercase
          checks whether the terms should be lowercase.
 
Fields inherited from class org.terrier.querying.parser.Query
child, tmpSTQ
 
Constructor Summary
SingleTermQuery()
          An empty default constructor.
SingleTermQuery(java.lang.String t)
          Creates an instance of the class for the given query term.
SingleTermQuery(java.lang.String t, int r)
          Creates an instance of the class for the given query term that should be either required or not.
 
Method Summary
 boolean applyTermPipeline(TermPipelineAccessor tpa)
          Puts the query term in the given term pipeline, which is accessed through the given accessor object.
 java.lang.Object clone()
          Deep copy this Query object
 int getRequired()
          Indicates whether the query term is required, or it isn't required to appear in the retrieved documents.
 java.lang.String getTerm()
          Gets the query term.
protected  void getTerms(java.util.List<Query> alist)
          Adds the query term in the given list of query terms.
 void getTermsOf(java.lang.Class<? extends Query> c, java.util.List<Query> alist, boolean req)
          An empty method because the single term query cannot have children.
 double getWeight()
          Returns the weight of the query term.
 boolean obtainControls(java.util.Set<java.lang.String> allowed, java.util.Map<java.lang.String,java.lang.String> controls)
          This object cannot contain any controls, so this method will always return false.
 void obtainQueryTerms(MatchingQueryTerms terms)
          Stores the term of the single term query in the given hash map.
 void obtainQueryTerms(MatchingQueryTerms terms, boolean _required)
          Stores the term of the single term query in the given hash map.
 java.lang.String parseTree()
          Returns the parse tree for the query as a string
 void setRequired(int r)
          Sets the value of the required switch.
 void setTerm(java.lang.String t)
          Sets the string of the term.
 void setWeight(double w)
          Sets the weight of the query term.
 java.lang.String toString()
          Returns a string representation of the query term.
 
Methods inherited from class org.terrier.querying.parser.Query
apply, obtainAllOf, setChild
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lowercase

protected static final boolean lowercase
checks whether the terms should be lowercase.

Constructor Detail

SingleTermQuery

public SingleTermQuery()
An empty default constructor.


SingleTermQuery

public SingleTermQuery(java.lang.String t)
Creates an instance of the class for the given query term.

Parameters:
t - String one query term.

SingleTermQuery

public SingleTermQuery(java.lang.String t,
                       int r)
Creates an instance of the class for the given query term that should be either required or not.

Parameters:
t - String one query term.
r - int indicates whether the term is required or not.
Method Detail

clone

public java.lang.Object clone()
Deep copy this Query object

Overrides:
clone in class Query

setRequired

public void setRequired(int r)
Sets the value of the required switch.

Parameters:
r - int the value of the required switch.

setTerm

public void setTerm(java.lang.String t)
Sets the string of the term.

Parameters:
t - String the query term.

getTerm

public java.lang.String getTerm()
Gets the query term.

Returns:
String the query term.

getRequired

public int getRequired()
Indicates whether the query term is required, or it isn't required to appear in the retrieved documents. A value of zero means that this has been left unspecified.

Returns:
int an indication of whether the query term should appear in the retrieved documents, or not.

toString

public java.lang.String toString()
Returns a string representation of the query term.

Specified by:
toString in class Query
Returns:
String a string representation of the query term.

setWeight

public void setWeight(double w)
Sets the weight of the query term.

Parameters:
w - double the weight of the query term.

getWeight

public double getWeight()
Returns the weight of the query term.

Returns:
double the weight of the query term.

applyTermPipeline

public boolean applyTermPipeline(TermPipelineAccessor tpa)
Puts the query term in the given term pipeline, which is accessed through the given accessor object.

Overrides:
applyTermPipeline in class Query
Parameters:
tpa - TermPipelineAccessor the object that provides the term pipeline.
Returns:
boolean true if the query is not empty, otherwise returns false.

obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms)
Stores the term of the single term query in the given hash map.

Overrides:
obtainQueryTerms in class Query
Parameters:
terms - the hashmap in which to store the query terms.

obtainQueryTerms

public void obtainQueryTerms(MatchingQueryTerms terms,
                             boolean _required)
Stores the term of the single term query in the given hash map.

Overrides:
obtainQueryTerms in class Query
Parameters:
terms - the hashmap in which to store the query terms.
_required - indicates whether the query term is required or not.

getTerms

protected void getTerms(java.util.List<Query> alist)
Adds the query term in the given list of query terms.

Overrides:
getTerms in class Query
Parameters:
alist - ArrayList the array list that stores the query terms.

obtainControls

public boolean obtainControls(java.util.Set<java.lang.String> allowed,
                              java.util.Map<java.lang.String,java.lang.String> controls)
This object cannot contain any controls, so this method will always return false.

Overrides:
obtainControls in class Query
Returns:
false

getTermsOf

public void getTermsOf(java.lang.Class<? extends Query> c,
                       java.util.List<Query> alist,
                       boolean req)
An empty method because the single term query cannot have children.

Specified by:
getTermsOf in class Query
Parameters:
c - Class a class of queries.
alist - ArrayList the list of query terms.
req - boolean indicates whether the subqueries are required or not.

parseTree

public java.lang.String parseTree()
Description copied from class: Query
Returns the parse tree for the query as a string

Specified by:
parseTree in class Query


Terrier 3.5. Copyright © 2004-2011 University of Glasgow