Word frequency: Difference between revisions

Content added Content deleted
m (→‎version 1: added an informative message stating how many words found in the number of records and the filename used.)
Line 298: Line 298:
end /*while*/
end /*while*/
end /*#*/
end /*#*/
say right('word', 40) " " center(' rank ', 6) " count " /*display title for output*/
say commas(c) ' words found in ' commas(#-1) ' records read from the file: ' fID
say
say right('════', 40) " " center('══════', 6) "═══════" /* " title separator.*/
say right('word', 40) " " center(' rank ', 6) " count " /*display title for output*/
say right('════', 40) " " center('══════', 6) " ═══════" /* " title separator.*/
/* [↓] note the BY incr.*/
/* [↓] note the BY incr.*/
do tops=1 by 0 until otops==tops|tops>top /*process enough words to satisfy TOP.*/
do tops=1 by 0 until otops==tops|tops>top /*process enough words to satisfy TOP.*/
Line 313: Line 315:
wr=max( length(' rank '), length(top) ) /*find the maximum length of the rank #*/
wr=max( length(' rank '), length(top) ) /*find the maximum length of the rank #*/
do d=1 for words(tl); _=word(tl, d) /*process each of the words in the TL. */
do d=1 for words(tl); _=word(tl, d) /*process each of the words in the TL. */
if d==1 then w=max(8, length(@._) ) /*use length of the first number used. */
if d==1 then w=max(10, length(@._) ) /*use length of the first number used. */
say right(@@._, 40) right(commas(tops), wr) right(commas(@._), w)
say right(@@._, 40) right(commas(tops), wr) right(commas(@._), w)
@._=0 /*nullify this word count for next time*/
@._=0 /*nullify this word count for next time*/
Line 326: Line 328:
{{out|output|text=  when using the default inputs:}}
{{out|output|text=  when using the default inputs:}}
<pre>
<pre>
23,414 words found in 67,663 records read from the file: les_mes.TXT
word rank count

════ ══════ ═══════
the 1 41,088
word rank count
of 2 19,949
════ ══════ ═══════
and 3 14,942
the 1 41,088
a 4 14,595
of 2 19,949
to 5 13,950
and 3 14,942
in 6 11,214
a 4 14,595
he 7 9,607
to 5 13,950
was 8 8,620
in 6 11,214
that 9 7,826
he 7 9,607
it 10 6,535
was 8 8,620
that 9 7,826
it 10 6,535
</pre>
</pre>
To see a list of the top 1,000 words that show (among other things) words like &nbsp; '''it's''' &nbsp; and other accented words, see the discussion page. <br><br>
To see a list of the top 1,000 words that show (among other things) words like &nbsp; '''it's''' &nbsp; and other accented words, see the discussion page. <br><br>