public class Classifier extends Object
Token,
TokenArrayList| Constructor and Description |
|---|
Classifier()
Default constructor.
|
Classifier(Dictionary d)
Creates a new classifier that recognizes the tokens specified in the
given dictionary.
|
Classifier(Dictionary d,
boolean useDefaults)
Creates a new classifier that recognizes the tokens specified in the
given dictionary.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addKeyword(String k,
int i)
Adds a new keyword to the classifier's dictionary.
|
boolean |
addSeparator(String c,
int i)
Adds a new separator to the classifier.
|
TokenArrayList |
classify(String s,
boolean returnSeps)
The classify function breaks down the specified string into tokens and
passes back an array of classified tokens.
|
public Classifier()
public Classifier(Dictionary d)
d - The dictionary that contains keyword tokens.public Classifier(Dictionary d, boolean useDefaults)
d - The dictionary that contains keyword tokens.useDefaults - A flag that indicates whether or not we should use the
default delimiter characters ' ', \t \r \n \f when tokenizing a string. If
this flag is set to false, you should add your own seperator characters using
the addSeperator() method.public boolean addKeyword(String k, int i)
The text should be 2 or more characters in length. If you want to recognize a single character as a token, you should add it using the addSeparator() method.
k - The text to be recognized as a keyword.i - Its unique numeric identifier.public boolean addSeparator(String c, int i)
c - A string containing a single character to be recognized as a separator.i - Its unique numeric identifier.public TokenArrayList classify(String s, boolean returnSeps)
s - The string to be parsed.returnSeps - Set to true if the separators should be returned as tokens.Copyright © 2023. All rights reserved.