Terrier IR Platform
2.2.1

uk.ac.gla.terrier.structures
Class TRECQuery

java.lang.Object
  extended by uk.ac.gla.terrier.structures.TRECQuery
Direct Known Subclasses:
SingleLineTRECQuery

public class TRECQuery
extends java.lang.Object

This class is used for reading the queries from TREC topic files.

Properties:

Version:
$Revision: 1.41 $
Author:
Ben He & Craig Macdonald

Constructor Summary
TRECQuery()
          Constructs an instance of TRECQuery, that reads and stores all the queries from the files specified in the trec.topics.list file.
TRECQuery(java.io.File queryfile)
          Constructs an instance of TRECQuery that reads and stores all the queries from a the specified query file.
TRECQuery(java.lang.String queryfilename)
          Constructs an instance of TRECQuery that reads and stores all the queries from a file with the specified filename.
 
Method Summary
 boolean extractQuery(java.lang.String queryfilename, java.util.Vector<java.lang.String> vecStringQueries, java.util.Vector<java.lang.String> vecStringIds)
          Extracts and stores all the queries from a query file.
 int getIndexOfCurrentQuery()
          Returns the index of the last obtained query.
 int getNumberOfQueries()
          Returns the number of the queries read from the processed topic files.
 java.lang.String getQuery(java.lang.String queryNo)
          Return the query for the given query number.
 java.lang.String getQueryId()
          Returns the query identifier of the last query fetched, or the first one, if none has been fetched yet.
 java.lang.String[] getQueryIds()
          Returns the query ids
 java.lang.String[] getTopicFilenames()
          Returns the filenames of the topic files from which the queries were extracted
 boolean hasMoreQueries()
          Test if there are more queries to process.
 java.lang.String nextQuery()
          Returns a query.
 void reset()
          Resets the query index.
 java.lang.String[] toArray()
          Returns the queries in an array of strings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TRECQuery

public TRECQuery()
Constructs an instance of TRECQuery, that reads and stores all the queries from the files specified in the trec.topics.list file.


TRECQuery

public TRECQuery(java.io.File queryfile)
Constructs an instance of TRECQuery that reads and stores all the queries from a the specified query file.

Parameters:
queryfile - File the file containing the queries.

TRECQuery

public TRECQuery(java.lang.String queryfilename)
Constructs an instance of TRECQuery that reads and stores all the queries from a file with the specified filename.

Parameters:
queryfilename - String the name of the file containing all the queries.
Method Detail

extractQuery

public boolean extractQuery(java.lang.String queryfilename,
                            java.util.Vector<java.lang.String> vecStringQueries,
                            java.util.Vector<java.lang.String> vecStringIds)
Extracts and stores all the queries from a query file.

Parameters:
queryfilename - String the name of a file containing topics.
vecStringQueries - Vector a vector containing the queries as strings.
vecStringIds - Vector a vector containing the query identifiers as strings.
Returns:
boolean true if some queries were successfully extracted.

getIndexOfCurrentQuery

public int getIndexOfCurrentQuery()
Returns the index of the last obtained query.

Returns:
int the index of the last obtained query.

getNumberOfQueries

public int getNumberOfQueries()
Returns the number of the queries read from the processed topic files.

Returns:
int the number of topics contained in the processed topic files.

getTopicFilenames

public java.lang.String[] getTopicFilenames()
Returns the filenames of the topic files from which the queries were extracted


getQuery

public java.lang.String getQuery(java.lang.String queryNo)
Return the query for the given query number.

Parameters:
queryNo - String The number of a query.
Returns:
String the string representing the query.

hasMoreQueries

public boolean hasMoreQueries()
Test if there are more queries to process.

Returns:
boolean true if there are more queries to process, otherwise returns false.

nextQuery

public java.lang.String nextQuery()
Returns a query.

Returns:
String the next query.

getQueryId

public java.lang.String getQueryId()
Returns the query identifier of the last query fetched, or the first one, if none has been fetched yet.

Returns:
String the query number of a query.

getQueryIds

public java.lang.String[] getQueryIds()
Returns the query ids

Returns:
String array containing the query ids.
Since:
2.2

toArray

public java.lang.String[] toArray()
Returns the queries in an array of strings

Returns:
String[] an array containing the strings that represent the queries.

reset

public void reset()
Resets the query index.


Terrier IR Platform
2.2.1

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