|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.core.converters.ArffLoader.ArffReader
public static class ArffLoader.ArffReader
Reads data from an ARFF file, either in incremental or batch mode.
Typical code for batch usage:
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 Summary | |
|---|---|
ArffLoader.ArffReader(java.io.Reader reader)
Reads the data completely from the reader. |
|
ArffLoader.ArffReader(java.io.Reader reader,
Instances template,
int lines)
Reads the data without header according to the specified template. |
|
ArffLoader.ArffReader(java.io.Reader reader,
Instances template,
int lines,
int capacity)
Initializes the reader without reading the header according to the specified template. |
|
ArffLoader.ArffReader(java.io.Reader reader,
int capacity)
Reads only the header and reserves the specified space for instances. |
|
| Method Summary | |
|---|---|
Instances |
getData()
Returns the data that was read |
int |
getLineNo()
returns the current line number |
java.lang.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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArffLoader.ArffReader(java.io.Reader reader)
throws java.io.IOException
getData() method.
reader - the reader to use
java.io.IOException - if something goes wronggetData()
public ArffLoader.ArffReader(java.io.Reader reader,
int capacity)
throws java.io.IOException
readInstance().
reader - the reader to usecapacity - the capacity of the new dataset
java.io.IOException - if something goes wrong
java.lang.IllegalArgumentException - if capacity is negativegetStructure(),
readInstance(Instances)
public ArffLoader.ArffReader(java.io.Reader reader,
Instances template,
int lines)
throws java.io.IOException
getData() method.
reader - the reader to usetemplate - the template headerlines - the lines read so far
java.io.IOException - if something goes wronggetData()
public ArffLoader.ArffReader(java.io.Reader reader,
Instances template,
int lines,
int capacity)
throws java.io.IOException
readInstance() method.
reader - the reader to usetemplate - the template headerlines - the lines read so farcapacity - the capacity of the new dataset
java.io.IOException - if something goes wronggetData()| Method Detail |
|---|
public int getLineNo()
public Instance readInstance(Instances structure)
throws java.io.IOException
structure - the dataset header information, will get updated
in case of string or relational attributes
java.io.IOException - if the information is not read
successfully
public Instance readInstance(Instances structure,
boolean flag)
throws java.io.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 instance
java.io.IOException - if the information is not read
successfullypublic Instances getStructure()
public Instances getData()
public java.lang.String getRevision()
getRevision in interface RevisionHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||