public class Word2VecModel extends java.lang.Object implements scala.Serializable, Saveable
Constructor and Description |
---|
Word2VecModel(scala.collection.immutable.Map<java.lang.String,float[]> model) |
Modifier and Type | Method and Description |
---|---|
scala.Tuple2<java.lang.String,java.lang.Object>[] |
findSynonyms(java.lang.String word,
int num)
Find synonyms of a word
|
scala.Tuple2<java.lang.String,java.lang.Object>[] |
findSynonyms(Vector vector,
int num)
Find synonyms of the vector representation of a word
|
protected java.lang.String |
formatVersion()
Current version of model save/load format.
|
scala.collection.immutable.Map<java.lang.String,float[]> |
getVectors()
Returns a map of words to their vector representations.
|
static Word2VecModel |
load(SparkContext sc,
java.lang.String path) |
void |
save(SparkContext sc,
java.lang.String path)
Save this model to the given path.
|
Vector |
transform(java.lang.String word)
Transforms a word to its vector representation
|
public Word2VecModel(scala.collection.immutable.Map<java.lang.String,float[]> model)
public static Word2VecModel load(SparkContext sc, java.lang.String path)
protected java.lang.String formatVersion()
Saveable
formatVersion
in interface Saveable
public void save(SparkContext sc, java.lang.String path)
Saveable
This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/
The model may be loaded using Loader.load
.
public Vector transform(java.lang.String word)
word
- a wordpublic scala.Tuple2<java.lang.String,java.lang.Object>[] findSynonyms(java.lang.String word, int num)
word
- a wordnum
- number of synonyms to findpublic scala.Tuple2<java.lang.String,java.lang.Object>[] findSynonyms(Vector vector, int num)
vector
- vector representation of a wordnum
- number of synonyms to findpublic scala.collection.immutable.Map<java.lang.String,float[]> getVectors()