Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Royal Oak, Michigan, USA
    Posts
    255
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Counter (v2000)

    I have a memo field capturing notes from dream study patients. We want to analyze the memo field in each record and produce a result that counts the number of occurrences of every single word for all records combined. I know 'a', 'and', 'the', etc. will appear a lot but we can exclude them from the final product. My challenge is how to count the total number of times each word appears.
    Hmmmm???
    Thanks!

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Word Counter (v2000)

    You need a words table, with two fields word and count.

    You could then use DAO code to loop through each of the records in your main table, parse the memo field into words, one word at a time and check the words table for this word. If it is present increment the count. If not add the new word to the table and set the counter to one.

    <post#=488688 >post 488688 </post#> had some code that is broadly very similar, and could be modified to do the job you want.
    Regards
    John



  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word Counter (v2000)

    I have attached a small demo. The module basParse contains a procedure WordFrequencies that takes two arguments: the name of the table and the name of the field whose word frequencies you want to count.

    The code assumes that you have created a table tblWords with 2 fields: Word (text, size large enough to hold the longest word you expect to occur, 30 should be ample), and Frequency (number). Existing records will be removed at the beginning of the procedure. The code uses the VBScript regular expressions object to parse the field into individual words (defined as consisting of upper and lower case letters, digits and underscores).

    The code uses DAO recordsets, so you need a reference to the Microsoft DAO 3.6 Object Library; if you prefer, you can easily adapt the code to use ADO instead of DAO.

    The first procedure in the module, TestParse, runs WordFrequencies on the tblEmployees table (a stripped down version of the table in the Northwind database that comes with Access).

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Counter (v2000)

    Hi Hans

    Nice demo, don't need it today, but who knows about tomorrow.

    Thanks, John

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Royal Oak, Michigan, USA
    Posts
    255
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Counter (v2000)

    Worked perfectly!!! Thanks Hans for sharing your expertise!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •