r13 - 19 Oct 2005 - 17:14:55 - JohnNiekraszYou are here:  Calo Web > MoKb > MokbGrammar

MOKB OAA Message Grammar

Examples

The following examples demonstrate the use of the MOKB oaa syntax for updates and queries. They do not necessarily conform to any semantic ontology, nor do they go together, but their syntax is correct. To see examples that specifically use the CALO ontology and which come from CALO use, visit MokbOntologyUsageExamples.

Here are some special notes to remember:

  • Queries use the angled brackets, while updates do not
  • Usage for literal dataypes like stings and integers is different between updates and queries:
    • In updates, the syntax incorporates the # character, with the datatype listed first (<nspace:type#value>)
    • In the query, the n-triple syntax for literals is used in the triples, and the raw string should be used in the comparison (AND) clause: ("value"^^<nspace:type>)
  • All other objects (i.e. not literals) should be in the calo namespace (there is one exception below), so use <tdo:xxx> to name classes and properties in the ontology, or any instances in the database created by you or someone else

An update

This update creates instances of some classes and asserts some relations between them, as well as asserting some literal datatype values for the time-begins and time-ends slots.

mokb_update(['tdo:speechalizer00412',
             'xsd:dateTime#2001-10-26T21:32:52.126',
             [['tdo:id-1',
               'rdf:type',
               [['tdo:Transmit','xsd:float#1.0']]],
              ['tdo:id-2',
               'rdf:type',
               [['tdo:Time-Interval','xsd:float#1.0']]],
              ['tdo:id-1',
               'tdo:time-during',
               [['tdo:id-2','xsd:float#1.0']]],
              ['tdo:id-2',
               'tdo:time-begins',
               [['xsd:dateTime#2001-10-26T21:32:52.129','xsd:float#1.0']]],
              ['tdo:id-2',
               'tdo:time-ends',
               [['xsd:dateTime#2001-10-26T21:45:00.000','xsd:float#1.0']]]]])

A query without reasoning

Note the difference between the functor here and in the next example:

mokb_query('
SELECT ?convey
WHERE
(?convey <tdo:subevent> ?speak )
USING tdo FOR <http://calo.sri.com/core-plus-office#>
')

A query with reasoning

mokb_reasoned_query('
SELECT ?event
WHERE
(?event <tdo:time-during> ?ival )
(?ival <tdo:time-begins> "2005-01-21T10:32:08.714"^^<xsd:dateTime>)
USING tdo FOR <http://calo.sri.com/core-plus-office#>
')

A query which does string-wise comparison of dates

mokb_query('
SELECT ?x
WHERE
(?x <tdo:time-begins> ?y)
(?x <tdo:time-ends> ?z)
AND ?y < ?z
USING tdo FOR <http://calo.sri.com/core-plus-office#>
')

Useful URIs

These are special URI's that are not in the ontology that you will need to use when making assertions and queries:

rdf:type the property which assigns an instance to a class
rdfs:subClassOf the property which says one class is a subclass of another

More about XML syntax, XSD datatypes, and URIs

In the n-triple syntax, uri's are surrounded by angled brackets, with a namespace and value separated by a colon inside. For xml literals, you will need to specify the type, which appears after the colon and has a # sign after it. Refer to the XML Schema specification to see what types you can use.

Using times and dates

Notice that all times should be of the xsd:dateTime type. They should be in the following string format:

yyyy-mm-ddThh:mm:ss.sss

For example, in an update you might say:

      [   'tdo:interval-1',
         'tdo:time-ends',
         [   [   'xsd:dateTime#2005-01-21T10:32:08.714',
               'xsd:float#1.0']]]]])

In a query, you might see this:

mokb_query('
SELECT ?x
WHERE
(?x <tdo:time-begins> ?y)
AND ?y < "2005-01-21T10:32:08.714"
USING tdo FOR <http://calo.sri.com/core-plus-office#>
')

RDQL

RDQL is the query language used by MOKB. The queries are piped directly without modification to the Jena RDQL query API. Therefore, one should refer directly to the Jena RDQL documentation for information on how to construct queries for MOKB. One thing to note is that RDQL requires that angled brackets be used for urls (though namespace prefixes are still allowable). Also, you need to use the N3 syntax for datatype literals: ("val"^^<xsd:type&rt;).

Grammar

The following is the grammar for OAA messages accepted by the MOKB servers. The characters * ' { } | " are non-literal metacharacters with the following special functions in the gramamr:

" characters surrounded by quotes are to be considered as literals
* the asterisk signifies an oaa list expansion, e.g. RULE* expands to RULE, RULE, RULE, ...
| the bar character signifies an either-or choice of the surrounding elements
{ } the curly braces signify an optional parts of the expansion
' characters surrounded by the single-quote should simply be grouped for use in either-or expansion

All other characters in the grammar should be treated as literals, except for the all-caps rule names.

MOKB_QUERY                  := mokb_query(RDQL_QUERY)
MOKB_UPDATE                 := mokb_update([CLIENT_ID,TIME,[PROB_TRIPLE*]])
MOKB_REMOVE                 := mokb_remove(CLIENT_ID,TIME_OF_ASSERTION,TRIPLE*)
MOKB_REGISTER               := mokb_register(CLIENT_ID,CLIENT_CLASS,QUERY_TRIPLE_TEMPLATE_LIST,UPDATE_TRIPLE_TEMPLATE_LIST,TIME)
QUERY_TRIPLE_TEMPLATE_LIST  := TRIPLE_TEMPLATE*
UPDATE_TRIPLE_TEMPLATE_LIST := TRIPLE_TEMPLATE*
QUERY_CHAIN                 := ['SUBJECT'|'?','PREDICATE'|'?'*,'OBJECT'|'?']
TRIPLE_TEMPLATE             := ['SUBJECT'|'?','PREDICATE'|'?','OBJECT'|'?']
TRIPLE                      := [SUBJECT,PREDICATE,OBJECT]
PROB_TRIPLE                 := [SUBJECT,PREDICATE,[OBJECT-PROBS*]]
OBJECT_PROBS                := [OBJECT,PROB]
CLIENT_CLASS                := URI
SUBJECT                     := URI
PREDICATE                   := URI
OBJECT                      := URI
CLIENT_ID                   := URI

The following terminal rules have the syntax described:

RDQL_QUERY this should be an RDQL query, surrounded by single quotes...see the RDQL documentation
PROB an xsd float string, surrounded by single-quotes: e.g. 'xsd:float#0.3'
TIME an xsd dataTime string, surrounded by single-quotes: e.g. 'xsd:dateTime#2001-10-26T21:32:52.12679'
URI a URI reference, as it would be encoded in N-Triple form (see uriref in the n-triple grammar)

Note on Off-line Processing

Typically, the time will just be the current time, but it can also serve an important purpose for CALO off-line processing. For off-line processing, the time should be the time that the agent would have asserted the assertion has the process been run online, using the initial grounding world-time sent to the agent as a reference for when it would have started.

Calo.MokbGrammar moved from Calo.MokbAgentSuite on 03 Nov 2004 - 18:09 by JohnNiekrasz - put it back
 

Semlab Home      
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Semlab? Send feedback