Structural – Building with Number Concepts
Building with Number Concepts
To solve a query, Rainbird may need to use numbers and/or dates. However, number and date concepts can not have relationships that point away from them. For Rainbird to accurately infer an answer which may require number or date concept instances to be selected/created by the user at run-time, string concepts, that refer to possible number/date concept instances, can be used. String concepts that refer to number/date concepts will be built using expressions.
To demonstrate how Rainbird can use string concept instances that refer to number/date concept instances, this article will explain how to build a map that will show what actions a person is ‘allowed to do’, by sorting ‘age’ number concept instances into ‘age bracket’ string concept instances.
First, we start building the map by creating the string concepts ‘Person’ and ‘Action’, as well as the number concept ‘Age’. The concepts are connected with relationships, as shown in figure below:
Figure 1: Creating the map’s Concepts and Relationships
Once the concepts have been created, we need to create concept instances for the concept ‘Action’. The concept instances will be ‘actions’ that a user may or may not be able to perform, based on their age:
Figure 2: Creating ‘action’ concept instances
In order to solve the query, Rainbird needs to know what age someone is and whether someone of that age can complete an action. As we cannot create facts between the number concept ‘age’ and the string concept ‘action’, we need to create a string concept, ‘age bracket’.
The ‘person’ concept is linked to the ‘age bracket’ concept with a relationship called ‘fits into age bracket’, and ‘age bracket’ is linked to ‘action’ with a relationship called ‘allowed to do’. The ‘allowed to do’ concept is set to plural, as a user may be able to perform multiple actions, dependent on their age.
Figure 3: Building the age bracket concept and connecting it to the existing concepts
Note – for guidance on how to build simple maps, please consult the ‘Build in Triangles‘ articles
Now we need to create ‘Age Brackets’ concept instances, which will be the different age groups that Rainbird will be sorting ages into: ‘Teen’, ‘Young Adult’, and ‘Adult’.
Once the ‘age bracket’ concept instances have been created, facts (relationship instances) can be created by linking appropriate ‘age bracket’ concept instances with the appropriate ‘action’ concept instances on the ‘allowed to do’ relationship:
Figure 4: Creating facts (relationship instances)
Now, Rainbird will know which actions can be performed by which age group.
Next, we need to build a rule on the relationship ‘can do action based on age bracket‘, which will tell Rainbird that:
A Person ‘can do action based on age bracket’ Action.
WHEN A Person ‘fits into age bracket’ Age Bracket
AND Age Bracket is ‘allowed to do’ Action
Figure 5: Creating the rule for the ‘can do action based on age’ relationship
Before continuing with the map build it is best practice to create a query based on this new rule in order to test it.
Rainbird will need to ask for the age of the user and then check whether an inputted ‘age’ number fits into an ‘age bracket’ concept instance.
To sort inputted ages into ‘age brackets’, comparative expressions on the ‘fits into age bracket’ will need to be created . Numbers concepts (like ‘Age’ in our example) can be used with mathematical function inside expressions. The map uses three different age brackets, so three object-specific rules will have to be created, one each for ‘Teen’, ‘Young Adult’ and ‘Adult’:
Figure 6: Rule and comparative expression that will sort an age into the ‘Teen’ age bracket concept instance
Figure 7: Rule and comparative expression that will sort an age into the ‘Young Adult’ age bracket concept instance
Figure 8: Rule and comparative expression that will sort an age into the ‘Adult’ age bracket concept instance
Now, our ‘fits into age bracket’ relationship will have three rules that sit underneath it:
Once Rainbird has sorted a person into an ‘age bracket’, Rainbird can use the rules of the knowledge map to infer which ‘action’ a ‘person’ can do.
To make sure Rainbird asks the ‘has age’ question correctly, we need change the question wording of the second form Question (Object) on the ‘has age’ relationship to ‘What is the age of the Person?:
Figure 9: Changing the Question Wording on the ‘has age’ relationship
Finally, we set the ‘question configuration‘ on all the other relationships to ‘off‘:
Figure 10: Setting the ‘question configuration’ to ‘none’ stops Rainbird asking questions about the selected relationship
Now, we can re-run our query.
The RBLang below will generate the example ‘age bracket’ map that was built in the article. Click on ‘Export .rbird’ to download the knowledge map, or ‘copy RBLang’ and paste the code directly into Rainbird.
Query and Results
You will need to run the query on the relationship “can do based on age bracket” for an example of a query that sorts a number concept into a string concept in order to reach an outcome.
Version 1.01 – Last Update: 26/02/2021