Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2462

Re: Count Ouccrence of words in a long text

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Albert Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Count Ouccrence of words in a long text
Date Wed, 18 May 2011 11:18:49 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <ir09up$25b$1@smc.vnet.net> (permalink)
References <iqtn8n$ilc$1@smc.vnet.net>
Lines 25
NNTP-Posting-Date 18 May 2011 10:19:49 GMT
NNTP-Posting-Host e54c07ad.news.twtelecom.net
X-Trace DXC=SS9L9Q7FbUFP;Ll>D9?]MBC_A=>8kQj6M=_1NR_H?JPMD4>5N:m;K;OEFiONJ7[GoF]:FVPdNU@<J
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:2462

Show key headers only | View raw


Hi,

> First of all I am pretty new to Mathematica, so excuse me if this has
> a simple answer.
>
> What I need is to be able to count the occurrence of each word of a
> text and count the times each word appears on it. I know how to do
> this on other languages but I am trying to achieve it with
> mathematica.
>
> Can someone hint me the way to go?

I think there might be languages that are better suited for this kind of 
tasks, especially if the text becomes _really_ long. Anyway, it is 
fairly easy in Mathematica and resonable fast, too:

text = Import["ExampleData/USConstitution.txt"];
words = StringCases[text, WordCharacter ..];
Tally[words]


hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Count Ouccrence of words in a long text Yako <yako@11y11.com> - 2011-05-17 11:47 +0000
  Re: Count Ouccrence of words in a long text Albert Retey <awnl@gmx-topmail.de> - 2011-05-18 11:18 +0000

csiph-web