Jump to content
Sign in to follow this  
Barry K

Pattern count/Keyword density probelm

Recommended Posts

Hi, 

I have a list of about 400 keywords Im looking for from a free form text field. What I am trying to accomplish is to find the number of occurrences of keywords from the list of keywords in the txt field where i have many paragraphs of text.

  • I have one field where I have all the keywords stored, all lower case
  • Another field where I have free form text, all lower case.

I am trying to see how many times keywords from the list come up as pattern matches from the text field of free form text.

 

For example

here is a short list words im looking for :

bob

went

store

and the text field has "bob went to the store, then bob went home."

I would like a 3rd field to say:

bob came up 3 times

went came up 2 times

store came up 1 times

 

Ive attached an example file. Thanks for any help you can give:)

pattern.fmp12.zip

Share this post


Link to post
Share on other sites

Hi Barry

Please find enclosed a sample file.

The way it works is :-

Count the number of values in the search list

Go round a loop that many times, and for each value, use PatternCount to see how many times it appears, and add the result to the 'answer' field.

It runs as a script, rather than it being a calculation field, hope that is OK?

pattern.fmp12.zip

Share this post


Link to post
Share on other sites
2 hours ago, Barry K said:

I am trying to see how many times keywords from the list come up as pattern matches from the text field of free form text.

There can be a big difference between how many times a keyword comes up as a pattern match and how many times a keyword comes up as a word. Consider for example the following sentence:

Bob the nabob went home to eat kabobs and watch the skibobbing competition.

Using PatternCount() will return 4 occurrences of the pattern "bob" - while a custom function such as CountWordOccurrences() will detect only 1 occurrence of the word "bob".

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.