public class ArrayFileParser extends Object implements Parser
When run as a stand-alone program, this class takes the names of example, lexicon, and model
files as input and prints all the feature vectors in the dataset to STDOUT
.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
exampleData
A single array from which all examples can be parsed.
|
protected String |
exampleFileName
The name of the file to parse.
|
protected DataInputStream |
in
Reader for file currently being parsed.
|
protected boolean |
includePruned
Whether the returned example arrays should include pruned features.
|
protected boolean |
zipped
Whether or not the input stream is zipped.
|
Constructor and Description |
---|
ArrayFileParser(byte[] data)
Initializes the parser with a data array assuming the input stream is not zipped.
|
ArrayFileParser(byte[] data,
boolean zip)
Initializes the parser with a data array, specifying whether the data is zipped.
|
ArrayFileParser(String exampleFile)
Initializes the parser with a file name assuming the input stream is not zipped.
|
ArrayFileParser(String exampleFile,
boolean zip)
Initializes the parser with a file name, specifying whether the data is zipped.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Frees any resources this parser may be holding.
|
int |
getNumExamples()
Returns the number of examples left in the example file.
|
static void |
main(String[] args) |
Object |
next()
Returns either an
Object[] or a FoldSeparator deserialized out of the
given file. |
void |
reset()
Resets the example file stream to the beginning.
|
void |
setIncludePruned(boolean b)
Setter for
includePruned . |
protected DataInputStream in
protected String exampleFileName
protected byte[] exampleData
protected boolean zipped
protected boolean includePruned
public ArrayFileParser(String exampleFile)
exampleFile
- The name of the file containing the examples.public ArrayFileParser(String exampleFile, boolean zip)
exampleFile
- The name of the file containing the examples.zip
- Whether or not the input stream is zipped.public ArrayFileParser(byte[] data)
data
- The examples can be parsed out of this array.public ArrayFileParser(byte[] data, boolean zip)
data
- The examples can be parsed out of this array.zip
- Whether or not the input stream is zipped.public void setIncludePruned(boolean b)
includePruned
.public int getNumExamples()
reset()
is called after
the examples are counted.public Object next()
Object[]
or a FoldSeparator
deserialized out of the
given file.public void reset()
public void close()
public static void main(String[] args)
Copyright © 2016. All rights reserved.