public class SimpleTextEmbedding extends java.lang.Object implements TextEmbedding
TextEmbedding
that applies a WordEmbedding
to each word independently.Constructor and Description |
---|
SimpleTextEmbedding(WordEmbedding wordEmbedding)
Constructs a
SimpleTextEmbedding . |
Modifier and Type | Method and Description |
---|---|
NDArray |
embedText(NDManager manager,
int[] textIndices)
Embeds the text after preprocessed using
TextEmbedding.preprocessTextToEmbed(List) . |
int[] |
preprocessTextToEmbed(java.util.List<java.lang.String> text)
Preprocesses the text to embed into an array to pass into the model.
|
java.util.List<java.lang.String> |
unembedText(NDArray textEmbedding)
Returns the closest matching text for a given embedding.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
embedText
public SimpleTextEmbedding(WordEmbedding wordEmbedding)
SimpleTextEmbedding
.wordEmbedding
- the word embedding to embed each wordpublic int[] preprocessTextToEmbed(java.util.List<java.lang.String> text)
Make sure to call TextEmbedding.embedText(NDManager, int[])
after this.
preprocessTextToEmbed
in interface TextEmbedding
text
- the text to embedpublic NDArray embedText(NDManager manager, int[] textIndices) throws EmbeddingException
TextEmbedding.preprocessTextToEmbed(List)
.embedText
in interface TextEmbedding
manager
- the manager to create the embedding arraytextIndices
- the text to embedEmbeddingException
- if there is an error while trying to embedpublic java.util.List<java.lang.String> unembedText(NDArray textEmbedding) throws EmbeddingException
unembedText
in interface TextEmbedding
textEmbedding
- the text embedding to find the matching string text for.EmbeddingException
- if the input is not unembeddable