Football words used

indexAFL = find(~cellfun(@isempty,AFLtemp));
tweetsAFL = T(indexAFL);
%%
load(‘sentiment.mat’);
%%
for h = 1:size(tweetsAFL,2)
segmentedAFL{h} = regexp(tweetsAFL{h},’ ‘,’split’);
end
%%
for j = 1:size(segmentedAFL,2)

thisTweet = segmentedAFL{j};

for k = 1:size(thisTweet,2)

thisWord = thisTweet{1,k};
indexPositive{j,k} = strmatch(thisWord, word,’exact’);
end
end
%%

totalCells = size(indexPositive,1)*size(indexPositive,2);
matrixPositive = zeros(size(indexPositive,1),size(indexPositive,2));

for p = 1:totalCells
if isempty(indexPositive{p}) == 0
matrixPositive(p) = indexPositive{p};
else matrixPositive(p) = NaN;
end
end

%%
scoresPositive = zeros(size(indexPositive,1),size(indexPositive,2));

for p = 1:totalCells
if isnan(matrixPositive(p)) == 0
scoresPositive(p) = sad(matrixPositive(p));
else scoresPositive(p) = NaN;
end
end

%%
averagesadEachTweet = zeros(size(indexPositive,1),1);

for p = 1:size(indexPositive,1)
averagesadEachTweet(p) = nanmean(scoresPositive(p,:));
end
%%
averagesadAFL = nanmean(averagesadEachTweet)
%%

vectorPositive = zeros(size(indexPositive,1)*size(indexPositive,2),1);

for p = 1:size(vectorPositive)
vectorPositive(p) = matrixPositive(p);

end

%%
vectorPositiveNoNaN = vectorPositive(all(~isnan(vectorPositive),2),:); % for nan – rows
%%

uniqueVectorPositive = unique(vectorPositiveNoNaN);
countVectorPositive = histc(vectorPositiveNoNaN,uniqueVectorPositive);
figure
plot(uniqueVectorPositive,countVectorPositive,’b.’)
xlabel(‘Words used’, ‘FontSize’, 20)
ylabel(‘Count for each word’, ‘FontSize’, 20)
set(gca,…
‘XTickLabel’,”)

%%

for p = 1:length(uniqueVectorPositive)
cellWords{p} = word{uniqueVectorPositive(p)};
end
%%
for p = 1:length(uniqueVectorPositive)
if countVectorPositive(p) > 12
text(uniqueVectorPositive(p),countVectorPositive(p),cellWords{p},’FontSize’,22)
else
text(uniqueVectorPositive(p),countVectorPositive(p),”)
end
end
%%

indexNRL = find(~cellfun(@isempty,NRLtemp));
tweetsNRL = T(indexNRL);
%%
load(‘sentiment.mat’);
%%
for h = 1:size(tweetsNRL,2)
segmentedNRL{h} = regexp(tweetsNRL{h},’ ‘,’split’);
end
%%
for j = 1:size(segmentedNRL,2)

thisTweet = segmentedNRL{j};

for k = 1:size(thisTweet,2)

thisWord = thisTweet{1,k};
indexPositive{j,k} = strmatch(thisWord, word,’exact’);
end
end
%%

totalCells = size(indexPositive,1)*size(indexPositive,2);
matrixPositive = zeros(size(indexPositive,1),size(indexPositive,2));

for p = 1:totalCells
if isempty(indexPositive{p}) == 0
matrixPositive(p) = indexPositive{p};
else matrixPositive(p) = NaN;
end
end

%%
scoresPositive = zeros(size(indexPositive,1),size(indexPositive,2));

for p = 1:totalCells
if isnan(matrixPositive(p)) == 0
scoresPositive(p) = sad(matrixPositive(p));
else scoresPositive(p) = NaN;
end
end

%%
averagesadEachTweet = zeros(size(indexPositive,1),1);

for p = 1:size(indexPositive,1)
averagesadEachTweet(p) = nanmean(scoresPositive(p,:));
end
%%
averagesadNRL = nanmean(averagesadEachTweet)

%%
vectorPositive = zeros(size(indexPositive,1)*size(indexPositive,2),1);

for p = 1:size(vectorPositive)
vectorPositive(p) = matrixPositive(p);

end

%%
vectorPositiveNoNaN = vectorPositive(all(~isnan(vectorPositive),2),:); % for nan – rows
%%

uniqueVectorPositive = unique(vectorPositiveNoNaN);
countVectorPositive = histc(vectorPositiveNoNaN,uniqueVectorPositive);
figure
plot(uniqueVectorPositive,countVectorPositive,’b.’)
xlabel(‘Words used’, ‘FontSize’, 20)
ylabel(‘Count for each word’, ‘FontSize’, 20)
set(gca,…
‘XTickLabel’,”)

%%

for p = 1:length(uniqueVectorPositive)
cellWords{p} = word{uniqueVectorPositive(p)};
end
%%
for p = 1:length(uniqueVectorPositive)
if countVectorPositive(p) > 12
text(uniqueVectorPositive(p),countVectorPositive(p),cellWords{p},’FontSize’,22)
else
text(uniqueVectorPositive(p),countVectorPositive(p),”)
end
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s