Previous topic  Top  Next topic  Print this Topic
 

Annotations

 

The two main goals of annotations are:

to define rule and query Ids and
to specify query options.

 

Rules, queries and constraints can have an Id, which is used in the annotation syntax.

The syntax is the following:

@{ID, frame, options[…],…} body.

ID represents the rule/query/constraint label,
frame represents the metadata associated with the rule/query/constraint to which the annotation is attached,
options[…] controls the output of a query; the different possible options are:
sort(asc(?X),desc(?Y),...): sort the output of a query in the ascending order of bindings for ?X, descending order of bindings for ?Y, etc.
outorder(?Y,?X): the output of a query should be a set of tuples (?Y,?X), i.e. the bindings for ?Y go first,
maxnumber(NUMBER): specifies that only (at most) the first NUMBER of answers needs to be computed.
timeout(NUMBER): stop the computation after this NUMBER of seconds.
body is a rule, a query or a constraint.

Example of an annotation for a query:

@{ID1,

 ID1[author -> “John”, date ->"2009-10-12"^^_dateTime],

 options[sort(desc(?Name)), maxnumber(2)]}

?- ?:person[name -> ?Name, age -> ?Age].

 

The query identifier is “ID1”, its author is “John” and it was created on the 12th of October 2009. The results will be sorted in the descending order by the attribute “name” of the class “person” and the returned result will be restricted to the first two results.