public static final class SimpleVocabulary.Builder
extends java.lang.Object
SimpleVocabulary.| Modifier and Type | Method and Description |
|---|---|
SimpleVocabulary.Builder |
add(java.util.List<java.lang.String> sentence)
Adds the given sentence to the
SimpleVocabulary. |
SimpleVocabulary.Builder |
addAll(java.util.List<java.util.List<java.lang.String>> sentences)
Adds the given list of sentences to the
SimpleVocabulary. |
SimpleVocabulary.Builder |
addFromCustomizedFile(java.lang.String path,
java.util.function.Function<java.lang.String,java.util.List<java.lang.String>> lambda)
Adds a customized vocabulary to the
SimpleVocabulary. |
SimpleVocabulary.Builder |
addFromTextFile(java.lang.String path)
Adds a text vocabulary to the
SimpleVocabulary. |
SimpleVocabulary |
build()
Builds the
SimpleVocabulary object with the set arguments. |
SimpleVocabulary.Builder |
optMinFrequency(int minFrequency)
Sets the optional parameter that specifies the minimum frequency to consider a token to
be part of the
SimpleVocabulary. |
SimpleVocabulary.Builder |
optReservedTokens(java.util.Collection<java.lang.String> reservedTokens)
Sets the optional parameter that sets the list of reserved tokens.
|
SimpleVocabulary.Builder |
optUnknownToken(java.lang.String unknownToken)
Sets the optional parameter that specifies the unknown token's string value.
|
public SimpleVocabulary.Builder optMinFrequency(int minFrequency)
SimpleVocabulary. Defaults to 10.minFrequency - the minimum frequency to consider a token to be part of the SimpleVocabularyVocabularyBuilderpublic SimpleVocabulary.Builder optUnknownToken(java.lang.String unknownToken)
unknownToken - the string value of the unknown tokenVocabularyBuilderpublic SimpleVocabulary.Builder optReservedTokens(java.util.Collection<java.lang.String> reservedTokens)
reservedTokens - the list of reserved tokensVocabularyBuilderpublic SimpleVocabulary.Builder add(java.util.List<java.lang.String> sentence)
SimpleVocabulary.sentence - the sentence to be addedVocabularyBuilderpublic SimpleVocabulary.Builder addAll(java.util.List<java.util.List<java.lang.String>> sentences)
SimpleVocabulary.sentences - the list of sentences to be addedVocabularyBuilderpublic SimpleVocabulary.Builder addFromTextFile(java.lang.String path)
SimpleVocabulary.
Example text file(vocab.txt): token1 token2 token3 will be mapped to index of 0 1 2
path - the path to the text fileVocabularyBuilderpublic SimpleVocabulary.Builder addFromCustomizedFile(java.lang.String path, java.util.function.Function<java.lang.String,java.util.List<java.lang.String>> lambda)
SimpleVocabulary.path - the path to load the filelambda - the function to parse the vocabulary fileVocabularyBuilderpublic SimpleVocabulary build()
SimpleVocabulary object with the set arguments.SimpleVocabulary object built