org.debellor.weka
Class ArffReader
java.lang.Object
org.debellor.core.Cell
org.debellor.weka.ArffReader
public class ArffReader
- extends Cell
Parameters:
- filename: directory path to the ARFF file
- fileURL: URL of the ARFF file.
Can be given instead of a filename,
e.g. to read from a class resource file:
arffReader.set("fileURL", myClass.class.getResource("...").toString());
- decisionAttr: index of the attribute to become
Sample.decision
. Indices start from 1.
Special values "last" and "-1" denote the last attribute.
If not specified or empty string, all attributes will fall into Sample.data
.
Instead of specifying a 'filename' or 'fileURL' the user may call
setInputStream(InputStream)
to manually
provide an instance of java.io.InputStream
that
should be used to read the ARFF file.
This enables reading from file that is not accessible in regular way,
e.g., is stored in memory.
This also gives the user more control over how the file is accessed and when,
as the InputStream instance may be prepared in a special way by the user.
- Author:
- Marcin Wojnarski
Methods inherited from class org.debellor.core.Cell |
close, erase, getAvailableParams, getParameters, learn, newThread, newThread, next, onErase, onLearn, open, openInputStream, set, set, set, set, setAvailableParams, setParameters, setRandomSeed, setSource, state, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ArffReader
public ArffReader()
setInputStream
public void setInputStream(java.io.InputStream inputStream)
- Sets the instance of
java.io.InputStream
that will be used
by this ArffReader to read the contents of an ARFF file.
ArffReader will use this input stream instead of opening
the file by itself.
This method has priority over parameters 'filename' and 'fileURL'.
It has effect only on the nearest call to open-next...-close.
onOpen
protected Sample.SampleType onOpen()
throws java.lang.Exception
- Description copied from class:
Cell
- Called by
Cell.open()
. Performs the actual opening of
communication session,
while open
checks only against access violation and handles exceptions.
Must be overridden in subclasses if open
is to be used.
Overriders may assume that the cell is in Cell.State.CLOSED
state.
- Overrides:
onOpen
in class Cell
- Throws:
java.lang.Exception
onNext
protected Sample onNext()
throws java.lang.Exception
- Description copied from class:
Cell
- Called by
Cell.Stream.next()
. Performs the actual generation of the next output sample,
while Stream.next()
checks only against access violation and handles exceptions.
Must be overridden in the subclass if next
is to be used, i.e.
if the subclass should generate some output data.
Overriders may assume that the cell is in Cell.State.OPEN
state.
- Overrides:
onNext
in class Cell
- Throws:
java.lang.Exception
onClose
protected void onClose()
throws java.lang.Exception
- Description copied from class:
Cell
- Called by
Cell.Stream.close()
. Performs the actual closing of
communication session,
while close
checks only against access violation and handles exceptions.
Must be overridden in subclasses if close
is to be used.
Usually the overrider will use onClose to release resources,
to let them be garbage-collected.
Overriders may assume that the cell is in Cell.State.OPEN
state.
- Overrides:
onClose
in class Cell
- Throws:
java.lang.Exception