Advanced Expressions – String concatenation
To improve the user experience, various Concept Instances Rainbird gathers whilst completing a query can be combined to create a “string concatenation” . Using string concatenations allows Rainbird to return more detailed and conversational results.
For example, if a query was being run to find out what language a user speaks, if using string concatenation, Rainbird could return a phrase such as “%USER speaks %LANGUAGE”; without string concatenation, Rainbird would just return the “%LANGUAGE” value:
Figure 1: Result not using string concatenation
Figure 2: Result using string concatenation
String concatenations can be built up with a variety of different elements, such as relationship subjects or objects (%S or %O), a specific value e.g %MAKE_OF_CAR, letters, words and/or symbols.
It is important to combine every element in the string correctly, as well as to assign the expression to a variable (normally “%O”) for Rainbird to display the string concatenation:
- Text has to be enclosed in apostrophes ‘ ‘
- Each String element is connected with a ‘+’ sign
- Variables need to be in capital letters and spaces need to be replaced with an underscore e.g %EXAMPLE_CAR
Figure 3: Building a string concatenation
The concatenated string is then returned as a result:
Figure 4: Returned string concatenation
IMPORTANT: When using special symbols like an apostrophe in an expression, you have to use an escaping character (backslash) before the symbol:
Escaping character Example
Figure 5: Creating a string concatenation with an escaping character
Figure 6: Returned string concatenation using an apostrophe
The query that will demonstrate string concatenation in action is built on the relationship ‘infer’. The query outcome will demonstrate a string concatenation that uses an escaping character. Click below to export the .rbird file for the ‘what car do I have’ example.
Version 1.01 – Last Update: 23/02/2021