Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:defining_computables [2014/11/26 20:48] – [Caveats] admin | doc:defining_computables [2014/11/26 21:00] (current) – [SQL computables] admin | ||
---|---|---|---|
Line 29: | Line 29: | ||
</ | </ | ||
The // | The // | ||
- | |||
- | ===== Debugging ===== | ||
- | |||
- | When something does not work, check the following. Most likely, there is a minor inconsistency in the OWL names that makes the whole process break. | ||
- | * is the right property being computed? knowrob: | ||
- | * is there a typo anywhere in the namespaces or base URLs? | ||
- | * check if there is a hash sign # between the URL and the property name (if using XML entities, check if the hash is either part of the entity or written where the entity is being used in the code) | ||
- | * debug with the following calls and step through to check that the right computable is being found, that the right query is sent, or that your predicate performs the right computations. | ||
- | < | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | |||
- | Some general remarks: | ||
- | * Computables should be defined in their own module; the computables for temporal relations (before, after, during etc), for example, are defined in the module // | ||
- | * The &bla; identifiers are XML entities that are replaced with the string specified at the beginning of the file when the file is being loaded. They are useful for making the code a bit shorter and more readable, and also for ensuring consistency. | ||
===== Prolog computables ===== | ===== Prolog computables ===== | ||
- | * Prolog computables, which evaluate a binary Prolog predicate that computes an OWL relation | + | Prolog computables computes an OWL relation |
- | ===== Prolog properties | + | ==== Prolog properties ==== |
- | For Prolog properties, we will have a look at the knowrob: | + | For Prolog properties, we will have a look at the knowrob: |
- | < | + | < |
< | < | ||
< | < | ||
Line 65: | Line 48: | ||
</ | </ | ||
- | Then, the computable that is attached to this property needs to be specified: | + | Then, the property |
- | < | + | < |
< | < | ||
+ | < | ||
< | < | ||
- | | + | |
- | < | + | |
- | < | + | |
</ | </ | ||
</ | </ | ||
- | Note that the target is described as in SQL properties, but instead of covering the different cases of bound/free variables with different SQL queries, we only specify one Prolog predicate (comp_after) that is supposed to handle | + | Note that the target is described as a binary |
- | < | + | < |
% after(TimePoint, | % after(TimePoint, | ||
comp_after(Pre, | comp_after(Pre, | ||
Line 86: | Line 68: | ||
</ | </ | ||
- | This predicate first checks if the subject and property have the correct types, then transforms the time points into numerical values using term_to_atom, | + | This predicate first checks if the subject and property have the correct types, then transforms the time points into numerical values using //term_to_atom//, and finally compares them to check if //Pre// is smaller |
- | * Prolog computables can do much more than just compare | + | * Prolog computables can do more than comparing |
* When trying to use rdf_assert inside a Prolog computable, you are likely to get an error " | * When trying to use rdf_assert inside a Prolog computable, you are likely to get an error " | ||
- | ===== Prolog classes | + | ==== Prolog classes ==== |
- | The definition of computable prolog classes is similar to the preceding ones, you simply need to describe the class (here: DrinkingMug) and a binary predicate (here: comp_objectsOnTable(Inst, | + | The definition of computable prolog classes is similar to Prolog properties. You simply need to describe the class (here: DrinkingMug) and a binary predicate (here: comp_objectsOnTable(Inst, |
- | < | + | < |
< | < | ||
< | < | ||
Line 103: | Line 85: | ||
- | ====== SQL computables ====== | + | ===== SQL computables ===== |
- | SQL computables, | + | |
+ | SQL computables used SQL queries for reading external data. They are currently deactivated, | ||
- | ===== SQL properties | + | ==== SQL properties ==== |
As mentioned before, the first step is to define the target to be computed. In this example, which can be found in ias_gram_human.owl, | As mentioned before, the first step is to define the target to be computed. In this example, which can be found in ias_gram_human.owl, | ||
Line 149: | Line 131: | ||
</ | </ | ||
- | ===== SQL classes | + | ==== SQL classes ==== |
The definition of computable SQL classes is rather similar to properties and will only be shortly explained. Obviously, the target class has to exist for the method to work. computeReaching reads human motion frames labeled as ' | The definition of computable SQL classes is rather similar to properties and will only be shortly explained. Obviously, the target class has to exist for the method to work. computeReaching reads human motion frames labeled as ' | ||
Line 169: | Line 151: | ||
</ | </ | ||
Here, we do not have the frame/value scheme, but rather one command for creating instances (command) and one for checking if an instance belongs to the respective class (testCommand). | Here, we do not have the frame/value scheme, but rather one command for creating instances (command) and one for checking if an instance belongs to the respective class (testCommand). | ||
+ | |||
+ | |||
+ | ===== Debugging ===== | ||
+ | |||
+ | When something does not work, check the following. Most likely, there is a minor inconsistency in the OWL names that makes the whole process break. | ||
+ | * is the right property being computed? knowrob: | ||
+ | * is there a typo anywhere in the namespaces or base URLs? | ||
+ | * check if there is a hash sign # between the URL and the property name (if using XML entities, check if the hash is either part of the entity or written where the entity is being used in the code) | ||
+ | * debug with the following calls and step through to check that the right computable is being found, that the right query is sent, or that your predicate performs the right computations. | ||
+ | < | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | Some general remarks: | ||
+ | * Computables should be defined in their own module; the computables for temporal relations (before, after, during etc), for example, are defined in the module // | ||
+ | * The &bla; identifiers are XML entities that are replaced with the string specified at the beginning of the file when the file is being loaded. They are useful for making the code a bit shorter and more readable, and also for ensuring consistency. | ||
+ | |||