|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.filters.Filter
wpi.filters.AttributeSetFilter
This filter converts a string attribute to a set of
yes & no nominal attributes. The new attributes will be created
for every unique entry separated by delimiter in the string.
Each of the new attributes will be named as 'attributeName-entryValue'.
(Note: The string attribute with no delimiter in any of its instance is
not affected.)
Valid options are:
-D delimiters
Specify the delimiters of the set.
(default "|")
-N nominal_values
Specify the nominal values used to classify an attribute.
Valid values are "yesno", "truefalse", and "onezero".
(default "yesno")
-R range
Specify the range of filtering.
e.g. 'first-last', or '1-2,6,8-last'.
(default "all")
-I
Use this flag to inverse the range.
Field Summary | |
protected java.lang.String |
m_delimiters
Stores the delimeter(s) used for separating entries in a set. |
protected int |
m_hashCapacity
Stores the initial hash capacity for a hash used internally. |
protected weka.core.Instances |
m_InputFormat
Stores the input format. |
protected java.lang.String |
m_nom_no
Stores the nominal value for an instance without an entry. |
protected int |
m_nom_values
The integer defining current nominal values. |
protected java.lang.String |
m_nom_yes
Stores the nominal value for an instance with an entry. |
protected weka.core.Instances |
m_OutputFormat
Stores the output format. |
protected java.lang.String |
m_range
Stores the range of filtering as a string. |
protected boolean |
m_rangeInverse
Stores whether the range of filtering should be inversed, or not. |
protected weka.core.FastVector |
m_SetFormat
Stores the set format. e.g. |
protected java.lang.String |
NONSET
The string defining a non-set. |
static int |
ONEZERO
The static integer used to define nominal values of 1 and 0. |
protected java.lang.String |
SET
The string definining a set. |
static weka.core.Tag[] |
TAGS_NOMINAL_VALUES
Define possible nominal values. |
static int |
TRUEFALSE
The static integer used to define nominal values of true and false. |
static int |
YESNO
The static integer used to define nominal values of yes and no. |
Fields inherited from class weka.filters.Filter |
m_NewBatch |
Constructor Summary | |
AttributeSetFilter()
|
Method Summary | |
boolean |
batchFinished()
Signify that this batch of input to the filter is finished. |
protected void |
convertInstance(weka.core.Instance instance)
Convert an instance to the output format. |
protected void |
convertInstanceFormat(weka.core.Instances instanceFormat)
Convert an instance format to output instance format. |
protected java.util.Hashtable |
createHash(weka.core.Attribute attribute)
Creates a hash of unique entries in a set attribute. |
java.lang.String |
delimitersTipText()
Returns the tip text for this property. |
protected boolean |
entryIsInSet(java.lang.String entry,
java.lang.String set)
Tests whether the entry is in the given set. |
java.lang.String |
getDelimiters()
Get the current delimeter(s). |
java.lang.String |
getInsideBracket(char startBracket,
char endBracket,
java.lang.String text)
Returns the string inside matching brackets. |
weka.core.SelectedTag |
getNominalValues()
Get the current nominal values used to classify an attribute. |
java.lang.String[] |
getOptions()
Gets the current settings of the filter. |
java.lang.String |
getRange()
Get the current range of filtering. |
boolean |
getRangeInverse()
Get whether the current range of filtering is to be inversed or not. |
java.lang.String |
globalInfo()
Returns a string describing this filter |
boolean |
input(weka.core.Instance instance)
Input an instance for filtering. |
protected boolean |
isAttributeSet(weka.core.Attribute attribute)
Tests whether the attribute is a set. |
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options |
static void |
main(java.lang.String[] argv)
Main method for testing this class. |
java.lang.String |
nominalValuesTipText()
Returns the tip text for this property. |
java.lang.String |
rangeInverseTipText()
Returns the tip text for this property. |
java.lang.String |
rangeTipText()
Returns the tip text for this property. |
void |
setDelimiters(java.lang.String delimiters)
Set the delimiters of the set. |
boolean |
setInputFormat(weka.core.Instances instanceInfo)
Sets the format of the input instances. |
void |
setNominalValues(weka.core.SelectedTag nominal_values)
Set the nominal values used to classify an attribute. |
void |
setOptions(java.lang.String[] options)
Parses a given list of options controlling the behaviour of this object. |
void |
setRange(java.lang.String range)
Set the range of filtering. Note: This filter will ignore any non-set attribute (The numeric, nominal, or string attribute with no delimeter in any of its instances). |
void |
setRangeInverse(boolean rangeInverse)
Inverses the range of filtering. |
Methods inherited from class weka.filters.Filter |
batchFilterFile, bufferInput, copyStringValues, copyStringValues, filterFile, flushInput, getInputFormat, getInputStringIndex, getOutputFormat, getOutputStringIndex, getStringIndices, inputFormat, isOutputFormatDefined, numPendingOutput, output, outputFormat, outputFormatPeek, outputPeek, push, resetQueue, setOutputFormat, useFilter |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int YESNO
public static int TRUEFALSE
public static int ONEZERO
protected int m_nom_values
protected java.lang.String SET
protected java.lang.String NONSET
protected weka.core.Instances m_InputFormat
protected weka.core.Instances m_OutputFormat
protected weka.core.FastVector m_SetFormat
protected java.lang.String m_nom_yes
protected java.lang.String m_nom_no
protected java.lang.String m_delimiters
protected java.lang.String m_range
protected boolean m_rangeInverse
protected int m_hashCapacity
public static final weka.core.Tag[] TAGS_NOMINAL_VALUES
Constructor Detail |
public AttributeSetFilter()
Method Detail |
public java.lang.String globalInfo()
public boolean setInputFormat(weka.core.Instances instanceInfo) throws java.lang.Exception
instanceInfo
- an Instances object containing the input instance
structure (any instances contained in the object are ignored - only the
structure is required).
java.lang.Exception
- if the inputFormat can't be set successfully.public boolean input(weka.core.Instance instance) throws java.lang.Exception
instance
- the input instance
java.lang.IllegalStateException
- if no input format has been defined.
java.lang.Exception
- if the input instance was not of the correct format
or if there was a problem with the filtering.public boolean batchFinished() throws java.lang.Exception
java.lang.NullPointerException
- if no input structure has been defined,
java.lang.Exception
- if there was a problem finishing the batch.public java.lang.String delimitersTipText()
public void setDelimiters(java.lang.String delimiters) throws java.lang.Exception
java.lang.Exception
- if an invalid delimeter is supplied.public java.lang.String getDelimiters()
public java.lang.String nominalValuesTipText()
public void setNominalValues(weka.core.SelectedTag nominal_values)
nominal_values
- the nominal values used to classify an attribute.public weka.core.SelectedTag getNominalValues()
public java.lang.String rangeTipText()
public void setRange(java.lang.String range) throws java.lang.Exception
range
- a string representing the range. Since the string will
typically come from a user, attributes are indexed from 1.java.lang.Exception
- if an invalid range is suppliedpublic java.lang.String getRange()
public java.lang.String rangeInverseTipText()
public void setRangeInverse(boolean rangeInverse)
rangeInverse
- true, if the range is to be inversed. false, otherwise.public boolean getRangeInverse()
protected void convertInstanceFormat(weka.core.Instances instanceFormat)
instanceFormat
- the instance format to convert.protected void convertInstance(weka.core.Instance instance)
instance
- the instance to convert.protected boolean isAttributeSet(weka.core.Attribute attribute)
attribute
- the attribute to test.
protected java.util.Hashtable createHash(weka.core.Attribute attribute)
attribute
- the attribute to create hash from.
protected boolean entryIsInSet(java.lang.String entry, java.lang.String set)
entry
- the entry to test.set
- the set to test.
public java.lang.String getInsideBracket(char startBracket, char endBracket, java.lang.String text)
startBracket
- the starting bracketendBracket
- the ending brackettext
- the text to examine
public java.util.Enumeration listOptions()
listOptions
in interface weka.core.OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-D delimiters
Specify the delimiters of the set.
(default "|")
-N nominal_values
Specify the nominal values used to classify an attribute.
Valid values are "yesno", "truefalse", and "onezero".
(default "yesno")
-R range
Specify the range of filtering.
e.g. 'first-last', or '1-2,6,8-last'.
(default "all")
-I
Use this flag to inverse the range.
setOptions
in interface weka.core.OptionHandler
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface weka.core.OptionHandler
public static void main(java.lang.String[] argv)
argv
- should contain arguments to the filter: use -h for help
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |