public class ModelZooWordEmbedding extends java.lang.Object implements WordEmbedding, java.lang.AutoCloseable
WordEmbedding using a ZooModel.| Constructor and Description |
|---|
ModelZooWordEmbedding(Model model)
Constructs a
ModelZooWordEmbedding. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
NDArray |
embedWord(NDManager manager,
int word)
Embeds the word after preprocessed using
WordEmbedding.preprocessWordToEmbed(String). |
int |
preprocessWordToEmbed(java.lang.String word)
Pre-processes the word to embed into an array to pass into the model.
|
java.lang.String |
unembedWord(NDArray word)
Returns the closest matching word for the given index.
|
boolean |
vocabularyContains(java.lang.String word)
Returns whether an embedding exists for a word.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitembedWordpublic ModelZooWordEmbedding(Model model)
ModelZooWordEmbedding.model - the model for the embedding. The model's block must consist of only an Embedding<String>.public boolean vocabularyContains(java.lang.String word)
vocabularyContains in interface WordEmbeddingword - the word to checkpublic int preprocessWordToEmbed(java.lang.String word)
Make sure to call WordEmbedding.embedWord(NDManager, int) after this.
preprocessWordToEmbed in interface WordEmbeddingword - the word to embedpublic NDArray embedWord(NDManager manager, int word) throws EmbeddingException
WordEmbedding.preprocessWordToEmbed(String).embedWord in interface WordEmbeddingmanager - the manager for the embedding arrayword - the index of the word to embedEmbeddingException - if there is an error while trying to embedpublic java.lang.String unembedWord(NDArray word)
unembedWord in interface WordEmbeddingword - the word embedding to find the matching string word for.public void close()
close in interface java.lang.AutoCloseable