public interface WordVectors
extends java.io.Serializable
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Double> |
accuracy(java.util.List<java.lang.String> questions)
Accuracy based on questions which are a space separated list of strings
where the first word is the query word, the next 2 words are negative,
and the last word is the predicted word to be nearest
|
java.lang.String |
getUNK() |
double[] |
getWordVector(java.lang.String word)
Get the word vector for a given matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorMatrix(java.lang.String word)
Get the word vector for a given matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorMatrixNormalized(java.lang.String word)
Returns the word vector divided by the norm2 of the array
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectors(java.util.Collection<java.lang.String> labels)
This method returns 2D array, where each row represents corresponding word/label
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorsMean(java.util.Collection<java.lang.String> labels)
This method returns mean vector, built from words/labels passed in
|
boolean |
hasWord(java.lang.String word)
Returns true if the model has this word in the vocab
|
int |
indexOf(java.lang.String word) |
WeightLookupTable |
lookupTable()
Lookup table for the vectors
|
void |
setModelUtils(ModelUtils utils)
Specifies ModelUtils to be used to access model
|
void |
setUNK(java.lang.String newUNK) |
double |
similarity(java.lang.String word,
java.lang.String word2)
Returns the similarity of 2 words
|
java.util.List<java.lang.String> |
similarWordsInVocabTo(java.lang.String word,
double accuracy)
Find all words with a similar characters
in the vocab
|
VocabCache |
vocab()
Vocab for the vectors
|
java.util.Collection<java.lang.String> |
wordsNearest(java.util.Collection<java.lang.String> positive,
java.util.Collection<java.lang.String> negative,
int top)
Words nearest based on positive and negative words
|
java.util.Collection<java.lang.String> |
wordsNearest(org.nd4j.linalg.api.ndarray.INDArray words,
int top) |
java.util.Collection<java.lang.String> |
wordsNearest(java.lang.String word,
int n)
Get the top n words most similar to the given word
|
java.util.Collection<java.lang.String> |
wordsNearestSum(java.util.Collection<java.lang.String> positive,
java.util.Collection<java.lang.String> negative,
int top)
Words nearest based on positive and negative words
|
java.util.Collection<java.lang.String> |
wordsNearestSum(org.nd4j.linalg.api.ndarray.INDArray words,
int top) |
java.util.Collection<java.lang.String> |
wordsNearestSum(java.lang.String word,
int n)
Get the top n words most similar to the given word
|
java.lang.String getUNK()
void setUNK(java.lang.String newUNK)
boolean hasWord(java.lang.String word)
word
- the word to test forjava.util.Collection<java.lang.String> wordsNearest(org.nd4j.linalg.api.ndarray.INDArray words, int top)
java.util.Collection<java.lang.String> wordsNearestSum(org.nd4j.linalg.api.ndarray.INDArray words, int top)
java.util.Collection<java.lang.String> wordsNearestSum(java.lang.String word, int n)
word
- the word to comparen
- the n to getjava.util.Collection<java.lang.String> wordsNearestSum(java.util.Collection<java.lang.String> positive, java.util.Collection<java.lang.String> negative, int top)
positive
- the positive wordsnegative
- the negative wordstop
- the top n wordsjava.util.Map<java.lang.String,java.lang.Double> accuracy(java.util.List<java.lang.String> questions)
questions
- the questions to askint indexOf(java.lang.String word)
java.util.List<java.lang.String> similarWordsInVocabTo(java.lang.String word, double accuracy)
word
- the word to compareaccuracy
- the accuracy: 0 to 1double[] getWordVector(java.lang.String word)
word
- the word to get the matrix fororg.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrixNormalized(java.lang.String word)
word
- the word to get the matrix fororg.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrix(java.lang.String word)
word
- the word to get the matrix fororg.nd4j.linalg.api.ndarray.INDArray getWordVectors(java.util.Collection<java.lang.String> labels)
labels
- org.nd4j.linalg.api.ndarray.INDArray getWordVectorsMean(java.util.Collection<java.lang.String> labels)
labels
- java.util.Collection<java.lang.String> wordsNearest(java.util.Collection<java.lang.String> positive, java.util.Collection<java.lang.String> negative, int top)
positive
- the positive wordsnegative
- the negative wordstop
- the top n wordsjava.util.Collection<java.lang.String> wordsNearest(java.lang.String word, int n)
word
- the word to comparen
- the n to getdouble similarity(java.lang.String word, java.lang.String word2)
word
- the first wordword2
- the second wordVocabCache vocab()
WeightLookupTable lookupTable()
void setModelUtils(ModelUtils utils)
utils
-