Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Counting verbs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rafael T - 08 May 2008 08:58 GMT
Hello

Is there any way to make word count the number of verbs in a document or highlighted portion?

thanks
Signature

**********
Rafael T

Jean-Guy Marcil - 08 May 2008 14:01 GMT
> Hello
>
> Is there any way to make word count the number of verbs in a document or highlighted portion?

Consider this sentence:

I will have been partying for a while to the beat of of African dance music
hits when your plane will have landed in the land of the of the midnight sun.

I know, it is twisted and ugly, but the point is, how many verbs are there?
There are two, but there are 7 words for those two verbs.
And what about "dance," "hits," "land"... in other sentences they might be
verbs...

How do you excpect a program to give you the correct total without human
intervention?

You would need a very complicated algorithm, and even then, the results
would never be really trustworthy.

That being said (or written!), with some creativity and lots of time to test
various sample texts, you might be able to do somthing using the synonym
list, which does have a "part of speech" element.

Here is some code directly from the VBA on-line help.
It lists all the main meanings (synonyms) associatd with a word and their
part of speech. If one of them is a verb, the source word might be a verb. If
all of them are verbs, the source word is most likely a verb, if none of them
are verbs, the source word is most likely not a verb. Notice that I am not
using absolutes because as soon as you handle English semantics and grammar,
there are no absolute.

Note that you would have to modify the code to scan each word in a
selection...
And find a way to flag those that might be verbs (Highlighting?)

Sub FindVerb()

Set mySynInfo = Selection.Range.SynonymInfo
If mySynInfo.MeaningCount <> 0 Then
   myList = mySynInfo.MeaningList
   myPos = mySynInfo.PartOfSpeechList
   For i = 1 To UBound(myPos)
       Select Case myPos(i)
           Case wdAdjective
                pos = "adjective"
           Case wdNoun
                pos = "noun"
           Case wdAdverb
                pos = "adverb"
           Case wdVerb
                pos = "verb"
           Case Else
                pos = "other"
       End Select
       MsgBox myList(i) & " found as " & pos
   Next i
Else
   MsgBox "There were no meanings found."
End If

End Sub

If you select "partying" in my ugly sentence above and run the code, you get
one meaning and it is a noun. If you select "landed", you get 0 meanings.

So, even this code cannot identify the two verbs in the sentence...

If you add code to strip "ing" or "ed" from words when scanning hem, then
"land" above (still in my ugly sentence) returns 2 noun meanings, 3 verbs and
one adjective... So, which is it? Would you trust the code to make a
decision? Based on which argumnents would the code make a decision? Also,
stripping "ing" or "ed" is not enough, consider "running" > "runn", "placed"
> "plac", "fitted" > "fitt"...
And, what about irregular verbs? put (no "ed"), found, bound. laid, sang, etc.

Good luck!
Rafael T - 09 May 2008 00:46 GMT
Thanks Jean,

Appreciate the sample code and the comments on how hard it will be.  As long
as I can get some results, I'm OK.
If there any way to access the grammar and style (not the regular grammar)
that part should be able to identify a little bit more about sentence
structure like the noun, verbs, and adjectives.

Signature

**********
Rafael T

>> Hello
>>
[quoted text clipped - 85 lines]
>
> Good luck!
Jean-Guy Marcil - 09 May 2008 13:57 GMT
> Thanks Jean,
>
> Appreciate the sample code and the comments on how hard it will be.  As long
> as I can get some results, I'm OK.

Yes, but useless results are not all that useful, are they? :-)

> If there any way to access the grammar and style (not the regular grammar)
> that part should be able to identify a little bit more about sentence
> structure like the noun, verbs, and adjectives.

Sorry, besides the code I posted, I do not know of any way to check if a
word is a verb or not.

Besides, as I stated before, a word could be all three (verb, noun or
adjective), only the context will tell which it is. Code to determine
something like this based on the context would be very complicated and, I
believe, beyond what VBA can do.

Sincerley, unless you have a different goal, I think you are wasting time
with this as this is not something VBA can do.

A possible scenario would be to find a software that would accept a string
programatically. Then, with VBA, you could feed a string to that software and
let it analyse it and return its verdict. If such a software that can ineract
with VBA were available, it would still be time consuming to analyse each
word in a document in this manner so as to identify the verbs.

What are you trying to do, overall?
Rafael T - 10 May 2008 04:25 GMT
Thanks Jean,

In school someone mentioned that it might be possible to automate some paper
checks on top of what word is doing, so i thought... hmmm let's see how hard
it could be.  that's why I started with what I thougth was going to be an
easy test....

well, its more related to grammatical structure and language rules than it
is on finding individual elements... but still I think is a good start.

do you know of any program that does a more accurate grammar, writing style,
or language check on a document?

thanks
Rafael

>> Thanks Jean,
>>
[quoted text clipped - 29 lines]
>
> What are you trying to do, overall?
Sam Hobbs - 10 May 2008 10:45 GMT
There are many software programs. There are even books on the subject of
parsing grammar using software.

There is an area of Artificial Intelligence called Natural Language
processing. I could not remember the term yesterday, but I do have a book on
the subject. Natural Language processing is software that understands
language. So you can get as advanced as you have the time to.

> Thanks Jean,
>
[quoted text clipped - 13 lines]
>
> "Jean-Guy Marcil" <JeanGuyMarcil@discussions.microsof
Rafael T - 11 May 2008 09:02 GMT
Thanks Sam,

i will start looking for more info on natural language process.

RT
> There are many software programs. There are even books on the subject of
> parsing grammar using software.
[quoted text clipped - 22 lines]
>>
>> "Jean-Guy Marcil" <JeanGuyMarcil@discussions.microsof
Sam Hobbs - 09 May 2008 14:26 GMT
This is more of a question of grammar than Word.

 Hello

 Is there any way to make word count the number of verbs in a document or highlighted portion?

 thanks
 --
 **********
 Rafael T
Rafael T - 10 May 2008 03:59 GMT
Sam,

Yes, I know it is more about grammar. I just thought that maybe word2007 was a bit more advance on the language usage.

Rafael
 This is more of a question of grammar than Word.

   "Rafael T" <okinawapro@hotmail.com> wrote in message news:exullEOsIHA.2208@TK2MSFTNGP04.phx.gbl...
   Hello

   Is there any way to make word count the number of verbs in a document or highlighted portion?

   thanks
   --
   **********
   Rafael T

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.