%% Encode Words as Word Count Vector
% Encode an array of words as a vector of word counts.

documents = tokenizedDocument([
    "an example of a short sentence"
    "a second short sentence"]);
bag = bagOfWords(documents)
words = ["another" "example" "of" "a" "short" "example" "sentence"];
counts = encode(bag,words)

% Copyright 2012 The MathWorks, Inc.