%% Create Bag-of-N-Grams Model from Unique N-Grams and Counts
% Create a bag-of-n-grams model using a string array of unique n-grams and a matrix of counts.
% Load the example n-grams and counts from sonnetsBigramCounts.mat. This file contains a string array uniqueNgrams, which contains the unique n-grams, and the matrix counts, which contains the n-gram frequency counts.

load sonnetsBigramCounts.mat

% View the first few n-grams in uniqueNgrams.

uniqueNgrams(1:10,:)

% Create the bag-of-n-grams model.

bag = bagOfNgrams(uniqueNgrams,counts)