dbTalk Databases Forums  

Generate a list of occurences of a word?

comp.databases.ms-access comp.databases.ms-access


Discuss Generate a list of occurences of a word? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christopher M.
 
Posts: n/a

Default Generate a list of occurences of a word? - 12-27-2011 , 09:36 PM






I found some code for generating a list of the number of occurrences of a
word in a Word document.
http://word.tips.net/T000879_Determi...Frequency.html

I'd like to do the same for fields in a table.


W. Pooh (AKA Winnie P.)

Reply With Quote
  #2  
Old   
Christopher M.
 
Posts: n/a

Default Re: Generate a list of occurences of a word? - 12-27-2011 , 09:42 PM






"Christopher M." <nospam_flibbity (AT) floo (DOT) com> wrote

Quote:
I found some code for generating a list of the number of occurrences of a
word in a Word document.
http://word.tips.net/T000879_Determi...Frequency.html

I'd like to do the same for fields in a table.
I also found this code for Excel. It creates a scripting dictionary
containing the word frequencies:
http://www.ozgrid.com/forum/showthread.php?t=95370


W. Pooh (AKA Winnie P.)

Reply With Quote
  #3  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Generate a list of occurences of a word? - 12-28-2011 , 08:49 AM



Christopher M. wrote:
Quote:
I found some code for generating a list of the number of occurrences
of a word in a Word document.
http://word.tips.net/T000879_Determi...Frequency.html

I'd like to do the same for fields in a table.


This is not really a task that sql (I'm talking about the language) is
suited for, especially JetSQL, at least, on its own. One problem is
identifying when a sequence of characters is actually a word. Some patterns
might be:
a number of characters
- surrounded by spaces
- space in front and end-of-line character after, or vice versa
- with a space in front and a punctuation mark after or vice versa
- if storing html, then you have to worry about tags
- combinations of the above

Some problems might be:
- hyphenated words: two separate words or a single word?

Depending on how many of the above patterns you have to deal with, you will
likely need to resort to creating a VBA function to do the actual counting
of the specified word in a passed string, perhaps using regular expressions.
Then use the function in a grouping query like this:

select SUM(WordCount("word", [Field1]) + WordCount("word", [Field2])
As Occurrences
FROM tablename

I've never had an occasion to write such a function so this is the extent of
the help I can offer.

Reply With Quote
  #4  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Generate a list of occurences of a word? - 12-28-2011 , 10:33 AM



On Dec 27, 9:36*pm, "Christopher M." <nospam_flibb... (AT) floo (DOT) com> wrote:
Quote:
I found some code for generating a list of the number of occurrences of a
word in a Word document.http://word.tips.net/T000879_Determi...Frequency.html

I'd like to do the same for fields in a table.

W. Pooh (AKA Winnie P.)
The following function splits a string into words then checks those
words against the word to search and returns a count.
Public Function OccursWord(var As Variant, strWord As String) As Long
If Not IsNull(var) Then
Dim ar() As String
Dim intFor As Integer

ar = Split(var, " ")

For intFor = LBound(ar) To UBound(ar)
If ar(intFor) = strWord Then OccursWord = OccursWord + 1
Next
End If
End Function

In a query you could enter something like
WordCount : OccursWord([MyMemoField],"test")
to create a column called WordCount that contains the word "test" in a
field called MyMemoField.

Reply With Quote
  #5  
Old   
Christopher M.
 
Posts: n/a

Default Re: Generate a list of occurences of a word? - 12-28-2011 , 03:12 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
Christopher M. wrote:
I found some code for generating a list of the number of occurrences
of a word in a Word document.
http://word.tips.net/T000879_Determi...Frequency.html

I'd like to do the same for fields in a table.


This is not really a task that sql (I'm talking about the language) is
suited for, especially JetSQL, at least, on its own. One problem is
identifying when a sequence of characters is actually a word. Some
patterns
might be:
a number of characters
- surrounded by spaces
- space in front and end-of-line character after, or vice versa
- with a space in front and a punctuation mark after or vice versa
- if storing html, then you have to worry about tags
- combinations of the above

Some problems might be:
- hyphenated words: two separate words or a single word?

Depending on how many of the above patterns you have to deal with, you
will
likely need to resort to creating a VBA function to do the actual counting
of the specified word in a passed string, perhaps using regular
expressions.
Then use the function in a grouping query like this:

select SUM(WordCount("word", [Field1]) + WordCount("word", [Field2])
As Occurrences
FROM tablename

I've never had an occasion to write such a function so this is the extent
of
the help I can offer.
I'm sorry. I was looking for something that counts both words and common
phrases.

I should probably look for some software. Thanks.


W. Pooh (AKA Winnie P.)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.