public class SimpleVocabulary extends java.lang.Object implements Vocabulary
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleVocabulary.Builder
Builder class that is used to build the
SimpleVocabulary. |
| Constructor and Description |
|---|
SimpleVocabulary(java.util.List<java.lang.String> tokens)
Create a
SimpleVocabulary object with the given list of tokens. |
SimpleVocabulary(SimpleVocabulary.Builder builder)
Create a
SimpleVocabulary object with a SimpleVocabulary.Builder. |
| Modifier and Type | Method and Description |
|---|---|
static SimpleVocabulary.Builder |
builder()
Creates a new builder to build a
SimpleVocabulary. |
boolean |
contains(java.lang.String token)
Check if the vocabulary contains a token.
|
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.
|
long |
size()
Returns the size of the
Vocabulary. |
public SimpleVocabulary(SimpleVocabulary.Builder builder)
SimpleVocabulary object with a SimpleVocabulary.Builder.builder - the SimpleVocabulary.Builder to build the vocabulary withpublic SimpleVocabulary(java.util.List<java.lang.String> tokens)
SimpleVocabulary object with the given list of tokens.tokens - the List of tokens to build the vocabulary withpublic boolean contains(java.lang.String token)
contains in interface Vocabularytoken - String token to be checkedpublic java.lang.String getToken(long index)
getToken in interface Vocabularyindex - the indexpublic long getIndex(java.lang.String token)
getIndex in interface Vocabularytoken - the tokenpublic long size()
Vocabulary.size in interface VocabularyVocabularypublic static SimpleVocabulary.Builder builder()
SimpleVocabulary.