public class Word2VecModel extends Object implements scala.Serializable, Saveable
| Constructor and Description |
|---|
Word2VecModel(scala.collection.immutable.Map<String,float[]> model) |
| Modifier and Type | Method and Description |
|---|---|
scala.Tuple2<String,Object>[] |
findSynonyms(String word,
int num)
Find synonyms of a word; do not include the word itself in results.
|
scala.Tuple2<String,Object>[] |
findSynonyms(Vector vector,
int num)
Find synonyms of the vector representation of a word, possibly
including any words in the model vocabulary whose vector representation
is the supplied vector.
|
scala.collection.immutable.Map<String,float[]> |
getVectors()
Returns a map of words to their vector representations.
|
static Word2VecModel |
load(SparkContext sc,
String path) |
void |
save(SparkContext sc,
String path)
Save this model to the given path.
|
Vector |
transform(String word)
Transforms a word to its vector representation
|
public Word2VecModel(scala.collection.immutable.Map<String,float[]> model)
public static Word2VecModel load(SparkContext sc, String path)
public void save(SparkContext sc, String path)
SaveableThis 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(String word)
word - a wordpublic scala.Tuple2<String,Object>[] findSynonyms(String word,
int num)
word - a wordnum - number of synonyms to findpublic scala.Tuple2<String,Object>[] findSynonyms(Vector vector, int num)
vector - vector representation of a wordnum - number of synonyms to findpublic scala.collection.immutable.Map<String,float[]> getVectors()