How to Limit Text Length

Adhering to the exact length specifications of a text is always a challenge - and the level of difficulty is significantly increased for dynamic texts, such as generated texts:

Numerous factors influence the length of the text. These are e.g. Containers with values that vary in the number of characters, triggers that turn certain Statements and Branches on or off, and variance methods such as Branches with different phrasing for certain facts.

However, it is still required to keep hold of such text limits, e.g. due to shop layout or SEO requirements. Therefore, the AX platform has text length limitation features.

Set Overall Text Length on Project/Collection Level

To control the amount of text in a project, you can set a limit on the total number of characters in project text for each Collection.

Screenshot Collection SettingsIn Data Sources click on your Collection and then edit to set the maximum text length

Then select in the individual Statement settings which Statements must always be included (set switch to obligatory) and which Statements can be left out in the case of a reduction. During rendering, the Statements that are not non-obligatory will be omitted one by one. This is done until the number of characters is below the upper limit.

To shorten the text, the Statements are gone through in reverse order: from last statement at the end towards the first statement at the beginning. This has the advantage that you can still put the most important messages or facts at the beginning of the text and the less important details at the end.

As rule of thumb: the more control you intend to have over the structure and content of the text, the fewer non-obligatory statements you should include. This means approaching the maximum from below and writing fewer statements.

TIP

When estimating how many statements to set as non-obligatory, pay attention to the properties of your rule set: For example, many triggers that result in some statements not being triggered lead to logical cuts in the text.

Control the Length of Text Parts on Statement and Branch Level

In some cases, there are additional restrictions on text length: Certain parts of the text may not exceed a certain number of characters, such as SEO titles or some headlines. This requires more granular settings. For this the NLG platform provides ways to control text length at Branch and Statement level by allowing you to set the maximum number of characters at each Branch or Statement.

TIP

To set the limits for Statements and Branches turn on the Advanced Shortening feature in the Project Settings > Feature Previews.

Note that it cannot be switched off again.

Screenshot Shortening BranchesBy setting a specific number of characters for a branching, you can precisely define the length of text sections.

1. Statement Shortening

You set the maximum number of characters in a Statement to make sure that a Statement that is longer than this number will not be rendered.

  1. You will receive an error message if the limit is exceeded and you have created the Statement without optional Branches.

WARNING

This error message is only shown if your Statement is set as oblitgatory. Optional Statements that exceed the maximum length in their Statement settings are omitted without warning.

  1. To build in flexibility you can split the Statement into Branches and set one or more of the Branches as optional. This way the optional Branches will be skipped from right to left until the number of characters is below the set level.

Partial Shortening on Statement levelPartial text shortening configurable per statement: optional branching "waschbar bis 40°C" has been removed to make the length requirement

2. Branching Shortening

Length can also be configured in the same way per Branching. Set the limit in the settings of the Branching and decide which Branches are optional.

  • As with the Statement, you can also add optional Branchings within the Branch you want to specify the parts that may be omitted.
  • If the number of characters of a Branch is exceeded then
    • firstly, the optional Subbranches of this Branch will be omitted from right to left until the limit is undercut.
    • If this would not be suffcient the next Branch of this Branching is rendered.

Skip Branches to get the required text lengthBranchings will switch to the next branch if the length requirement can not be reached.

TIP

To see how the shortenings affect the results, check your settings with several Test objects!