LBJ2.parse
Class FeatureVectorParser

java.lang.Object
  extended by LBJ2.parse.FeatureVectorParser
All Implemented Interfaces:
Parser

public class FeatureVectorParser
extends java.lang.Object
implements Parser

This parser returns FeatureVectors deserialized out of the first file passed to the constructor. In fact, this first file contains only ints that index the features. The second file passed to the constructor is the lexicon used to translate from ints to Feature objects.

When run as a stand-alone program, this class takes the names of the example and lexicon files as input on the command line and simply writes a string representation of every example to STDOUT.


Field Summary
protected  java.lang.String exampleFileName
          The name of the file to parse.
protected  java.io.DataInputStream in
          Reader for file currently being parsed.
protected  Feature[] lexicon
          The feature objects corresponding to the ints in the example file.
 
Constructor Summary
protected FeatureVectorParser(java.lang.String exampleFile)
          For internal use only.
  FeatureVectorParser(java.lang.String exampleFile, Feature[] lexicon)
          Creates the parser.
  FeatureVectorParser(java.lang.String exampleFile, java.lang.String lexiconFile)
          Creates the parser.
 
Method Summary
static void main(java.lang.String[] args)
          Takes the names of the example and lexicon files as input on the command line and prints all the examples to STDOUT.
 java.lang.Object next()
          Returns a FeatureVector deserialized out of the given file.
 void reset()
          Resets the example file stream to the beginning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected java.io.DataInputStream in
Reader for file currently being parsed.


exampleFileName

protected java.lang.String exampleFileName
The name of the file to parse.


lexicon

protected Feature[] lexicon
The feature objects corresponding to the ints in the example file.

Constructor Detail

FeatureVectorParser

protected FeatureVectorParser(java.lang.String exampleFile)
For internal use only. This constructor sets up the stream to read in the examples, but does not initialize the lexicon.

Parameters:
exampleFile - The name of the file to parse.

FeatureVectorParser

public FeatureVectorParser(java.lang.String exampleFile,
                           Feature[] lexicon)
Creates the parser.

Parameters:
exampleFile - The name of the file to parse.
lexicon - The lexicon.

FeatureVectorParser

public FeatureVectorParser(java.lang.String exampleFile,
                           java.lang.String lexiconFile)
Creates the parser.

Parameters:
exampleFile - The name of the file to parse.
lexiconFile - The name of the lexicon file.
Method Detail

next

public java.lang.Object next()
Returns a FeatureVector deserialized out of the given file.

Specified by:
next in interface Parser
Returns:
The next object parsed from the input data.

reset

public void reset()
Resets the example file stream to the beginning. Alternatively, one could simply create a new FeatureVectorParser with the same constructor arguments, but this method avoids re-reading the lexicon.

Specified by:
reset in interface Parser

main

public static void main(java.lang.String[] args)
Takes the names of the example and lexicon files as input on the command line and prints all the examples to STDOUT.