public class DefaultVocabulary extends java.lang.Object implements Vocabulary
Modifier and Type | Class and Description |
---|---|
static class |
DefaultVocabulary.Builder
Builder class that is used to build the
DefaultVocabulary . |
Constructor and Description |
---|
DefaultVocabulary(DefaultVocabulary.Builder builder)
Creates a
DefaultVocabulary object with a DefaultVocabulary.Builder . |
DefaultVocabulary(java.util.List<java.lang.String> tokens)
Creates a
DefaultVocabulary object with the given list of tokens. |
Modifier and Type | Method and Description |
---|---|
static DefaultVocabulary.Builder |
builder()
Creates a new builder to build a
DefaultVocabulary . |
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 DefaultVocabulary(java.util.List<java.lang.String> tokens)
DefaultVocabulary
object with the given list of tokens.tokens
- the List
of tokens to build the vocabulary withpublic DefaultVocabulary(DefaultVocabulary.Builder builder)
DefaultVocabulary
object with a DefaultVocabulary.Builder
.builder
- the DefaultVocabulary.Builder
to build the vocabulary withpublic boolean contains(java.lang.String token)
contains
in interface Vocabulary
token
- String token to be checkedpublic 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
public static DefaultVocabulary.Builder builder()
DefaultVocabulary
.