| View previous topic :: View next topic |
| Author |
Message |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Tue Dec 13, 2005 1:55 pm Post subject: word count and not string count |
|
|
dr dread,
i need your help with string.dll ... i have a file that contains 'driving lesson' and 'driving lessons' ... i need to count the number of times each is used ... the problem i come across using string.dll is that when i do a count for 'driving lesson', it also counts the number of times 'driving lessons' occurs because 'driving lessons' contains 'driving lesson' as i am using the string count part of string.dll ... i can't find a way for a word count
is there an easy way for me to be able to get the correct count for 'driving lesson' and 'driving lessons' separately using string.dll?
thanks in advance
serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Dec 13, 2005 2:16 pm Post subject: |
|
|
Have you tried something like this:
count "driving lesson"
count "driving lessons"
subtract second count from first, then I guess you should have the real count of "driving lesson".
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Dec 14, 2005 12:34 am Post subject: |
|
|
i take it from your answer that there is no way easy way to do it ... the example i gave you is a very simplified version and i thought of doing a take away but given the way the code is written, this will be very difficult to do as the code does word counts for all sorts of other things as well
thanks for your answer, i will have to think of a work around
serge _________________
|
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Dec 14, 2005 3:15 am Post subject: |
|
|
Any chance you can look for the words with a space after them?
Like "driving lesson " and "driving lessons " _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Dec 14, 2005 7:25 am Post subject: |
|
|
| Serge wrote: | | i take it from your answer that there is no way easy way to do it ... |
If by easy you mean pre-made function, then no.
| Serge wrote: | | the example i gave you is a very simplified version |
Well, if you want to do complex stuff, then my advice would be the same as always in these situations - use the force.
The force being a regular expression.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Dec 14, 2005 8:35 am Post subject: |
|
|
| Quote: | Any chance you can look for the words with a space after them?
Like "driving lesson " and "driving lessons " |
i thought of that too but the program does word counts in web pages and some words will not have a space after them but punctuation eg. 'driving lesson.'
| Quote: | | If by easy you mean pre-made function |
that is exactly what i was after and thought that may be i missed something in the help file that would enable me to do that
never mind, i will try and use the force eg. try and susbstitute all punctuations with a space and then look for "driving lesson "
string.dll is still a fantastic piece of work and thanks for bringing it out for us to use
serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Dec 14, 2005 11:42 am Post subject: |
|
|
Actually there's no need to do any replacements.
Use a loop with RegxFind and a counter
Change the RegxFind starting pos for each loop, so you start behind the latest match
Regx has a nice word boundary operator \b so use a RegEx like \bdriving lesson\b
That should do the trick.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Dec 14, 2005 2:52 pm Post subject: |
|
|
i will give that a try ... i am pulling what is left of my hair at the moment as the workaround i impleted only works some of the time and i can't work out why ... ggrr!!!
thanks for that
serge _________________
|
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Thu Dec 15, 2005 9:11 am Post subject: |
|
|
dr dread,
you are a legend
your tip is just what i needed and i don't have to try and find a work around ... i can now keep my hair a bit longer
thanks
serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Fri Dec 16, 2005 9:03 am Post subject: |
|
|
Great.
Perhaps start working more with RegExes - they can be a bit hairy so possibly you could even add
to your hair growth
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Dec 16, 2005 9:10 am Post subject: |
|
|
will do
serge _________________
|
|
| Back to top |
|
 |
|