|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.converters.ConverterUtils.DataSource
public static class ConverterUtils.DataSource
Helper class for loading data from files and URLs. Via the ConverterUtils
class it determines which converter to use for loading the data into
memory. If the chosen converter is an incremental one, then the data
will be loaded incrementally, otherwise as batch. In both cases the
same interface will be used (hasMoreElements
,
nextElement
). Before the
data can be read again, one has to call the reset
method.
The data source can also be initialized with an Instances object, in
order to provide a unified interface to files and already loaded datasets.
hasMoreElements(Instances)
,
nextElement(Instances)
,
reset()
,
ConverterUtils.DataSink
,
Serialized FormConstructor Summary | |
---|---|
ConverterUtils.DataSource(java.io.InputStream stream)
Initializes the datasource with the given input stream. |
|
ConverterUtils.DataSource(Instances inst)
Initializes the datasource with the given dataset. |
|
ConverterUtils.DataSource(Loader loader)
Initializes the datasource with the given Loader. |
|
ConverterUtils.DataSource(java.lang.String location)
Tries to load the data from the file. |
Method Summary | |
---|---|
Instances |
getDataSet()
returns the full dataset, can be null in case of an error. |
Instances |
getDataSet(int classIndex)
returns the full dataset with the specified class index set, can be null in case of an error. |
Loader |
getLoader()
returns the determined loader, null if the DataSource was initialized with data alone and not a file/URL. |
java.lang.String |
getRevision()
Returns the revision string. |
Instances |
getStructure()
returns the structure of the data. |
Instances |
getStructure(int classIndex)
returns the structure of the data, with the defined class index. |
boolean |
hasMoreElements(Instances structure)
returns whether there are more Instance objects in the data. |
static boolean |
isArff(java.lang.String location)
returns whether the extension of the location is likely to be of ARFF format, i.e., ending in ".arff" or ".arff.gz" (case-insensitive). |
boolean |
isIncremental()
returns whether the loader is an incremental one. |
static void |
main(java.lang.String[] args)
for testing only - takes a data file as input. |
Instance |
nextElement(Instances dataset)
returns the next element and sets the specified dataset, null if none available. |
static Instances |
read(java.io.InputStream stream)
convencience method for loading a dataset in batch mode from a stream. |
static Instances |
read(Loader loader)
convencience method for loading a dataset in batch mode. |
static Instances |
read(java.lang.String location)
convencience method for loading a dataset in batch mode. |
void |
reset()
resets the loader. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConverterUtils.DataSource(java.lang.String location) throws java.lang.Exception
location
- the name of the file to load
java.lang.Exception
- if initialization failspublic ConverterUtils.DataSource(Instances inst)
inst
- the dataset to usepublic ConverterUtils.DataSource(Loader loader)
loader
- the Loader to usepublic ConverterUtils.DataSource(java.io.InputStream stream)
stream
- the stream to useMethod Detail |
---|
public static boolean isArff(java.lang.String location)
location
- the file location to check
public boolean isIncremental()
public Loader getLoader()
public Instances getDataSet() throws java.lang.Exception
java.lang.Exception
- if resetting of loader failspublic Instances getDataSet(int classIndex) throws java.lang.Exception
classIndex
- the class index for the dataset
java.lang.Exception
- if resetting of loader failspublic void reset() throws java.lang.Exception
java.lang.Exception
- if resetting failspublic Instances getStructure() throws java.lang.Exception
java.lang.Exception
- if something goes wrongpublic Instances getStructure(int classIndex) throws java.lang.Exception
classIndex
- the class index for the dataset
java.lang.Exception
- if something goes wrongpublic boolean hasMoreElements(Instances structure)
structure
- the structure of the dataset
nextElement(Instances)
public Instance nextElement(Instances dataset)
dataset
- the dataset to set for the instance
public static Instances read(java.lang.String location) throws java.lang.Exception
location
- the dataset to load
java.lang.Exception
- if loading failspublic static Instances read(java.io.InputStream stream) throws java.lang.Exception
stream
- the stream to load the dataset from
java.lang.Exception
- if loading failspublic static Instances read(Loader loader) throws java.lang.Exception
loader
- the loader to get the dataset from
java.lang.Exception
- if loading failspublic static void main(java.lang.String[] args) throws java.lang.Exception
args
- the commandline arguments
java.lang.Exception
- if something goes wrongpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |