Package weka.core.tokenizers
Class Tokenizer
java.lang.Object
weka.core.tokenizers.Tokenizer
- All Implemented Interfaces:
Serializable,Enumeration<String>,OptionHandler,RevisionHandler
- Direct Known Subclasses:
AlphabeticTokenizer,CharacterDelimitedTokenizer,CharacterNGramTokenizer
public abstract class Tokenizer
extends Object
implements Enumeration<String>, OptionHandler, Serializable, RevisionHandler
A superclass for all tokenizer algorithms.
- Version:
- $Revision: 10203 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Gets the current option settings for the OptionHandler.abstract StringReturns a string describing the stemmerabstract booleanTests if this enumeration contains more elements.Returns an enumeration of all the available options..abstract StringReturns the next element of this enumeration if this enumeration object has at least one more element to provide.static voidrunTokenizer(Tokenizer tokenizer, String[] options) initializes the given tokenizer with the given options and runs the tokenizer over all the remaining strings in the options array.voidsetOptions(String[] options) Sets the OptionHandler's options using the given list.abstract voidSets the string to tokenize.static String[]initializes the given tokenizer with the given options and runs the tokenizer over all the remaining strings in the options array.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Enumeration
asIteratorMethods inherited from interface weka.core.RevisionHandler
getRevision
-
Constructor Details
-
Tokenizer
public Tokenizer()
-
-
Method Details
-
globalInfo
Returns a string describing the stemmer- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
listOptions
Returns an enumeration of all the available options..- Specified by:
listOptionsin interfaceOptionHandler- Returns:
- an enumeration of all available options.
-
getOptions
Gets the current option settings for the OptionHandler.- Specified by:
getOptionsin interfaceOptionHandler- Returns:
- the list of current option settings as an array of strings
-
setOptions
Sets the OptionHandler's options using the given list. All options will be set (or reset) during this call (i.e. incremental setting of options is not possible).- Specified by:
setOptionsin interfaceOptionHandler- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
hasMoreElements
public abstract boolean hasMoreElements()Tests if this enumeration contains more elements.- Specified by:
hasMoreElementsin interfaceEnumeration<String>- Returns:
- true if and only if this enumeration object contains at least one more element to provide; false otherwise.
-
nextElement
Returns the next element of this enumeration if this enumeration object has at least one more element to provide.- Specified by:
nextElementin interfaceEnumeration<String>- Returns:
- the next element of this enumeration.
-
tokenize
Sets the string to tokenize. Tokenization happens immediately.- Parameters:
s- the string to tokenize
-
tokenize
initializes the given tokenizer with the given options and runs the tokenizer over all the remaining strings in the options array. If no strings remained in the option string then data is read from stdin, line by line.- Parameters:
tokenizer- the tokenizer to useoptions- the options for the tokenizer- Returns:
- the tokenized strings
- Throws:
Exception- if setting of options or tokenization fails
-
runTokenizer
initializes the given tokenizer with the given options and runs the tokenizer over all the remaining strings in the options array. The generated tokens are then printed to stdout. If no strings remained in the option string then data is read from stdin, line by line.- Parameters:
tokenizer- the tokenizer to useoptions- the options for the tokenizer
-