Below we've broken down a few of the fundamental building blocks that we used in this doc. But don't limit yourself to these examples - there are lots of ways to create text generation!
Show off your own NLG docs in the ! Example 1: Using the SWITCHIF() function
The SWITCHIF() formula is an easy way to generate flexible text in Coda. For example, switch between different games using the dropdown below. Notice how the sentence changes👇.
Nationals v Braves | @Nationals Park | Sun, Sep 2, 6:50 PM
- - The faced off against the on in what turned out to be a day at . 👏Cool right?
We can extend that by adding in a second sentence about the outcome of the game:
The with a final score of - . Notice how we can change "won" to "barely won" using our outcome definitions found in . Example 2: Using the RANDOM() function
This is an example of using the RANDOM() formula to make each game summary a little different. Each phrase is randomly selected from to add some pizzaz to the summary. Take a look at the RANDOM() formula in the Top moment text gen column. It's a little complicated, but the basic text gen logic is:
[Player] + [Top moment phrase] + [Amazing play]
You'll notice that each time a change is made to the doc (typing, clicking, refreshing, etc.), the top moment phrase changes. This is because the RANDOM() formula selects a new number each time the Coda doc recalculates. If this drives you crazy, change the formula to RANDOM(false), which keeps the formula from recalculating.
Try adding in new "top moments" phrases below👇 and notice that they randomly appear in the Top moment text gen column above 👆(after the RANDOM() formulas recalculate a few times).