Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2018, 05:06 AM
Marcway Marcway is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 7 64bit How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2007
Novice
How to count words in a text, arrange them in separate lines and put the grammar class ?
 
Join Date: Dec 2018
Posts: 2
Marcway is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-03-2018, 08:27 AM
Charles Kenyon Charles Kenyon is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 10 How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #3  
Old 12-03-2018, 03:18 PM
Guessed's Avatar
Guessed Guessed is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 10 How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #4  
Old 12-03-2018, 07:47 PM
macropod's Avatar
macropod macropod is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 7 64bit How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 12-04-2018, 10:09 AM
Charles Kenyon Charles Kenyon is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 10 How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #6  
Old 12-07-2018, 04:11 AM
Marcway Marcway is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 7 64bit How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2007
Novice
How to count words in a text, arrange them in separate lines and put the grammar class ?
 
Join Date: Dec 2018
Posts: 2
Marcway is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 12-14-2018, 04:25 PM
macropod's Avatar
macropod macropod is offline How to count words in a text, arrange them in separate lines and put the grammar class ? Windows 7 64bit How to count words in a text, arrange them in separate lines and put the grammar class ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Marcway View Post
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 did warn that Word would report various common words as exceptions.
Quote:
Originally Posted by Marcway View Post
Is it possible that the words were counted and that this number of occurrences appeared at the end of the grammar class?
Yes, but that would require a different approach and, insofar as the context is a crucial aspect of which part of speech a word belongs to, would diminish the benefits of the analysis.
Quote:
Originally Posted by Marcway View Post
Can the WebJspell tool (http://natura.di.uminho.pt/webjspell/jsol.pl) be used?
Possibly, but that would require an entirely different programming approach and, in any event, even that tool lacks contextual analysis.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

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
How to count words in a text, arrange them in separate lines and put the grammar class ? 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
How to count words in a text, arrange them in separate lines and put the grammar class ? Creating Text to count words WITHOUT title page ingmar.s Word 3 10-08-2009 10:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft