%% Output Document Word Counts in Columns
% Encode an array of documents as a matrix of word counts with documents in columns.

documents = tokenizedDocument([
    "an example of a short sentence"
    "a second short sentence"]);
bag = bagOfWords(documents)
documents = tokenizedDocument([
    "a new sentence"
    "a second new sentence"])

% View the documents encoded as a matrix of word counts with documents in columns. The word "new" does not appear in bag, so it is not counted.

counts = encode(bag,documents,'DocumentsIn','columns');
full(counts)

% Copyright 2012 The MathWorks, Inc.