Randomly inserting values in strings

Hi,

I’m looking for a good way to randomly from a table insert values in to a main string, something like:

This is $value1$ sentence and lets make it $value2$.

My input data in to this looks like:

RowID Value1 Value2

1 Good Larger
2 Nice Bigger
3 Cool Better

For each record I would like a function to randomly pick any Value1/2 value regardless of row ID so that the output could be:

RowID 1: This is nice sentence and lets make it better or
RowID 2: This is nice sentence and lets make it larger or
RowID 3: This is good sentence and lets make it better
etc

I’ve tried to use this function in the String Manipulation node but I can’t seem to work how to randomise the $Value1$ and “Value2” in the function:

join("This is a ", $Value1$, ". Let’s make it ", $Value2$)

Any help is hugely appreciated.

Hello @cason,

if you want to create one sentence per row you can use Shuffle or Target Shuffling node prior to String Manipulation node. Using Use seed option will shuffle it same every time.

Br,
Ivan

Thanks for the help @ipazin. In the end I used the Random Label Assigner (data) node since it gave me a lot of flexibility.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.