Word frequency: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added syntax colouring the hard way)
No edit summary
Line 2,176: Line 2,176:


Var L=loadfile("rosettalesmiserables.txt")
Var L=loadfile("rosettalesmiserables.txt")
L=lcase(L)
'get deliminators
'get deliminators
for n as long=1 to 96
for n as long=1 to 96
Line 2,187: Line 2,188:


string_split(L,deliminators,s())
string_split(L,deliminators,s())

For n As Long=Lbound(s) To ubound(s)'lower case
s(n)=lcase(s(n))
Next


quicksort(s(),lbound(s),ubound(s))
quicksort(s(),lbound(s),ubound(s))
Line 2,208: Line 2,205:
print "frequency","word"
print "frequency","word"
print
print
for n as long=lbound(t) to lbound(t)+10
for n as long=lbound(t) to lbound(t)+9
print t(n).l,t(n).s
print t(n).l,t(n).s
next
next
Line 2,219: Line 2,216:
<pre>
<pre>
I saved and reloaded the file as ascii text.
I saved and reloaded the file as ascii text.

frequency word
frequency word


36672 the
41098 the
19624 of
19955 of
14082 and
14939 and
13586 a
14557 a
13543 to
13953 to
11524 he
11219 in
10275 in
9648 he
8545 was
8621 was
7325 that
7923 that
7129 his
6660 it

6360 is
time for operation 1.099869600031525 seconds


time for operation 1.11089929996524 seconds
</pre>
</pre>