Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,14 @@
function [result,count] = word_frequency()
URL='https://www.gutenberg.org/files/135/135-0.txt';
text=webread(URL);
DELIMITER={' ', ',', ';', ':', '.', '/', '*', '!', '?', '<', '>', '(', ')', '[', ']','{', '}', '&','$','§','"','','','-','','','\t','\n','\r'};
words = sort(strsplit(lower(text),DELIMITER));
flag = [find(~strcmp(words(1:end-1),words(2:end))),length(words)];
dwords = words(flag); % get distinct words, and ...
count = diff([0,flag]); % ... the corresponding occurance frequency
[tmp,idx] = sort(-count); % sort according to occurance
result = dwords(idx);
count = count(idx);
for k = 1:10,
fprintf(1,'%d\t%s\n',count(k),result{k})
end