M= word2vec(emb,words)returns the embedding vectors ofwordsin the embeddingemb. If a word is not in the embedding vocabulary, then the function returns a row ofNaNs. The function, by default, is case sensitive.
M= word2vec(emb,words,'IgnoreCase',true)returns the embedding vectors ofwordsignoring case using any of the previous syntaxes. If multiple words in the embedding differ only in case, then the function returns the vector corresponding to one of them and does not return any particular vector.
Load a pretrained word embedding usingfastTextWordEmbedding. This function requires Text Analytics Toolbox™ Modelfor fastText English 16 Billion Token Word Embeddingsupport 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 usingword2vec.
italy = word2vec(emb,"Italy"); rome = word2vec(emb,"Rome"); paris = word2vec(emb,"Paris");
Map the vectoritaly - rome + paristo a word usingvec2word.
Input word embedding, specified as awordEmbeddingobject.
words—Input words 字符串向量|character vector|cell array of character vectors
Input words, specified as a string vector, character vector, or cell array of character vectors. If you specifywordsas a character vector, then the function treats the argument as a single word.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.