Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7776 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

I have the following script which is supposed to create a keyword list from a long text field. Where it is failing is that certain times either a letter or series of letters, not only comes up to be replaced in the text, but also comes at the end of other words in the text. For instance, I have the script replace the word "MB ", but then when "dumb " appears, it becomes "du". Eventually, if the text is long enough, it all starts to deteriorate, since then "du" is a two-letter word to be deleted, and so on, until there's little but garbage left, not keywords. Here's the script:

Go to Record/Request/Page [ First ]

Loop

Set Field [ CommonWords_Holder, CommonWords2 ] (This sets a global to the text field contents)

Loop

Exit Loop If [ WordCount(CommonWords_Holder) ? 1 ]

Set Field [ CommonWords_Holder, Trim(CommonWords_Holder) ]

Copy [ Word_Copy ] [ Select entire contents ] (this retrieves the first word of the text from a calc field which holds it)

Paste [ Global_Text_Holder ] [ Select entire contents ] (This is a text global for holding the first word)

Go to Field [ CommonWords_Holder ] [ Select/perform ]

Perform Find/Replace [ Find: Global_Text_Holder_Calc; Replace:

Posted

Try replacing based on " " & Global_Text_Holder & " ". This ensures that ' dumb ' is left alone while ' mb ' is removed.

Posted

Hi--

Actually, the reason I didn't do that is it creates another bug. When a word is first in the list, normally, there is no space in front of it. So if the word is "Foo ", It will never be replaced, and so the script keeps printing "Foo " endlessly in the keywords field. So the problem is that I don't know how to account for both instances.

All My Best,

Jeffrey

Posted

If CommonWords_Holder is the field containing the text, simply prepend/append a " " wherever you require it. E.g. Set Field[ CommonWords_Holder, " " & Trim(CommonWords_Holder) & " "].

Will that work for you?

Posted

So add a space to the list before you start replacing, and remove it at the end.

Posted

Here is an alternative way that is a bit more efficent

1. Create a global number field

g_WordCount

2. Change your CommonWords_Holder to a text field.

3. Create a 1 to 1 self relationship (UniqueID::UniqueID)

4. Create a value list "Keywords" that uses values from related field selfjoin::CommonWords_Holder

Your Script would be:

set field [g_WordCount, wordcount(CommonWords2)]

loop

if [length(leftwords(rightwords(CommonWords2,g_WordCount),1))>3]

set field [CommonWords_Holder,CommonWords_Holder& Leftwords(Rightwords(CommonWords2,g_WordCount),1)& "PP"]

end if

set field [g_WordCount, g_Wordcount-1]

exit loop if [g_wordcount=0]

end loop

set field [CommonWords_Holder, ValueListItems(status(currentFileName, "KeyWords"))

This adds every word larger than 3 letters to WordCount_Holder seperated by carrige returns, then uses the valuelistitems function to filter out duplicates and alphabetize. Just tested it out- works great. I hope that is what you wanted...Anyway, had some time to kill.

-Raz

This topic is 7776 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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