public class StaticWord2Vec extends Object implements WordVectors
| Modifier and Type | Class and Description |
|---|---|
static class |
StaticWord2Vec.Builder |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Double> |
accuracy(List<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
PLEASE NOTE: This method is not available in this implementation.
|
String |
getUNK() |
double[] |
getWordVector(String word)
Get the word vector for a given matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorMatrix(String word)
Get the word vector for a given matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorMatrixNormalized(String word)
Returns the word vector divided by the norm2 of the array
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectors(Collection<String> labels)
This method returns 2D array, where each row represents corresponding word/label
|
org.nd4j.linalg.api.ndarray.INDArray |
getWordVectorsMean(Collection<String> labels)
This method returns mean vector, built from words/labels passed in
|
boolean |
hasWord(String word)
Returns true if the model has this word in the vocab
|
int |
indexOf(String word) |
protected void |
init()
Init method validates configuration defined using
|
WeightLookupTable |
lookupTable()
Lookup table for the vectors
PLEASE NOTE: This method is not available in this implementation.
|
void |
setModelUtils(ModelUtils utils)
Specifies ModelUtils to be used to access model
PLEASE NOTE: This method has no effect in this implementation.
|
void |
setUNK(String newUNK) |
double |
similarity(String label1,
String label2)
Returns the similarity of 2 words
|
List<String> |
similarWordsInVocabTo(String word,
double accuracy)
Find all words with a similar characters
in the vocab
PLEASE NOTE: This method is not available in this implementation.
|
VocabCache |
vocab()
Vocab for the vectors
|
Collection<String> |
wordsNearest(Collection<String> positive,
Collection<String> negative,
int top)
Words nearest based on positive and negative words
PLEASE NOTE: This method is not available in this implementation.
|
Collection<String> |
wordsNearest(org.nd4j.linalg.api.ndarray.INDArray words,
int top) |
Collection<String> |
wordsNearest(String word,
int n)
Get the top n words most similar to the given word
PLEASE NOTE: This method is not available in this implementation.
|
Collection<String> |
wordsNearestSum(Collection<String> positive,
Collection<String> negative,
int top)
Words nearest based on positive and negative words
PLEASE NOTE: This method is not available in this implementation.
|
Collection<String> |
wordsNearestSum(org.nd4j.linalg.api.ndarray.INDArray words,
int top) |
Collection<String> |
wordsNearestSum(String word,
int n)
Get the top n words most similar to the given word
PLEASE NOTE: This method is not available in this implementation.
|
public String getUNK()
getUNK in interface WordVectorspublic void setUNK(String newUNK)
setUNK in interface WordVectorsprotected void init()
public boolean hasWord(String word)
hasWord in interface WordVectorsword - the word to test forpublic Collection<String> wordsNearest(org.nd4j.linalg.api.ndarray.INDArray words, int top)
wordsNearest in interface WordVectorspublic Collection<String> wordsNearestSum(org.nd4j.linalg.api.ndarray.INDArray words, int top)
wordsNearestSum in interface WordVectorspublic Collection<String> wordsNearestSum(String word, int n)
wordsNearestSum in interface WordVectorsword - the word to comparen - the n to getpublic Collection<String> wordsNearestSum(Collection<String> positive, Collection<String> negative, int top)
wordsNearestSum in interface WordVectorspositive - the positive wordsnegative - the negative wordstop - the top n wordspublic Map<String,Double> accuracy(List<String> questions)
accuracy in interface WordVectorsquestions - the questions to askpublic int indexOf(String word)
indexOf in interface WordVectorspublic List<String> similarWordsInVocabTo(String word, double accuracy)
similarWordsInVocabTo in interface WordVectorsword - the word to compareaccuracy - the accuracy: 0 to 1public double[] getWordVector(String word)
getWordVector in interface WordVectorsword - the word to get the matrix forpublic org.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrixNormalized(String word)
getWordVectorMatrixNormalized in interface WordVectorsword - the word to get the matrix forpublic org.nd4j.linalg.api.ndarray.INDArray getWordVectorMatrix(String word)
getWordVectorMatrix in interface WordVectorsword - the word to get the matrix forpublic org.nd4j.linalg.api.ndarray.INDArray getWordVectors(Collection<String> labels)
getWordVectors in interface WordVectorslabels - public org.nd4j.linalg.api.ndarray.INDArray getWordVectorsMean(Collection<String> labels)
getWordVectorsMean in interface WordVectorslabels - public Collection<String> wordsNearest(Collection<String> positive, Collection<String> negative, int top)
wordsNearest in interface WordVectorspositive - the positive wordsnegative - the negative wordstop - the top n wordspublic Collection<String> wordsNearest(String word, int n)
wordsNearest in interface WordVectorsword - the word to comparen - the n to getpublic double similarity(String label1, String label2)
similarity in interface WordVectorslabel1 - the first wordlabel2 - the second wordpublic VocabCache vocab()
vocab in interface WordVectorspublic WeightLookupTable lookupTable()
lookupTable in interface WordVectorspublic void setModelUtils(ModelUtils utils)
setModelUtils in interface WordVectorsutils - Copyright © 2018. All rights reserved.