ALKnowledge¶
NAOqi Core - Overview | API | Tutorials
What it does¶
ALKnowledge service allows you to manage persistent data in the form of triples. The goal is to build and use an ontology (a set of triples) representing the knowledge of the robot. The ontology is shared within the robot which means that you can access, use and modify the data set by other applications (which can do the same with your data) if you have access to the Domain of these data.
This formalism used for instance by dbpedia is used to describe relation between concepts within a domain.
How it works¶
Triple¶
A triple is the basic structure of this service. A triple is represented as:
subject - predicate - object
Where the subject, the predicate and the object can be anything which can be converted to a string.
In a triple, the predicate represents the relation between the subject and the object which are unique within the ontology.
Here are some examples:
- sky (subject) - colour (predicate) - blue (object)
- user_42 (subject) - type (predicate) - person (object)
- user_42 (subject) - name (predicate) - Paul (object)
It means that “user_42” can be considered as an entity of type “person” which has the name “Paul”.
Domain¶
The domain allows you to use several sets of triples for specific contexts. You can think of domain as a subgraph of a big graph. When using knowledge API, you have to precise a domain so the method (add, query, etc) will apply to the corresponding subgraph.
Note that for now, metadatas features and API are only available for the Domain com.aldebaran.learning.
Metadata¶
Metadatas are data which are directly linked to a triple.
By default, 2 metadatas are added to each triple.
You can also add your own metadatas.
Default Metadatas¶
Name | Value |
---|---|
addedDate | timestamp of when the triple has been added in the format yyyy-MM-ddThh:mm:ssZ |
addingCount | number of time this triple has been added |
Adding, deleting triples¶
- When a triple is added, its subject, predicate and object are linked to the same unique node with an ID which is the triple ID. This node will be the subject of all metadatas triples (ID-metadataName-metadataValue).
- When a triple is deleted, the metadatas linked to it are not deleted because they can still be relevant, if they are not, you should delete the metadatas explicitly.
For instance the default metadata addedDate can be used to have an history of what happened because it will not be deleted if the base triple is not deleted. So you can know when a triple has been added and how many times even if the triple is not there anymore:
add("com.aldebaran.learning", "bob", "eat", "pizza")
remove("com.aldebaran.learning", "bob", "eat", "pizza")
add("com.aldebaran.learning", "bob", "eat", "salad")
remove("com.aldebaran.learning", "bob", "eat", "salad")
add("com.aldebaran.learning", "bob", "eat", "pizza")
remove("com.aldebaran.learning", "bob", "eat", "pizza")
query("com.aldebaran.learning", "bob", "eat", "?") -> ""
queryMetadata("com.aldebaran.learning", "bob", "eat", "pizza", addedTime) -> "2"