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

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

Recommended Posts

Posted

Hi,

Charles Ross (Chuck) posted the following script in 2010 to split the contents of a text field into text chunks, using the last period (within a period count) as text chunk separator:

Let(
  [
    MaxString = Left( String; 100 );
// Get the first 100 characters of the original string.
    PeriodCount = PatternCount( MaxString; "." );
// Find out how many periods are in the substring.
    PeriodPos = Position( PeriodCount; "."; 1; PeriodCount );
// Get the position of the last period.
    Substring = Left( MaxString; PeriodPos )
  ];

  Substring
)
 

I've only been able to get the first line to work with a given number of characters:

Left ( String ; 1880 )

When I add the rest of the script there is no error message, yet nothing is recovered from the String.

The second problem I have is: As the remaining text will not necessarily start at 1880, how do I calculate the recovery of the remaining text after the first text chunk is collected?

Thanks very much beforehand,

Daniel

Posted

What you show here is not a script, but a calculation. Perhaps it's part of the script that you refer to - sadly, without linking to it. You also don't show your own implementation, not even your input - so it is impossible to say what might be wrong.

Why don't you start from the beginning and show us an example of what you have, and explain what you want to end up with.

Posted (edited)

The original calc should be changed to 

PeriodPos = Position( MaxString; "."; 1; PeriodCount )

to make it work.

As comment said, we need more information to understand how it applies to your current problem (if it indeed does). Why the number 1880? Is it arbitrary, or does it have some significance?

Edited by doughemi
Posted

Thanks for your response.  I have text fields with +8000 characters within.  I need to separate the text into text chunks no larger than 1880 characters for further processing.  As the Let() calc didn't work, I split the Let() calc into five separate fields (see screenshot).  It's not elegant, but it works. 

So, I have my 1880 character text chunks but they're splitting words.  I would like to add the ". " PatternCount and PeriodPosition in order to avoid the word-splitting.

Hopefully this makes my question clearer.

Screen Shot 2017-05-31 at 11.36.45.png

Posted

Please post the link to the original topic.

I can't find a member named "Charles Ross (Chuck)" 

Posted (edited)
1 hour ago, Quito said:

 I need to separate the text into text chunks no larger than 1880 characters for further processing.

Where would these "chunks" go? Surely hard-coded calculation fields are not the best place to keep them (not to mention that what you need here is recursive processing, where the start of each chunk depends on the length of its preceding siblings). What is this "further processing" you need to do?

 

Edited by comment
Posted
3 minutes ago, Quito said:

Thanks for your response.  I have text fields with +8000 characters within.  I need to separate the text into text chunks no larger than 1880 characters for further processing.  As the Let() calc didn't work, I split the Let() calc into five separate fields (see screenshot).  It's not elegant, but it works. 

So, I have my 1880 character text chunks but they're splitting words.  I would like to add the ". " PatternCount and PeriodPosition in order to avoid the word-splitting.

Hopefully this makes my question clearer.

Screen Shot 2017-05-31 at 11.36.45.png

 

16 minutes ago, comment said:

What you show here is not a script, but a calculation. Perhaps it's part of the script that you refer to - sadly, without linking to it. You also don't show your own implementation, not even your input - so it is impossible to say what might be wrong.

Why don't you start from the beginning and show us an example of what you have, and explain what you want to end up with.

 

1 minute ago, comment said:

Where would these "chunks" go?

Source_text is split into Chunk1, Chunk2, Chunk3, Chunk4 and Chunk5 fields.  The problem is that the words are being split in two because the 1880 limit doesn't have any filter to stop sooner (to avoid the word-split).  Stopping at the end of the word isn't a viable option either as I need the entire sentence.

Posted
7 minutes ago, Quito said:

Source_text is split into Chunk1, Chunk2, Chunk3, Chunk4 and Chunk5 fields.  

As I said, it's not a good idea. And you didn't answer my question regarding the final purpose of this exercise.

Posted
12 minutes ago, doughemi said:

The original calc should be changed to 


PeriodPos = Position( MaxString; "."; 1; PeriodCount )

to make it work.

As comment said, we need more information to understand how it applies to your current problem (if it indeed does). Why the number 1880? Is it arbitrary, or does it have some significance?

Hi Doughemi,

That was it!  I was able to split the first chunk at 1815/1880.

Thank you for the sharp eye!

Although the number 1880 is indeed arbitrary, I am trying to avoid problems in the future.

OK, so first problem solved.  This is what Chunk1 looks like now:

Let(
[
MaxString = Left( Source_text ; 1880 );
PeriodCount = PatternCount( MaxString; ". " );
PeriodPos = Position( MaxString; ". "; 1; PeriodCount );
Substring = Left( MaxString; PeriodPos )
];
Substring
)

Chunk1 selects the last "period-space" within the first 1880 characters in the "Source_text" text field.

Chunks 2 to 5 are shown in the screenshot.

I need to modify Chunk2 so that instead of capturing from 1881 onwards it should

1. Either capture from the last "period-space" or

2. Perform a Length (Chunk1) and use that number to determine where Chunk2 should start.

I'll try #2 first.  Seems easier.

 

Screen Shot 2017-05-31 at 11.59.30.png

This topic is 2724 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.