org.terrier.matching
Class TRECResultsMatching

java.lang.Object
  extended by org.terrier.matching.TRECResultsMatching
All Implemented Interfaces:
Matching

public class TRECResultsMatching
extends java.lang.Object
implements Matching

A matching implementation that retrieves results from a TREC result file rather than the current index. Such a result file must be compatible with trec_eval, i.e., it should have the following format:

queryID Q0 docno score rank label

Properties:

Author:
Craig Macdonald, Rodrygo Santos

Nested Class Summary
static class TRECResultsMatching.InputFormat
          input format
 
Field Summary
protected  CollectionStatistics collStats
          The underlying collections statistics.
protected  int docid
          The current read document identifier.
protected static java.lang.String DSMNS
          The default namespace for document score modifiers.
protected  java.util.List<DocumentScoreModifier> dsms
          The list of document score modifiers to be applied.
protected  java.lang.String filename
          The TREC results filename.
protected  TRECResultsMatching.InputFormat format
          The input format to use when parsing document identifiers.
protected  boolean found
          Whether the current query was found in the results file.
protected  Index index
          The underlying index.
protected  org.apache.log4j.Logger logger
          This object's logger.
protected  int maxResults
          The maximum number of results to read per query.
protected  boolean parseScores
          Whether document scores should be parsed from the results file.
protected  java.io.BufferedReader reader
          The TREC results file reader.
protected  boolean reset
          Whether the current file has already been reset.
protected  double score
          The current read score.
protected static java.util.regex.Pattern SPLIT_SPACE_PLUS
           
 
Constructor Summary
TRECResultsMatching(Index _index)
          Contructs an instance of the TRECResultsMatching given an index.
TRECResultsMatching(Index _index, java.lang.String _filename)
          Contructs an instance of the TRECResultsMatching.
TRECResultsMatching(Index _index, java.lang.String _filename, java.lang.String defDSMs)
          Contructs an instance of the TRECResultsMatching.
 
Method Summary
protected  void finalize()
           
 CollectionStatistics getCollectionStatistics()
          Returns collection statistics.
protected  int getDocid(java.lang.String docno)
           
 java.lang.String getInfo()
          Return a human readable description of this Matching class
protected  void initDSMs(java.lang.String defDSMs)
           
 ResultSet match(java.lang.String _qid, MatchingQueryTerms mqt)
          Get a ResultSet for the given query terms.
protected  boolean read(java.lang.String _qid)
           
protected  void reopen()
           
 void setCollectionStatistics(CollectionStatistics _collStats)
          Update the collection statistics being used by this matching instance
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPLIT_SPACE_PLUS

protected static final java.util.regex.Pattern SPLIT_SPACE_PLUS

index

protected Index index
The underlying index.


collStats

protected CollectionStatistics collStats
The underlying collections statistics.


DSMNS

protected static final java.lang.String DSMNS
The default namespace for document score modifiers.

See Also:
Constant Field Values

dsms

protected java.util.List<DocumentScoreModifier> dsms
The list of document score modifiers to be applied.


filename

protected java.lang.String filename
The TREC results filename.


reader

protected java.io.BufferedReader reader
The TREC results file reader.


format

protected final TRECResultsMatching.InputFormat format
The input format to use when parsing document identifiers.


parseScores

protected final boolean parseScores
Whether document scores should be parsed from the results file.


maxResults

protected final int maxResults
The maximum number of results to read per query.


docid

protected int docid
The current read document identifier.


score

protected double score
The current read score.


found

protected boolean found
Whether the current query was found in the results file.


reset

protected boolean reset
Whether the current file has already been reset.


logger

protected org.apache.log4j.Logger logger
This object's logger.

Constructor Detail

TRECResultsMatching

public TRECResultsMatching(Index _index)
                    throws java.io.IOException
Contructs an instance of the TRECResultsMatching given an index.

Parameters:
_index -
Throws:
java.io.IOException

TRECResultsMatching

public TRECResultsMatching(Index _index,
                           java.lang.String _filename)
                    throws java.io.IOException
Contructs an instance of the TRECResultsMatching.

Parameters:
_index -
_filename -
Throws:
java.io.IOException

TRECResultsMatching

public TRECResultsMatching(Index _index,
                           java.lang.String _filename,
                           java.lang.String defDSMs)
                    throws java.io.IOException
Contructs an instance of the TRECResultsMatching.

Parameters:
_index -
_filename -
defDSMs -
Throws:
java.io.IOException
Method Detail

reopen

protected void reopen()
               throws java.io.IOException
Throws:
java.io.IOException

initDSMs

protected void initDSMs(java.lang.String defDSMs)

getInfo

public java.lang.String getInfo()
Description copied from interface: Matching
Return a human readable description of this Matching class

Specified by:
getInfo in interface Matching

getDocid

protected int getDocid(java.lang.String docno)
                throws java.io.IOException
Throws:
java.io.IOException

read

protected boolean read(java.lang.String _qid)
                throws java.io.IOException
Throws:
java.io.IOException

match

public ResultSet match(java.lang.String _qid,
                       MatchingQueryTerms mqt)
                throws java.io.IOException
Description copied from interface: Matching
Get a ResultSet for the given query terms.

Specified by:
match in interface Matching
Parameters:
_qid - - some ID of the query
mqt - - query terms to match
Returns:
ResultSet - the matched results
Throws:
java.io.IOException - if a problem occurs during matching

setCollectionStatistics

public void setCollectionStatistics(CollectionStatistics _collStats)
Description copied from interface: Matching
Update the collection statistics being used by this matching instance

Specified by:
setCollectionStatistics in interface Matching
Parameters:
_collStats - CollectionStatistics to use during matching

getCollectionStatistics

public CollectionStatistics getCollectionStatistics()
Returns collection statistics.

Returns:
collection statistics

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Terrier 3.5. Copyright © 2004-2011 University of Glasgow