public class WordVectorSerializer extends Object
| Constructor and Description |
|---|
WordVectorSerializer() |
| Modifier and Type | Method and Description |
|---|---|
static float |
getFloat(byte[] b)
Read float from byte array, credit to:
Credit to: https://github.com/NLPchina/Word2VEC_java/blob/master/src/com/ansj/vec/Word2VEC.java
|
static Word2Vec |
loadGoogleModel(String path,
boolean binary)
Loads the google model
|
static Pair<WeightLookupTable,VocabCache> |
loadTxt(File path)
Loads an in memory cache from the given path (sets syn0 and the vocab)
|
static WordVectors |
loadTxtVectors(File path)
Loads an in memory cache from the given path (sets syn0 and the vocab)
|
static float |
readFloat(InputStream is)
Credit to: https://github.com/NLPchina/Word2VEC_java/blob/master/src/com/ansj/vec/Word2VEC.java
|
static void |
writeTsneFormat(Glove vec,
org.nd4j.linalg.api.ndarray.INDArray tsne,
File csv)
Write the tsne format
|
static void |
writeTsneFormat(Word2Vec vec,
org.nd4j.linalg.api.ndarray.INDArray tsne,
File csv)
Write the tsne format
|
static void |
writeWordVectors(InMemoryLookupTable l,
InMemoryLookupCache cache,
String path)
Writes the word vectors to the given path.
|
static void |
writeWordVectors(Word2Vec vec,
String path)
Writes the word vectors to the given path.
|
public static Word2Vec loadGoogleModel(String path, boolean binary) throws IOException
path - the path to the google modelIOExceptionpublic static float readFloat(InputStream is) throws IOException
is - IOExceptionpublic static float getFloat(byte[] b)
b - public static void writeWordVectors(InMemoryLookupTable l, InMemoryLookupCache cache, String path) throws IOException
path - the path to writeIOExceptionpublic static void writeWordVectors(Word2Vec vec, String path) throws IOException
vec - the word2vec to writepath - the path to writeIOExceptionpublic static WordVectors loadTxtVectors(File path) throws FileNotFoundException
path - the path of the file to loadFileNotFoundExceptionpublic static Pair<WeightLookupTable,VocabCache> loadTxt(File path) throws FileNotFoundException
path - the path of the file to loadFileNotFoundExceptionpublic static void writeTsneFormat(Glove vec, org.nd4j.linalg.api.ndarray.INDArray tsne, File csv) throws Exception
vec - the word vectors to use for labelingtsne - the tsne array to writecsv - the file to useExceptionCopyright © 2015. All rights reserved.