![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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! 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 Specs![]() |
| | #3 (permalink) |
| | 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. (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 Specs![]() |
| | #4 (permalink) |
| | 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. (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 Specs![]() |
| | #5 (permalink) |
| | 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 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 Specs![]() |
| | #6 (permalink) |
| | 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). -- (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 Specs![]() |
![]() |
| 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 | |||