Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - About word frequency

Reply
 
Old 09-17-2009   #1 (permalink)
buddy


 
 

About word frequency

To All:

Is it possible to count word frenquecy?I have lots of text file that
have so many duplicate phone numbers, I used regular expression to
filter all the phone num in a list, how to perfom word frequency
counting by using vbs?Thanks!

My System SpecsSystem Spec
Old 09-18-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: About word frequency


"buddy" <buddy.qin@newsgroup> wrote in message
news:4d0e4a2d-9d06-4722-bd64-a38939775861@newsgroup
Quote:

> To All:
>
> Is it possible to count word frenquecy?I have lots of text file that
> have so many duplicate phone numbers, I used regular expression to
> filter all the phone num in a list, how to perfom word frequency
> counting by using vbs?Thanks!
I always chuckle when posters ask "Is it possible to . . ." and I'm tempted
to say "Yes, it is possible!". I suspect that this is not really what you
want to know, so here is a suggestion:
1. Put your phone numbers into a string, separated by a suitable divider,
e.g. like so:
059 229 8732?034 887 9912?012 555 3964
2. Use the split function to turn the string into an array.
3. Sort the array.
4. Count the number of occurances of each unique number.


My System SpecsSystem Spec
Old 09-18-2009   #3 (permalink)
Tom Lavedas


 
 

Re: About word frequency

On Sep 18, 6:02*am, "Pegasus [MVP]" <n...@newsgroup> wrote:
Quote:

> "buddy" <buddy....@newsgroup> wrote in message
>
> news:4d0e4a2d-9d06-4722-bd64-a38939775861@newsgroup
>
Quote:

> > To All:
>
Quote:

> > Is it possible to count word frenquecy?I have lots of text file that
> > have so many duplicate phone numbers, I used regular expression to
> > filter all the phone num in a list, how to perfom word frequency
> > counting by using vbs?Thanks!
>
> I always chuckle when posters ask "Is it possible to . . ." and I'm tempted
> to say "Yes, it is possible!". I suspect that this is not really what you
> want to know, so here is a suggestion:
> 1. Put your phone numbers into a string, separated by a suitable divider,
> e.g. like so:
> * * 059 229 8732?034 887 9912?012 555 3964
> 2. Use the split function to turn the string into an array.
> 3. Sort the array.
> 4. Count the number of occurances of each unique number.
Yes, that's one way to do it, but that requires manual post-processig
(which I hate). Further, I suspect that the real desire (unexpressed)
is to extract a list of unique numbers. For that, I'd use a
dictionary, something like this ...

With CreateObject("Scripting.FileSystemObject")
aList = Split(.OpenTextFile("file1.txt", 1).ReadAll, vbNewLine)
end With

Set dUnique = CreateObject("Scripting.Dictionary")
For each sLine in aList
sline = trim(sline)
if sline <> "" Then
if dUnique.Exists(sLine) then
dUnique(sLine) = dUnique(sLine) + 1
else
dUnique(sLine) = 1
end if
end if
Next

for each k in dUnique.keys
wsh.echo k, dUnique.item(k)
next

Actually, this returns the unique items and their count. Note that it
does not sort the list.
_____________________
Tom Lavedas
My System SpecsSystem Spec
Old 09-18-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: About word frequency


"Tom Lavedas" <tglbatch@newsgroup> wrote in message
news:0519be80-c054-408f-b73c-ec3adad6dc20@newsgroup
On Sep 18, 6:02 am, "Pegasus [MVP]" <n...@newsgroup> wrote:
Quote:

> "buddy" <buddy....@newsgroup> wrote in message
>
> news:4d0e4a2d-9d06-4722-bd64-a38939775861@newsgroup
>
Quote:

> > To All:
>
Quote:

> > Is it possible to count word frenquecy?I have lots of text file that
> > have so many duplicate phone numbers, I used regular expression to
> > filter all the phone num in a list, how to perfom word frequency
> > counting by using vbs?Thanks!
>
> I always chuckle when posters ask "Is it possible to . . ." and I'm
> tempted
> to say "Yes, it is possible!". I suspect that this is not really what you
> want to know, so here is a suggestion:
> 1. Put your phone numbers into a string, separated by a suitable divider,
> e.g. like so:
> 059 229 8732?034 887 9912?012 555 3964
> 2. Use the split function to turn the string into an array.
> 3. Sort the array.
> 4. Count the number of occurances of each unique number.
Yes, that's one way to do it, but that requires manual post-processig
(which I hate). Further, I suspect that the real desire (unexpressed)
is to extract a list of unique numbers. For that, I'd use a
dictionary, something like this ...

With CreateObject("Scripting.FileSystemObject")
aList = Split(.OpenTextFile("file1.txt", 1).ReadAll, vbNewLine)
end With

