Map word to embedding vector
M = word2vec(emb,words)
Load a pretrained word embedding using
fastTextWordEmbedding. This function requires Text Analytics Toolbox™ Model for fastText English 16 Billion Token Word Embedding support package. If this support package is not installed, then the function provides a download link.
emb = fastTextWordEmbedding
emb = wordEmbedding with properties: Dimension: 300 Vocabulary: [1×1000000 string]
Map the words "Italy", "Rome", and "Paris" to vectors using
italy = word2vec(emb,"Italy"); rome = word2vec(emb,"Rome"); paris = word2vec(emb,"Paris");
Map the vector
italy - rome + paris to a word using
word = vec2word(emb,italy - rome + paris)
word = "France"
emb— Input word embedding
Input word embedding, specified as a
words— Input words
Input words, specified as a string vector, character vector, or cell array of character
vectors. If you specify
words as a character vector, then the
function treats the argument as a single word.
M— Matrix of word embedding vectors
Matrix of word embedding vectors.