mark.nlp.data
Class FileCategorySet

java.lang.Object
  |
  +--mark.nlp.data.FileCategorySet

public class FileCategorySet
extends java.lang.Object

A FileCategorySet defines a set of categories to which files belong. The idea is that we are going to be working with a number of files. Each file belongs to exactly one category. Each Categoru has a name and a corresponding number in the range 0 through the number of categories minus one. A FileCategorySet knows the name<->number maps and how to determine a file's category. The class follows the Immutable design pattern.


Constructor Summary
FileCategorySet(java.lang.String[] categoryNames)
          Initializes the category set.
 
Method Summary
static FileCategorySet extract(ArgHelper args)
          Extracts a file category set from an argument helper.
 java.lang.String map(int i)
          Maps the integer representation of a category to its textual representation.
 int map(java.lang.String s)
          Maps the string representation of a category it its integer representation.
 int mapFile(java.io.File f)
          Returns the integer representation of the given file's category.
 int size()
          Returns the number of categories.
 java.lang.String toString()
           
static java.lang.String usage()
          Returns a usage string for specification of a file category set at the the command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileCategorySet

public FileCategorySet(java.lang.String[] categoryNames)
Initializes the category set.

Parameters:
categoryNames - a set of Strings defining the category names.
Method Detail

size

public int size()
Returns the number of categories.

Returns:
the number of categories.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

map

public java.lang.String map(int i)
                     throws java.lang.Exception
Maps the integer representation of a category to its textual representation.

Parameters:
i - the integer representation [0, numCategories ()).
Returns:
the string representation.
java.lang.Exception

map

public int map(java.lang.String s)
        throws java.lang.Exception
Maps the string representation of a category it its integer representation.

Parameters:
s - the string representation.
Returns:
the integer representation [0, numCategories ()).
java.lang.Exception

mapFile

public int mapFile(java.io.File f)
            throws java.lang.Exception
Returns the integer representation of the given file's category.

Parameters:
f - the file.
Returns:
the category [0, numCategories ()).
Throws:
java.lang.Exception - if the mapping does not exist.

usage

public static java.lang.String usage()
Returns a usage string for specification of a file category set at the the command line.

Returns:
the usage string.

extract

public static FileCategorySet extract(ArgHelper args)
                               throws java.lang.Exception
Extracts a file category set from an argument helper.

Parameters:
args - the argument helper.
Returns:
the file category set.
java.lang.Exception