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(java.util.List<java.lang.String> tokens)
Create a
SimpleVocabulary object with the given list of tokens. |
SimpleVocabulary(SimpleVocabulary.VocabularyBuilder builder)
Create a
SimpleVocabulary object with a SimpleVocabulary.VocabularyBuilder . |
Modifier and Type | Method and Description |
---|---|
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.VocabularyBuilder builder)
SimpleVocabulary
object with a SimpleVocabulary.VocabularyBuilder
.builder
- the SimpleVocabulary.VocabularyBuilder
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 java.lang.String getToken(long index)
getToken
in interface Vocabulary
index
- the indexpublic long getIndex(java.lang.String token)
getIndex
in interface Vocabulary
token
- the tokenpublic long size()
Vocabulary
.size
in interface Vocabulary
Vocabulary