Counting verbs

R

Rafael T

Hello

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

thanks
 
J

Jean-Guy Marcil

Rafael T said:
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!
 
R

Rafael T

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.
 
J

Jean-Guy Marcil

Rafael T said:
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?
 
S

Sam Hobbs

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
 
R

Rafael T

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.

Hello

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

thanks
 
R

Rafael T

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
 
S

Sam Hobbs

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top