%% Map Words to Vectors and Back
% 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

% Map the words "Italy", "Rome", and "Paris" to vectors using word2vec.

italy = word2vec(emb,"Italy");
rome = word2vec(emb,"Rome");
paris = word2vec(emb,"Paris");

% Map the vector italy - rome + paris to a word using vec2word.

word = vec2word(emb,italy - rome + paris)

% Copyright 2012 The MathWorks, Inc.