edu.umd.cloud9.collection.trec
Class TrecDocnoMapping

java.lang.Object
  extended by edu.umd.cloud9.collection.trec.TrecDocnoMapping
All Implemented Interfaces:
DocnoMapping

public class TrecDocnoMapping
extends Object
implements DocnoMapping

Object that maps between TREC docids (String identifiers) to docnos (sequentially-numbered ints). The main of this class provides a simple program for accessing docno mappings. Command-line arguments are as follows:

Author:
Jimmy Lin

Constructor Summary
TrecDocnoMapping()
          Creates a TrecDocnoMapping object.
 
Method Summary
 String getDocid(int docno)
          Returns the docid for a particular docno.
 int getDocno(String docid)
          Returns the docno for a particular docid.
 void loadMapping(Path p, FileSystem fs)
          Loads a mapping file containing the docid/docno mappings.
static void main(String[] args)
          Simple program the provides access to the docno/docid mappings.
static String[] readMappingData(Path p, FileSystem fs)
          Reads a mappings file into memory.
static void writeMappingData(Path input, Path output, FileSystem fs)
          Creates a mappings file from the contents of a flat text file containing docid to docno mappings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrecDocnoMapping

public TrecDocnoMapping()
Creates a TrecDocnoMapping object.

Method Detail

getDocno

public int getDocno(String docid)
Description copied from interface: DocnoMapping
Returns the docno for a particular docid.

Specified by:
getDocno in interface DocnoMapping
Parameters:
docid - the docid
Returns:
the docno for the docid

getDocid

public String getDocid(int docno)
Description copied from interface: DocnoMapping
Returns the docid for a particular docno.

Specified by:
getDocid in interface DocnoMapping
Parameters:
docno - the docno
Returns:
the docid for the docno

loadMapping

public void loadMapping(Path p,
                        FileSystem fs)
                 throws IOException
Description copied from interface: DocnoMapping
Loads a mapping file containing the docid/docno mappings.

Specified by:
loadMapping in interface DocnoMapping
Parameters:
p - path to the mappings file
fs - reference to the FileSystem
Throws:
IOException

writeMappingData

public static void writeMappingData(Path input,
                                    Path output,
                                    FileSystem fs)
                             throws IOException
Creates a mappings file from the contents of a flat text file containing docid to docno mappings. This method is used by NumberTrecDocuments internally.

Parameters:
input - flat text file containing docid to docno mappings
output - output mappings data file
fs - FileSystem to write to
Throws:
IOException

readMappingData

public static String[] readMappingData(Path p,
                                       FileSystem fs)
                                throws IOException
Reads a mappings file into memory.

Parameters:
p - path to the mappings data file
fs - appropriate FileSystem
Returns:
an array of docids; the index position of each docid is its docno
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Simple program the provides access to the docno/docid mappings.

Throws:
IOException