Package weka.core.converters
Class AbstractLoader
java.lang.Object
weka.core.converters.AbstractLoader
- All Implemented Interfaces:
Serializable,Loader,RevisionHandler
- Direct Known Subclasses:
AbstractFileLoader,DatabaseLoader,TextDirectoryLoader
Abstract class gives default implementation of setSource methods. All other
methods must be overridden.
- Version:
- $Revision: 12184 $
- Author:
- Richard Kirkby (rkirkby@cs.waikato.ac.nz)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface weka.core.converters.Loader
Loader.StructureNotReadyException -
Field Summary
Fields inherited from interface weka.core.converters.Loader
BATCH, INCREMENTAL, NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InstancesReturn the full data set.abstract InstancegetNextInstance(Instances structure) Read the data set incrementally---get the next instance in the data set or returns null if there are no more instances to get.abstract InstancesDetermines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.voidreset()Default implementation sets retrieval mode to NONEvoidsetRetrieval(int mode) Sets the retrieval mode.voidDefault implementation throws an IOException.voidsetSource(InputStream input) Default implementation throws an IOException.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface weka.core.RevisionHandler
getRevision
-
Constructor Details
-
AbstractLoader
public AbstractLoader()
-
-
Method Details
-
setRetrieval
public void setRetrieval(int mode) Sets the retrieval mode.- Specified by:
setRetrievalin interfaceLoader- Parameters:
mode- the retrieval mode
-
setSource
Default implementation throws an IOException.- Specified by:
setSourcein interfaceLoader- Parameters:
file- the File- Throws:
IOException- always
-
reset
Default implementation sets retrieval mode to NONE -
setSource
Default implementation throws an IOException.- Specified by:
setSourcein interfaceLoader- Parameters:
input- the input stream- Throws:
IOException- always
-
getStructure
Description copied from interface:LoaderDetermines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.- Specified by:
getStructurein interfaceLoader- Returns:
- the structure of the data set as an empty set of Instances
- Throws:
IOException- if there is no source or parsing failspublic_normal_behavior requires: model_sourceSupplied == true && model_structureDetermined == false && (* successful parse *); modifiable: model_structureDetermined; ensures: \result != null && \result.numInstances() == 0 && model_structureDetermined == true; also public_exceptional_behavior requires: model_sourceSupplied == false || (* unsuccessful parse *); signals: (IOException);
-
getDataSet
Description copied from interface:LoaderReturn the full data set. If the structure hasn't yet been determined by a call to getStructure then the method should do so before processing the rest of the data set.- Specified by:
getDataSetin interfaceLoader- Returns:
- the full data set as an Instances object
- Throws:
IOException- if there is an error during parsing or if getNextInstance has been called on this source (either incremental or batch loading can be used, not both).public_normal_behavior requires: model_sourceSupplied == true && (* successful parse *); modifiable: model_structureDetermined; ensures: \result != null && \result.numInstances() >= 0 && model_structureDetermined == true; also public_exceptional_behavior requires: model_sourceSupplied == false || (* unsuccessful parse *); signals: (IOException);
-
getNextInstance
Description copied from interface:LoaderRead the data set incrementally---get the next instance in the data set or returns null if there are no more instances to get. If the structure hasn't yet been determined by a call to getStructure then method should do so before returning the next instance in the data set. If it is not possible to read the data set incrementally (ie. in cases where the data set structure cannot be fully established before all instances have been seen) then an exception should be thrown.- Specified by:
getNextInstancein interfaceLoader- Parameters:
structure- the dataset header information, will get updated in case of string or relational attributes- Returns:
- the next instance in the data set as an Instance object or null if there are no more instances to be read
- Throws:
IOException- if there is an error during parsing or if getDataSet has been called on this source (either incremental or batch loading can be used, not both).
-