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.net.URL url,
java.util.function.Function<java.net.URL,java.util.List<java.lang.String>> lambda)
Adds a customized vocabulary to the
SimpleVocabulary . |
SimpleVocabulary.Builder |
addFromTextFile(java.nio.file.Path path)
Adds a text vocabulary to the
SimpleVocabulary . |
SimpleVocabulary.Builder |
addFromTextFile(java.net.URL url)
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 SimpleVocabulary
VocabularyBuilder
public SimpleVocabulary.Builder optUnknownToken(java.lang.String unknownToken)
unknownToken
- the string value of the unknown tokenVocabularyBuilder
public SimpleVocabulary.Builder optReservedTokens(java.util.Collection<java.lang.String> reservedTokens)
reservedTokens
- the list of reserved tokensVocabularyBuilder
public SimpleVocabulary.Builder add(java.util.List<java.lang.String> sentence)
SimpleVocabulary
.sentence
- the sentence to be addedVocabularyBuilder
public SimpleVocabulary.Builder addAll(java.util.List<java.util.List<java.lang.String>> sentences)
SimpleVocabulary
.sentences
- the list of sentences to be addedVocabularyBuilder
public SimpleVocabulary.Builder addFromTextFile(java.nio.file.Path path) throws java.io.IOException
SimpleVocabulary
.
Example text file(vocab.txt): token1 token2 token3 will be mapped to index of 0 1 2
path
- the path to the text fileVocabularyBuilder
java.io.IOException
- if failed to read vocabulary filepublic SimpleVocabulary.Builder addFromTextFile(java.net.URL url) throws java.io.IOException
SimpleVocabulary
.url
- the text file urlVocabularyBuilder
java.io.IOException
- if failed to read vocabulary filepublic SimpleVocabulary.Builder addFromCustomizedFile(java.net.URL url, java.util.function.Function<java.net.URL,java.util.List<java.lang.String>> lambda)
SimpleVocabulary
.url
- the text file urllambda
- the function to parse the vocabulary fileVocabularyBuilder
public SimpleVocabulary build()
SimpleVocabulary
object with the set arguments.SimpleVocabulary
object built