public class SimpleVocabulary extends java.lang.Object implements Vocabulary
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleVocabulary.VocabularyBuilder
Builder class that is used to build the
SimpleVocabulary. |
| Constructor and Description |
|---|
SimpleVocabulary(SimpleVocabulary.VocabularyBuilder builder)
Create a
SimpleVocabulary object with ta SimpleVocabulary.VocabularyBuilder. |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String> |
getAllTokens()
Returns all the tokens in the vocabulary.
|
long |
getIndex(java.lang.String token)
Returns the index of the given token.
|
java.lang.String |
getToken(long index)
Returns the token corresponding to the given index.
|
java.lang.String |
getUnknownToken()
Return a
String used for unseen or rarely-seen tokens. |
boolean |
isKnownToken(java.lang.String token)
Returns whether the given token is a known word.
|
int |
size()
Returns the size of the
Vocabulary. |
public SimpleVocabulary(SimpleVocabulary.VocabularyBuilder builder)
SimpleVocabulary object with ta SimpleVocabulary.VocabularyBuilder.builder - the SimpleVocabulary.VocabularyBuilder to build the vocabulary withpublic boolean isKnownToken(java.lang.String token)
token - the tokenpublic java.lang.String getUnknownToken()
String used for unseen or rarely-seen tokens.String used for unseen or rarely-seen tokenspublic java.lang.String getToken(long index)
getToken in interface Vocabularyindex - the indexpublic java.util.List<java.lang.String> getAllTokens()
public long getIndex(java.lang.String token)
getIndex in interface Vocabularytoken - the tokenpublic int size()
Vocabulary.Vocabulary