edu.umd.cloud9.collection.line
Class TextDocnoMapping

java.lang.Object
  extended by edu.umd.cloud9.collection.line.TextDocnoMapping
All Implemented Interfaces:
DocnoMapping

public class TextDocnoMapping
extends Object
implements DocnoMapping

Object that maps between docids (String identifiers) to docnos (sequentially-numbered ints) for regular text documents.

Author:
Jimmy Lin

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.umd.cloud9.collection.DocnoMapping
DocnoMapping.Builder, DocnoMapping.BuilderUtils, DocnoMapping.DefaultBuilderOptions
 
Constructor Summary
TextDocnoMapping()
          Creates a TrecDocnoMapping object
 
Method Summary
 DocnoMapping.Builder getBuilder()
          Returns the builder for this mapping.
 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.
static void main(String[] args)
          Simple program the provides access to the docno/docid mappings.
static String[] readDocnoData(Path p, FileSystem fs)
          Reads a mappings file into memory.
static void writeDocnoData(String inputFile, String outputFile, 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

TextDocnoMapping

public TextDocnoMapping()
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.

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

writeDocnoData

public static void writeDocnoData(String inputFile,
                                  String outputFile,
                                  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 TrecDocnoMappingBuilder internally.

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

readDocnoData

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

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

getBuilder

public DocnoMapping.Builder getBuilder()
Description copied from interface: DocnoMapping
Returns the builder for this mapping.

Specified by:
getBuilder in interface DocnoMapping
Returns:
builder for this mapping

main

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

Parameters:
args - command-line arguments
Throws:
IOException