home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum16.lzh
/
SOFTWARE
/
AWK
/
EXAMPLES
/
p119
< prev
next >
Wrap
Text File
|
1991-05-06
|
498b
|
14 lines
# wordfreq - print number of occurrences of each word
# input : text
# output: number-word pairs sorted by numbers
{ gsub(/[.,:;!?(){}]/,"")
for (i = 1; i <= NF; i++) count[$i]++ }
END { for (w in count) print count[w], w }
# The book (p.118) proposes a pipe in the END bracket.
# This will not work, a procedure file workaround (or
# a command line pipe command must be used.
# Note - use SED to do case conversion,
# so Bug and bug are counted as the same word