Word frequency: Difference between revisions

Content added Content deleted
m (added omits)
(Added example for KAP)
Line 2,618: Line 2,618:
"he" │ 6816
"he" │ 6816
"had" │ 6140</pre>
"had" │ 6140</pre>

=={{header|KAP}}==
The below program defines the function `stats` which accepts a filename containing the text.

<lang kap>
∇ stats (file) {
content ← "[\\h,.\"'\n-]+" regex:split unicode:toLower io:readFile file
sorted ← (⍋⊇⊢) content
selection ← 1,2≢/sorted
words ← selection / sorted
{⍵[10↑⍒⍵[;1];]} words ,[0.5] ≢¨ sorted ⊂⍨ +\selection
}
</lang>
{{out}}
<pre>┏━━━━━━━━━━━━┓
┃ "the" 40387┃
┃ "of" 19913┃
┃ "and" 14742┃
┃ "a" 14289┃
┃ "to" 13819┃
┃ "in" 11088┃
┃ "he" 9430┃
┃ "was" 8597┃
┃"that" 7516┃
┃ "his" 6435┃
┗━━━━━━━━━━━━┛</pre>


=={{header|Kotlin}}==
=={{header|Kotlin}}==