🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Harald Nikolaus Fri, 17 Apr 1998 00:00
Counting and listing words
#6976
Author: Harald Nikolaus
Date: Fri, 17 Apr 1998 00:00
11 lines
1088 bytes

Hi,

does anybody know where I can find a program, an add-on, a macro or a 
Perl module that lists alle the words in a file
and also, how often they appear?
Or do I have to write it myself?

Greetings
Harald
Re: Counting and listing words
#6977
Author: Christian Wetzel
Date: Fri, 17 Apr 1998 00:00
13 lines
1209 bytes
Harald Nikolaus:

> does anybody know where I can find a program, an add-on, a macro or a
> Perl module that lists alle the words in a file
> and also, how often they appear?
> Or do I have to write it myself?

If you are on Unix, try

cat textfile | perl -pe 's/(^\s+|\s+$)//g;s/\s+/\n/g;' | sort | uniq -c

Christian
Re: Counting and listing words
#6978
Author: dkm
Date: Fri, 17 Apr 1998 00:00
28 lines
1296 bytes
Harald Nikolaus <harald@ruprecht.fsk.uni-heidelberg.de> wrote:

>
>Hi,
>
>does anybody know where I can find a program, an add-on, a macro or a 
>Perl module that lists alle the words in a file
>and also, how often they appear?
>Or do I have to write it myself?
>
>Greetings
>Harald
>

How about AWK:

{
for (i = 1; i <= NF; i++) word[$i]++
}
END {for (i in word) print i, word[i]
}

You probably want to eliminate the punctuation first.

For info on AWK, search DejaNews for "FAQ and AWK" in comp.lang.awk.

DKM
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads