%% Scores Using Bag-of-Words Model
% Create a bag-of-words model from the text data in sonnets.csv.

filename = "sonnets.csv";
tbl = readtable(filename,'TextType','string');
textData = tbl.Sonnet;
documents = tokenizedDocument(textData);
bag = bagOfWords(documents)

% Calculate LexRank scores for each sonnet.

scores = lexrankScores(bag);

% Visualize the scores in a bar chart.

figure
bar(scores)
xlabel("Document")
ylabel("Score")
title("LexRank Scores")

% Copyright 2019 The MathWorks, Inc.