[Tutor] Please comment on this code...WORD FREQUENCY COUNTER

Tiago Saboga tiagosaboga at terra.com.br
Tue Oct 24 03:34:45 CEST 2006


Em Segunda 23 Outubro 2006 18:03, Asrarahmed Kadri escreveu:
> Folks,
>
> I have written a program which calculates teh frequency of each word that
> appears in a file. I would like to have your feedback.

Sorry, I couldn't resist. Others talked about your code, but here's what I use 
(no, it's not python, it's just linux utils):

$ sed -e 's/[[:space:]]/\n/g' -e 's/.*/\L&/g' -e 's/[][,;.:()]//g' 
myfile.txt | sort -d | uniq -c | sort -n

Tiago.


More information about the Tutor mailing list