public abstract class DataGenerator extends Object implements OptionHandler, Randomizable, Serializable, RevisionHandler
Modifier and Type | Field and Description |
---|---|
protected boolean |
m_CreatingRelationName
flag, that indicates whether the relationname is currently assembled
|
protected Instances |
m_DatasetFormat
The format for the generated dataset
|
protected boolean |
m_Debug
Debugging mode
|
protected StringWriter |
m_DefaultOutput
default output (is printed to stdout after generation)
|
protected int |
m_NumExamplesAct
Number of instances that should be produced into the dataset
this number is by default m_NumExamples,
but can be reset by the generator
|
protected static HashSet |
m_OptionBlacklist
a black list for options not to be listed (for derived generators)
in the makeOptionString method
|
protected PrintWriter |
m_Output
PrintWriter for outputting the generated data
|
protected Random |
m_Random
random number generator
|
protected String |
m_RelationName
Relation name the dataset should have
|
protected int |
m_Seed
random number generator seed
|
Constructor and Description |
---|
DataGenerator()
initializes with default settings.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addToBlacklist(String option)
adds the given option, e.g., for "-V" use "V", to the blacklist of options
that are not to be output via the makeOptionString method
|
protected static void |
clearBlacklist()
removes all entries from the options blacklist
|
String |
debugTipText()
Returns the tip text for this property
|
protected int |
defaultNumExamplesAct()
returns the default number of actual examples
|
StringWriter |
defaultOutput()
Gets the string writer, which is used for outputting to stdout.
|
protected String |
defaultRelationName()
returns a relation name based on the options
|
protected int |
defaultSeed()
returns the default seed
|
Instances |
defineDataFormat()
Initializes the format for the dataset produced.
|
protected Vector |
enumToVector(Enumeration enm)
creates a vector out of the enumeration from the listOptions of the
super class.
|
String |
formatTipText()
Returns the tip text for this property
|
abstract Instance |
generateExample()
Generates one example of the dataset.
|
abstract Instances |
generateExamples()
Generates all examples of the dataset.
|
abstract String |
generateFinished()
Generates a comment string that documentates the data generator.
|
abstract String |
generateStart()
Generates a comment string that documentates the data generator.
|
Instances |
getDatasetFormat()
Gets the format of the dataset that is to be generated.
|
boolean |
getDebug()
Gets the debug flag.
|
int |
getNumExamplesAct()
Gets the number of examples the dataset should have.
|
String[] |
getOptions()
Gets the current settings of the datagenerator RDG1.
|
PrintWriter |
getOutput()
Gets the print writer.
|
Random |
getRandom()
Gets the random generator.
|
String |
getRelationName()
Gets the relation name the dataset should have.
|
protected String |
getRelationNameToUse()
returns the relation name to use, i.e., in case the currently set
relation name is empty, a generic one is returned.
|
int |
getSeed()
Gets the random number seed.
|
abstract boolean |
getSingleModeFlag()
Return if single mode is set for the given data generator
mode depends on option setting and or generator type.
|
protected static boolean |
isOnBlacklist(String option)
checks, whether the given option is in the blacklist of options not to
be output by makeOptionString
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
makeData(DataGenerator generator,
String[] options)
Calls the data generator.
|
protected static String |
makeOptionString(DataGenerator generator)
returns all the options in a string
|
protected String |
numExamplesActTipText()
Returns the tip text for this property
|
String |
outputTipText()
Returns the tip text for this property
|
String |
randomTipText()
Returns the tip text for this property
|
String |
relationNameTipText()
Returns the tip text for this property
|
protected String[] |
removeBlacklist(String[] options)
removes all the options from the options array that are blacklisted
|
protected static void |
runDataGenerator(DataGenerator datagenerator,
String[] options)
runs the datagenerator instance with the given options.
|
String |
seedTipText()
Returns the tip text for this property
|
void |
setDatasetFormat(Instances newFormat)
Sets the format of the dataset that is to be generated.
|
void |
setDebug(boolean debug)
Sets the debug flag.
|
protected void |
setNumExamplesAct(int numExamplesAct)
Sets the number of examples the dataset should have.
|
void |
setOptions(String[] options)
Parses a list of options for this object.
|
void |
setOutput(PrintWriter newOutput)
Sets the print writer.
|
void |
setRandom(Random newRandom)
Sets the random generator.
|
void |
setRelationName(String relationName)
Sets the relation name the dataset should have.
|
void |
setSeed(int newSeed)
Sets the random number seed.
|
protected String |
toStringFormat()
Returns a string representing the dataset in the instance queue.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRevision
protected boolean m_Debug
protected Instances m_DatasetFormat
protected String m_RelationName
protected int m_NumExamplesAct
protected transient StringWriter m_DefaultOutput
protected transient PrintWriter m_Output
protected int m_Seed
protected Random m_Random
protected boolean m_CreatingRelationName
protected static HashSet m_OptionBlacklist
makeOptionString(DataGenerator)
public DataGenerator()
protected Vector enumToVector(Enumeration enm)
enm
- the Enumeration to dump into a vectorpublic Enumeration listOptions()
listOptions
in interface OptionHandler
public void setOptions(String[] options) throws Exception
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
removeBlacklist(String[])
public Instances defineDataFormat() throws Exception
Exception
- if the generating of the format faileddefaultRelationName()
public abstract Instance generateExample() throws Exception
public abstract Instances generateExamples() throws Exception
public abstract String generateStart() throws Exception
Exception
- if the generating of the documentation failspublic abstract String generateFinished() throws Exception
Exception
- if the generating of the documentation failspublic abstract boolean getSingleModeFlag() throws Exception
Exception
- if mode is not set yetpublic void setDebug(boolean debug)
debug
- the new debug flagpublic boolean getDebug()
public String debugTipText()
public void setRelationName(String relationName)
relationName
- the new relation nameprotected String defaultRelationName()
protected String getRelationNameToUse()
defaultRelationName()
,
defineDataFormat()
public String getRelationName()
public String relationNameTipText()
protected int defaultNumExamplesAct()
protected void setNumExamplesAct(int numExamplesAct)
numExamplesAct
- the new number of examplespublic int getNumExamplesAct()
protected String numExamplesActTipText()
public void setOutput(PrintWriter newOutput)
newOutput
- the new print writerpublic PrintWriter getOutput()
public StringWriter defaultOutput()
public String outputTipText()
public void setDatasetFormat(Instances newFormat)
newFormat
- the new dataset format of the datasetpublic Instances getDatasetFormat()
public String formatTipText()
protected int defaultSeed()
public int getSeed()
getSeed
in interface Randomizable
public void setSeed(int newSeed)
setSeed
in interface Randomizable
newSeed
- the new random number seed.public String seedTipText()
public Random getRandom()
public void setRandom(Random newRandom)
newRandom
- is the random generator.public String randomTipText()
protected String toStringFormat()
protected static void clearBlacklist()
protected static void addToBlacklist(String option)
option
- the option to exclude from listingmakeOptionString(DataGenerator)
protected static boolean isOnBlacklist(String option)
option
- the option to checkmakeOptionString(DataGenerator)
protected String[] removeBlacklist(String[] options)
options
- the options to remove from the blacklistprotected static String makeOptionString(DataGenerator generator)
generator
- the DataGenerator to return all the options forpublic static void makeData(DataGenerator generator, String[] options) throws Exception
generator
- one of the data generatorsoptions
- options of the data generatorException
- if there was an error in the option listprotected static void runDataGenerator(DataGenerator datagenerator, String[] options)
datagenerator
- the datagenerator to runoptions
- the commandline optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.