$ include "seed7_05.s7i"; include "gethttp.s7i"; include "strifile.s7i"; include "scanfile.s7i"; include "chartype.s7i"; include "console.s7i"; const type: wordHash is hash [string] integer; const type: countHash is hash [integer] array string; const proc: main is func local var file: inFile is STD_NULL; var string: aWord is ""; var wordHash: numberOfWords is wordHash.EMPTY_HASH; var countHash: countWords is countHash.EMPTY_HASH; var array integer: countKeys is 0 times 0; var integer: index is 0; var integer: number is 0; begin OUT := STD_CONSOLE; inFile := openStrifile(getHttp("www.gutenberg.org/files/135/135-0.txt")); while hasNext(inFile) do aWord := lower(getSimpleSymbol(inFile)); if aWord <> "" and aWord[1] in letter_char then if aWord in numberOfWords then incr(numberOfWords[aWord]); else numberOfWords @:= [aWord] 1; end if; end if; end while; countWords := flip(numberOfWords); countKeys := sort(keys(countWords)); writeln("Word Frequency"); for index range length(countKeys) downto length(countKeys) - 9 do number := countKeys[index]; for aWord range sort(countWords[number]) do writeln(aWord rpad 8 <& number); end for; end for; end func;