Using multiple scripts
So far you’ve created your text in a single script, and this is usually adequate for short texts. As a text gets longer, though, it becomes useful to split the text into smaller pieces that are easier to work with. You can do this by using multiple scripts.
The source data you are working with has information about each jurisdiction’s characteristics and information about who leads the government in each case. So, you might want to write a separate paragraph about each of these two sets of information, and build the paragraphs in separate scripts.
Click the Add New Script button (highlighted below) and name the script StateOrTerritory.
Create another new script and name it HeadOfState.
Note
The script name must comply with certain naming conventions. For example, you cannot enter a script name with spaces. For the full set of conventions, see Script names.
Click on Main to return to your Main script.
Cut the entire content of this script and paste it into the StateOrTerritory script.
Return to the Main script, which should be empty.
Click the Insert Script button and select StateOrTerritory from the drop-down. This inserts a call to that script into your Main script.
Click the Enter key to enter a paragraph break after the newly inserted script call.
Click Insert Script again and select HeadOfState from the drop-down. Your Main script should now have two script calls:
Click Preview and check that the output text is exactly as it was before. Of course, we have not yet added any content to the HeadOfState script. We’ll do that next.
Note
A common way to use NLG Studio is to start out with a target text that represents the kind of narrative you want to build from the data, and then to gradually evolve that text to be a script.
Go to your HeadOfState script and enter the following text:
The Premier, Daniel Andrews (ALP), is in his first term. He has one daughter, Grace, and two sons, Joseph and Noah.
Let’s focus on the first sentence first. There are two elements here we can directly replace with references to variables: the head of government’s name and the party he or she belongs to.
Insert the HeadOfGovt and Party variables using the Insert Variable button. Your HeadOfState script should now look like this.
There is one more thing to fix before progressing: states have premiers, but territories have chief ministers. To cover both possibilities, you need to replace the word Premier with a conditional that selects either Premier or Chief Minister depending on the data in the Type column.
Replace Premier with a conditional statement. You learned about conditional statements earlier in the tutorial, so try to do this on your own without reading ahead. If done correctly, your script should look like this:
And the underlying ATL (click on the ATL View button) should look like this:
Click Preview and check that the correct output text is being produced for each row.
If you have inserted the conditional correctly, rows 1-6 should output Premier, and rows 7 and 8 should output Chief Minister.
Both sentences in this script need further work, but you'll do this in the next section of the tutorial, which demonstrates how to use Studio's language functions.