Word frequency: Difference between revisions

Content added Content deleted
(→‎{{header|KAP}}: Fox formatting for KAP code)
Line 2,622: Line 2,622:
The below program defines the function 'stats' which accepts a filename containing the text.
The below program defines the function 'stats' which accepts a filename containing the text.


<lang kap>
<lang kap>∇ stats (file) {
∇ stats (file) {
content ← "[\\h,.\"'\n-]+" regex:split unicode:toLower io:readFile file
content ← "[\\h,.\"'\n-]+" regex:split unicode:toLower io:readFile file
sorted ← (⍋⊇⊢) content
sorted ← (⍋⊇⊢) content
Line 2,629: Line 2,628:
words ← selection / sorted
words ← selection / sorted
{⍵[10↑⍒⍵[;1];]} words ,[0.5] ≢¨ sorted ⊂⍨ +\selection
{⍵[10↑⍒⍵[;1];]} words ,[0.5] ≢¨ sorted ⊂⍨ +\selection
}</lang>
}
</lang>
{{out}}
{{out}}
<pre>┏━━━━━━━━━━━━┓
<pre>┏━━━━━━━━━━━━┓