public static class ConverterUtils.DataSource extends Object implements Serializable, RevisionHandler
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 and Description |
---|
ConverterUtils.DataSource(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(String location)
Tries to load the data from the file.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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(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(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(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(String location)
convencience method for loading a dataset in batch mode.
|
void |
reset()
resets the loader.
|
public ConverterUtils.DataSource(String location) throws Exception
location
- the name of the file to loadException
- if initialization failspublic ConverterUtils.DataSource(Instances inst)
inst
- the dataset to usepublic ConverterUtils.DataSource(Loader loader)
loader
- the Loader to usepublic ConverterUtils.DataSource(InputStream stream)
stream
- the stream to usepublic static boolean isArff(String location)
location
- the file location to checkpublic boolean isIncremental()
public Loader getLoader()
public Instances getDataSet() throws Exception
Exception
- if resetting of loader failspublic Instances getDataSet(int classIndex) throws Exception
classIndex
- the class index for the datasetException
- if resetting of loader failspublic void reset() throws Exception
Exception
- if resetting failspublic Instances getStructure() throws Exception
Exception
- if something goes wrongpublic Instances getStructure(int classIndex) throws Exception
classIndex
- the class index for the datasetException
- if something goes wrongpublic boolean hasMoreElements(Instances structure)
structure
- the structure of the datasetnextElement(Instances)
public Instance nextElement(Instances dataset)
dataset
- the dataset to set for the instancepublic static Instances read(String location) throws Exception
location
- the dataset to loadException
- if loading failspublic static Instances read(InputStream stream) throws Exception
stream
- the stream to load the dataset fromException
- if loading failspublic static Instances read(Loader loader) throws Exception
loader
- the loader to get the dataset fromException
- if loading failspublic static void main(String[] args) throws Exception
args
- the commandline argumentsException
- if something goes wrongpublic String getRevision()
getRevision
in interface RevisionHandler
Copyright © 2016 University of Waikato, Hamilton, NZ. All Rights Reserved.