public static class ArffLoader.ArffReader extends Object implements RevisionHandler
BufferedReader reader = new BufferedReader(new FileReader("/some/where/file.arff"));
ArffReader arff = new ArffReader(reader);
Instances data = arff.getData();
data.setClassIndex(data.numAttributes() - 1);
Typical code for incremental usage:
BufferedReader reader = new BufferedReader(new FileReader("/some/where/file.arff"));
ArffReader arff = new ArffReader(reader, 1000);
Instances data = arff.getStructure();
data.setClassIndex(data.numAttributes() - 1);
Instance inst;
while ((inst = arff.readInstance(data)) != null) {
data.add(inst);
}
| Constructor and Description |
|---|
ArffLoader.ArffReader(Reader reader)
Reads the data completely from the reader.
|
ArffLoader.ArffReader(Reader reader,
Instances template,
int lines)
Reads the data without header according to the specified template.
|
ArffLoader.ArffReader(Reader reader,
Instances template,
int lines,
int capacity)
Initializes the reader without reading the header according to the
specified template.
|
ArffLoader.ArffReader(Reader reader,
Instances template,
int lines,
int capacity,
boolean batch)
Initializes the reader without reading the header according to the
specified template.
|
ArffLoader.ArffReader(Reader reader,
int capacity) |
ArffLoader.ArffReader(Reader reader,
int capacity,
boolean batch)
Reads only the header and reserves the specified space for instances.
|
| Modifier and Type | Method and Description |
|---|---|
Instances |
getData()
Returns the data that was read
|
int |
getLineNo()
returns the current line number
|
String |
getRevision()
Returns the revision string.
|
Instances |
getStructure()
Returns the header format
|
Instance |
readInstance(Instances structure)
Reads a single instance using the tokenizer and returns it.
|
Instance |
readInstance(Instances structure,
boolean flag)
Reads a single instance using the tokenizer and returns it.
|
public ArffLoader.ArffReader(Reader reader) throws IOException
getData() method.reader - the reader to useIOException - if something goes wronggetData()public ArffLoader.ArffReader(Reader reader, int capacity) throws IOException
IOExceptionpublic ArffLoader.ArffReader(Reader reader, int capacity, boolean batch) throws IOException
readInstance().reader - the reader to usecapacity - the capacity of the new datasetIOException - if something goes wrongIllegalArgumentException - if capacity is negativegetStructure(),
readInstance(Instances)public ArffLoader.ArffReader(Reader reader, Instances template, int lines) throws IOException
getData() method.reader - the reader to usetemplate - the template headerlines - the lines read so farIOException - if something goes wronggetData()public ArffLoader.ArffReader(Reader reader, Instances template, int lines, int capacity) throws IOException
readInstance() method.reader - the reader to usetemplate - the template headerlines - the lines read so farcapacity - the capacity of the new datasetIOException - if something goes wronggetData()public ArffLoader.ArffReader(Reader reader, Instances template, int lines, int capacity, boolean batch) throws IOException
readInstance() method.reader - the reader to usetemplate - the template headerlines - the lines read so farcapacity - the capacity of the new datasetbatch - true if the values of string attributes should be collected in the headerIOException - if something goes wronggetData()public int getLineNo()
public Instance readInstance(Instances structure) throws IOException
structure - the dataset header information, will get updated
in case of string or relational attributesIOException - if the information is not read
successfullypublic Instance readInstance(Instances structure, boolean flag) throws IOException
structure - the dataset header information, will get updated
in case of string or relational attributesflag - if method should test for carriage return after
each instanceIOException - if the information is not read
successfullypublic Instances getStructure()
public Instances getData()
public String getRevision()
getRevision in interface RevisionHandlerCopyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.