Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How do I create a list with the 10 most frequently used words in a file?

by NetWallah (Canon)
on Apr 29, 2019 at 18:22 UTC ( [id://1233151]=note: print w/replies, xml ) Need Help??


in reply to How do I create a list with the 10 most frequently used words in a file?

Here is the obligatory "one-liner" to get the top ten word frequency:
perl -anE "$c{$_}++ for @F}{ ++$top<11 && say qq|$c{$_}\t$_| for sort +{$c{$b}<=>$c{$a}} keys %c" YOUR-FILE.txt
Use single-quotes instead of double, for Linux.

                "It's ten o'clock... Do you know where your AI programs are?"

  • Comment on Re: How do I create a list with the 10 most frequently used words in a file?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1233151]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-26 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found