Set dUnique = CreateObject("Scripting.Dictionary")
For each sLine in aList
sline = trim(sline)
if sline <> "" Then
if dUnique.Exists(sLine) then
dUnique(sLine) = dUnique(sLine) + 1
else
dUnique(sLine) = 1
end if
end if
Next

for each k in dUnique.keys
wsh.echo k, dUnique.item(k)
next

Actually, this returns the unique items and their count. Note that it
does not sort the list.
_____________________
Tom Lavedas

===========

In Step 5 I was actually thinking of counting the various strings with VB
Script code, not manually. However, since this appears to be a one-off task,
it might be more efficient to adopt a wholly manual approach:
1. Put the numbers into a text file, one number per line.
2. Open the text file with Excel.
3. Sort the numbers.
4. Look for unique numbers, or for repeated numbers.
This would probably require the least amount of time.


My System SpecsSystem Spec
Old 09-18-2009   #5 (permalink)
buddy


 
 

Re: About word frequency

On 9月18日, 下午8时26分, Tom Lavedas <tglba...@newsgroup> wrote:
Quote:

> On Sep 18, 6:02*am, "Pegasus [MVP]" <n...@newsgroup> wrote:
>
>
>
Quote:

> > "buddy" <buddy....@newsgroup> wrote in message
>
Quote:

> >news:4d0e4a2d-9d06-4722-bd64-a38939775861@newsgroup
>
Quote:
Quote:

> > > To All:
>
Quote:
Quote:

> > > Is it possible to count word frenquecy?I have lots of text file that
> > > have so many duplicate phone numbers, I used regular expression to
> > > filter all the phone num in a list, how to perfom word frequency
> > > counting by using vbs?Thanks!
>
Quote:

> > I always chuckle when posters ask "Is it possible to . . ." and I'm tempted
> > to say "Yes, it is possible!". I suspect that this is not really what you
> > want to know, so here is a suggestion:
> > 1. Put your phone numbers into a string, separated by a suitable divider,
> > e.g. like so:
> > * * 059 229 8732?034 887 9912?012 555 3964
> > 2. Use the split function to turn the string into an array.
> > 3. Sort the array.
> > 4. Count the number of occurances of each unique number.
>
> Yes, that's one way to do it, but that requires manual post-processig
> (which I hate). *Further, I suspect that the real desire (unexpressed)
> is to extract a list of unique numbers. *For that, I'd use a
> dictionary, something like this ...
>
> * With CreateObject("Scripting.FileSystemObject")
> * * aList = Split(.OpenTextFile("file1.txt", 1).ReadAll, vbNewLine)
> * end With
>
> * Set dUnique = CreateObject("Scripting.Dictionary")
> * For each sLine in aList
> * *sline = trim(sline)
> * *if sline <> "" Then
> * * *if dUnique.Exists(sLine) then
> * * * *dUnique(sLine) = dUnique(sLine) + 1
> * * *else
> * * * *dUnique(sLine) = 1
> * * *end if
> * *end if
> * Next
>
> * for each k in dUnique.keys
> * * wsh.echo k, dUnique.item(k)
> * next
>
> Actually, this returns the unique items and their count. *Note that it
> does not sort the list.
> _____________________
> Tom Lavedas
Thanks Tom! Before posting this thread, I also use Dictionary object
to get the unique num,but don't know how to use Exists method.So I
import the num list into Excel and use frequecy fuction to do job.And
also thanks Pegsus!
My System SpecsSystem Spec
Old 09-19-2009   #6 (permalink)
Dr J R Stockton


 
 

Re: About word frequency

In microsoft.public.scripting.vbscript message <evZ1ABGOKHA.1280@newsgroup
NGP04.phx.gbl>, Fri, 18 Sep 2009 15:02:23, "Pegasus [MVP]"
<news@newsgroup> posted:
Quote:
Quote:

>> I always chuckle when posters ask "Is it possible to . . ." and I'm
>> tempted
>> to say "Yes, it is possible!". I suspect that this is not really what you
>> want to know, so here is a suggestion:
>> 1. Put your phone numbers into a string, separated by a suitable divider,
>> e.g. like so:
>> 059 229 8732?034 887 9912?012 555 3964
>> 2. Use the split function to turn the string into an array.
>> 3. Sort the array.
>> 4. Count the number of occurances of each unique number.
>
>Yes, that's one way to do it, but that requires manual post-processig
>(which I hate).
In what way does it require *manual* post-processing?

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
CPU Maximum Frequency always 100% Vista performance & maintenance
Bad Frequency Test Vista performance & maintenance
frequency in rec/send Vista mail
WMP11 Playback Frequency Vista music pictures video
How to enable crossover frequency for SW? Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46