public class Vocabulary
extends java.lang.Object
Vocabulary is a collection of tokens. The primary purpose of a vocabulary is the map a
token to an index.| Modifier and Type | Class and Description |
|---|---|
static class |
Vocabulary.VocabularyBuilder
Builder class that is used to build the
Vocabulary. |
| Constructor and Description |
|---|
Vocabulary(Vocabulary.VocabularyBuilder builder)
Create a
Vocabulary object with ta Vocabulary.VocabularyBuilder. |
| Modifier and Type | Method and Description |
|---|---|
long |
getIndex(java.lang.String token)
Returns the index of the given token.
|
java.lang.String |
getToken(int 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 Vocabulary(Vocabulary.VocabularyBuilder builder)
Vocabulary object with ta Vocabulary.VocabularyBuilder.builder - the Vocabulary.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(int index)
index - the indexpublic long getIndex(java.lang.String token)
token - the tokenpublic int size()
Vocabulary.Vocabulary