Code: Select all
text = #.readtext("hamlet.txt")
words = #.split(text, " ", ".", ",", ";", "'", "!", "?", "-", "(", ")", "[", "]", #.crlf, #.quot)
> i, 1..#.size(words,1)
>> words[i] = ""
key = #.lower(words[i])
dict[key] += 1
total += 1
<
#.sortval(dict)
#.reverse(dict)
#.output(total, " words; ", #.size(dict), " unique words")
> i, 1..10
key = dict[i]
#.output(i, " : ", key, " = ", dict[key])
<
Code: Select all
32885 words; 4634 unique words
1 : the = 1091
2 : and = 969
3 : to = 767
4 : of = 675
5 : i = 633
6 : a = 571
7 : you = 558
8 : my = 520
9 : in = 451
10 : it = 421