%% Remove Empty Documents from Bag-of-Words Model
% Remove documents containing no words from bag-of-words model.
% Create a bag-of-words model from an array of tokenized documents.

documents = tokenizedDocument([
    "An example of a short sentence."
    ""
    "A second short sentence."
    ""]);
bag = bagOfWords(documents)

% Remove the empty documents from the bag-of-words model.

newBag = removeEmptyDocuments(bag)

% Copyright 2017 The MathWorks, Inc.