|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to count words in a text, arrange them in separate lines and put the grammar class ?
Hello everyone,
I would like to ask if there is any tool in Word that performs what I present below. If it exists, I would ask for help on how to do these actions in Word. Are the following: 1- There is a document with several words. How do I make Word, count each of these words, arrange them in separate lines and put the grammar class (*)? * Only for: nouns, adjectives and verbs For example: "Mathematicians seek and use patterns to formulate new conjectures; they solve the truth or falsity of conjectures by mathematical proof." (Wikipedia) With these words Word should list them like this: Mathematicians 1 adjective seek 1 verb and 1 use 1 verb patterns 1 noun to 1 formulate 1 verb new 1 adjective conjectures 2 noun they 1 resolve 1 verb the 1 truth 1 noun or 1 falsity 1 noun of 1 conjectures 2 noun by 1 mathematical 1 adjective proof 1 noun Is this possible ? Thanks, Marcway. |
#2
|
|||
|
|||
Picking nits:
"Mathematicians" is a noun (plural) "conjectures" is a verb or a noun Last edited by Charles Kenyon; 12-04-2018 at 10:11 AM. |
#3
|
||||
|
||||
Actually it would be possible but you would need a macro and it would have to refer to a big dictionary of nouns, adjectives and words.
If you create the dictionary first, the code would be relatively straight-forward as long as we close our eyes to the context of each word. eg I lead the way to the lead battery before being charged with assault and battery.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#4
|
||||
|
||||
Word is incapable of the context analysis needed to determine the part of speech for many words. For example, with your sample text, the following macro reports the potential parts of speech of most words - note the common exceptions!
Code:
Sub PartsOfSpeech() Dim wdSynInfo As SynonymInfo, wdSynList As Variant, i As Long, w As Long Dim wdSyn As String, StrWrd As String, StrTmp As String, StrOut As String With ActiveDocument.Range For w = 1 To .Words.Count StrTmp = "": StrWrd = Trim(.Words(w)) If StrWrd Like "[A-Za-z]*" Then Set wdSynInfo = SynonymInfo(Word:=StrWrd, LanguageID:=wdEnglishUS) If wdSynInfo.MeaningCount <> 0 Then wdSynList = wdSynInfo.PartOfSpeechList For i = 1 To UBound(wdSynList) Select Case wdSynList(i) Case wdAdjective: wdSyn = "adjective" Case wdNoun: wdSyn = "noun" Case wdAdverb: wdSyn = "adverb" Case wdVerb: wdSyn = "verb" Case wdConjunction: wdSyn = "conjunction" Case wdIdiom: wdSyn = "idiom" Case wdInterjection: wdSyn = "interjection" Case wdPreposition: wdSyn = "preposition" Case wdPronoun: wdSyn = "pronoun" Case Else: wdSyn = "other" End Select If UBound(Split(StrTmp, " ")) < 1 Then StrTmp = StrTmp & " " & wdSyn ElseIf Split(StrTmp, " ")(UBound(Split(StrTmp, " "))) <> wdSyn Then StrTmp = StrTmp & " " & wdSyn End If Next i StrOut = StrOut & vbCr & StrWrd & ": " & Replace(Trim(StrTmp), " ", ", ") Else StrOut = StrOut & vbCr & StrWrd & ": No meanings found." End If End If Next w End With MsgBox StrOut End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
I had no idea that the Object Model contained parts of speech.
Thank you for giving me a better idea of the scope of my ignorance. |
#6
|
|||
|
|||
Dear Charles, Andrew and Paul,
Many thanks for the precious help! I copied the code that was sent by our friend Paul and it worked correctly. Several words returned with the expression "no meanings found". I'm checking a way to widen the accuracy of each word exam as our friend Andrew suggested. Is it possible that the words were counted and that this number of occurrences appeared at the end of the grammar class? Can the WebJspell tool (http://natura.di.uminho.pt/webjspell/jsol.pl) be used? Many thanks, Marcway. |
#7
|
||||
|
||||
Quote:
Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Getting grammar check to ignore spacing associated with numbers but not with words | grrlwhit03 | Word | 0 | 06-20-2017 04:51 PM |
Putting separate words together | mohsen.amiri | Word | 1 | 10-27-2016 12:34 AM |
How to Re-arrange large field lines in talble | PRA007 | Word Tables | 4 | 03-18-2015 02:24 AM |
Separate lines in an Excel cell - possible? If so, how? | mtcn | Excel | 5 | 12-12-2014 01:06 PM |
Creating Text to count words WITHOUT title page | ingmar.s | Word | 3 | 10-08-2009 10:23 AM |