public class TextDirectoryLoader extends AbstractLoader implements BatchConverter, IncrementalConverter, OptionHandler, CommandlineRunnable
-D Enables debug output. (default: off)
-F Stores the filename in an additional attribute. (default: off)
-dir <directory> The directory to work on. (default: current directory)
-charset <charset name> The character set to use, e.g UTF-8. (default: use the default character set)
-R Retain all string attribute values when reading incrementally.Based on code from the TextDirectoryToArff tool. See the
Loader
,
Serialized FormLoader.StructureNotReadyException
BATCH, INCREMENTAL, NONE
Constructor and Description |
---|
TextDirectoryLoader()
default constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
charSetTipText()
the tip text for this property
|
java.lang.String |
debugTipText()
the tip text for this property
|
java.lang.String |
getCharSet()
Get the character set to use when reading text files.
|
Instances |
getDataSet()
Return the full data set.
|
boolean |
getDebug()
Gets whether additional debug information is printed.
|
java.io.File |
getDirectory()
get the Dir specified as the source
|
java.lang.String |
getFileDescription()
Returns a description of the file type, actually it's directories.
|
Instance |
getNextInstance(Instances structure)
Process input directories/files incrementally.
|
java.lang.String[] |
getOptions()
Gets the setting
|
boolean |
getOutputFilename()
Gets whether the filename will be stored as an extra attribute.
|
java.lang.String |
getRevision()
Returns the revision string.
|
Instances |
getStructure()
Determines and returns (if possible) the structure (internally the header)
of the data set as an empty set of instances.
|
java.lang.String |
globalInfo()
Returns a string describing this loader
|
java.util.Enumeration<Option> |
listOptions()
Lists the available options
|
static void |
main(java.lang.String[] args)
Main method.
|
java.lang.String |
outputFilenameTipText()
the tip text for this property
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before commandline
execution.
|
void |
reset()
Resets the loader ready to read a new data set
|
void |
run(java.lang.Object toRun,
java.lang.String[] args)
Execute the supplied object.
|
void |
setCharSet(java.lang.String charSet)
Set the character set to use when reading text files (an empty string
indicates that the default character set will be used).
|
void |
setDebug(boolean value)
Sets whether to print some debug information.
|
void |
setDirectory(java.io.File dir)
sets the source directory
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setOutputFilename(boolean value)
Sets whether the filename will be stored as an extra attribute.
|
void |
setSource(java.io.File dir)
Resets the Loader object and sets the source of the data set to be the
supplied File object.
|
setRetrieval, setSource
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeCopy
public java.lang.String globalInfo()
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-D Enables debug output. (default: off)
-F Stores the filename in an additional attribute. (default: off)
-dir <directory> The directory to work on. (default: current directory)
-charset <charset name> The character set to use, e.g UTF-8. (default: use the default character set)
setOptions
in interface OptionHandler
options
- the optionsjava.lang.Exception
- if options cannot be setpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public java.lang.String charSetTipText()
public void setCharSet(java.lang.String charSet)
charSet
- the character set to use.public java.lang.String getCharSet()
public void setDebug(boolean value)
value
- if true additional debug information will be printed.public boolean getDebug()
public java.lang.String debugTipText()
public void setOutputFilename(boolean value)
value
- if true the filename will be stored in an extra attributepublic boolean getOutputFilename()
public java.lang.String outputFilenameTipText()
public java.lang.String getFileDescription()
public java.io.File getDirectory()
public void setDirectory(java.io.File dir) throws java.io.IOException
dir
- the source directoryjava.io.IOException
- if an error occurspublic void reset()
reset
in interface Loader
reset
in class AbstractLoader
public void setSource(java.io.File dir) throws java.io.IOException
setSource
in interface Loader
setSource
in class AbstractLoader
dir
- the source directory.java.io.IOException
- if an error occurspublic Instances getStructure() throws java.io.IOException
getStructure
in interface Loader
getStructure
in class AbstractLoader
java.io.IOException
- if an error occurspublic Instances getDataSet() throws java.io.IOException
getDataSet
in interface Loader
getDataSet
in class AbstractLoader
java.io.IOException
- if there is no source or parsing failspublic Instance getNextInstance(Instances structure) throws java.io.IOException
getNextInstance
in interface Loader
getNextInstance
in class AbstractLoader
structure
- ignoredjava.io.IOException
- if a problem occurspublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
public static void main(java.lang.String[] args)
args
- should contain the name of an input file.public void preExecution() throws java.lang.Exception
preExecution
in interface CommandlineRunnable
java.lang.Exception
- if a problem occurs during setuppublic void postExecution() throws java.lang.Exception
postExecution
in interface CommandlineRunnable
java.lang.Exception
- if a problem occurs during teardownpublic void run(java.lang.Object toRun, java.lang.String[] args) throws java.lang.IllegalArgumentException
CommandlineRunnable
run
in interface CommandlineRunnable
toRun
- the object to executeargs
- any options to pass to the objectjava.lang.IllegalArgumentException