All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.filters.unsupervised.attribute.StringToWordVector

java.lang.Object
    |
    +----weka.filters.Filter
            |
            +----weka.filters.unsupervised.attribute.StringToWordVector

public class StringToWordVector
extends Filter
implements UnsupervisedFilter, OptionHandler
Converts String attributes into a set of attributes representing word occurrence information from the text contained in the strings. The set of words (attributes) is determined by the first batch filtered (typically training data).

Version:
$Revision: 1.3 $
Author:
Len Trigg (len@reeltwo.com)
Author:
Stuart Inglis (stuart@reeltwo.com)

Constructor Index

 o StringToWordVector()
Default constructor.
 o StringToWordVector(int)
Constructor that allows specification of the target number of words in the output.

Method Index

 o batchFinished()
Signify that this batch of input to the filter is finished.
 o getDelimiters()
Get the value of delimiters.
 o getOptions()
Gets the current settings of the filter.
 o getOutputWordCounts()
Gets whether output instances contain 0 or 1 indicating word presence, or word counts.
 o getSelectedRange()
Get the value of m_SelectedRange.
 o getWordsToKeep()
Gets the number of words (per class if there is a class attribute assigned) to attempt to keep.
 o input(Instance)
Input an instance for filtering.
 o listOptions()
Returns an enumeration describing the available options
 o main(String[])
Main method for testing this class.
 o setDelimiters(String)
Set the value of delimiters.
 o setInputFormat(Instances)
Sets the format of the input instances.
 o setOptions(String[])
Parses a given list of options controlling the behaviour of this object.
 o setOutputWordCounts(boolean)
Sets whether output instances contain 0 or 1 indicating word presence, or word counts.
 o setSelectedRange(String)
Set the value of m_SelectedRange.
 o setWordsToKeep(int)
Sets the number of words (per class if there is a class attribute assigned) to attempt to keep.

Constructor Detail

 o StringToWordVector
public StringToWordVector()
          Default constructor. Targets 1000 words in the output.
 o StringToWordVector
public StringToWordVector(int wordsToKeep)
          Constructor that allows specification of the target number of words in the output.
Parameters:
wordsToKeep - the number of words in the output vector (per class if assigned).

Method Detail

 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options controlling the behaviour of this object. Valid options are:

-C
Output word counts rather than boolean word presence.

-D delimiter_charcters
Specify set of delimiter characters (default: " \n\t.,:'\\\"()?!\"

-R index1,index2-index4,...
Specify list of string attributes to convert to words. (default: all string attributes)

-W number_of_words_to_keep
Specify number of word fields to create. Other, less useful words will be discarded. (default: 1000)

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the filter.
Returns:
an array of strings suitable for passing to setOptions
 o setInputFormat
public boolean setInputFormat(Instances instanceInfo) throws java.lang.Exception
          Sets the format of the input instances.
Parameters:
instanceInfo - an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).
Returns:
true if the outputFormat may be collected immediately
Throws:
java.lang.Exception - if the input format can't be set successfully
Overrides:
setInputFormat in class Filter
 o input
public boolean input(Instance instance)
          Input an instance for filtering. Filter requires all training instances be read before producing output.
Parameters:
instance - the input instance.
Returns:
true if the filtered instance may now be collected with output().
Throws:
java.lang.IllegalStateException - if no input structure has been defined.
Overrides:
input in class Filter
 o batchFinished
public boolean batchFinished()
          Signify that this batch of input to the filter is finished. If the filter requires all instances prior to filtering, output() may now be called to retrieve the filtered instances.
Returns:
true if there are instances pending output.
Throws:
java.lang.IllegalStateException - if no input structure has been defined.
Overrides:
batchFinished in class Filter
 o getOutputWordCounts
public boolean getOutputWordCounts()
          Gets whether output instances contain 0 or 1 indicating word presence, or word counts.
Returns:
true if word counts should be output.
 o setOutputWordCounts
public void setOutputWordCounts(boolean outputWordCounts)
          Sets whether output instances contain 0 or 1 indicating word presence, or word counts.
Parameters:
outputWordCounts - true if word counts should be output.
 o getDelimiters
public java.lang.String getDelimiters()
          Get the value of delimiters.
Returns:
Value of delimiters.
 o setDelimiters
public void setDelimiters(java.lang.String newDelimiters)
          Set the value of delimiters.
Parameters:
newdelimiters - Value to assign to delimiters.
 o getSelectedRange
public Range getSelectedRange()
          Get the value of m_SelectedRange.
Returns:
Value of m_SelectedRange.
 o setSelectedRange
public void setSelectedRange(java.lang.String newSelectedRange)
          Set the value of m_SelectedRange.
Parameters:
newSelectedRange - Value to assign to m_SelectedRange.
 o getWordsToKeep
public int getWordsToKeep()
          Gets the number of words (per class if there is a class attribute assigned) to attempt to keep.
Returns:
the target number of words in the output vector (per class if assigned).
 o setWordsToKeep
public void setWordsToKeep(int newWordsToKeep)
          Sets the number of words (per class if there is a class attribute assigned) to attempt to keep.
Parameters:
newWordsToKeep - the target number of words in the output vector (per class if assigned).
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - should contain arguments to the filter: use -h for help

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home