Example R-DEVICE Queries

 

Taken from the RDF Query and Rule languages Use Cases and Examples survey

 

(deductiverule q1a

  ?x <- (? (email:message-id '123456@example.com'))

  =>

  (result (email ?x))

)

 

(deductiverule q1b

  ?msg <- (pop3:Message (pop3:property ?prop))

  ?prop <- (? (rdfs:label 'From') (rdf:value ?from))

  (test (str-index "hotmail" ?from))

  =>

  (result (email ?msg))

)

 

(deductiverule q2

  ?x <- (? (vcard:N ?y))

  ?y <- (? (vcard:Family "Smith") (vcard:Given ?v))

  =>

  (person (name ?v))

)

 

(deductiverule q3

  data:x <- (? (?property ?value))

  ?property <- (rdf:Property (rdfs:range $? ?t $?))

  =>

  (result (property ?property) (value ?value)(type ?t))

)

 

(deductiverule q4

  ?Header <- (hdr:HeaderField (hdr:fieldName ?name) (rdfs:label ?purpose) (hdr:protocol ?p))

  ?p <- (? (hdr:protocolName ?pn) (hdr:spec ?ps))

  ?ps <- (? (hdr:document ?psdocument))

  =>

  (result (header ?Header) (name ?name) (protocol ?p) (purpose ?purpose) (pname ?pn) (spec ?ps) (document ?psdocument))

)

 

(deductiverule q5

  (rss:item (rss:title ?title) (rss:link ?link))

  =>

  (result (title ?title) (link ?link))

)

 

(deductiverule q6

  (rss:item (rss:title ?title) (rss:link ?link))

  (test (str-index "RDQL" ?title))

  =>

  (result (link ?link))

)

 

(deductiverule q7

  ?x <- (? (dc:title ?tt) (dc:description ?dd) ((etbthes:ETBT dc:subject) ?ss2) (dc:identifier ?identifier)

           ((dcq:RFC1766 dc:language) ?language))

  ?tt <- (? (rdf:value ?t_val) ((dcq:RFC1766 dc:language) ?t_lang))

  ?ss2 <- (? (rdf:value ?subject_val) ((dcq:RFC1766 dc:language) ?subj_lang))

  ?dd <- (? (rdf:value ?desc_val) ((dcq:RFC1766 dc:language) ?desc_lang))

  =>

  (result (title_value ?t_val) (title_language ?t_lang) (subj_val ?subject_val) (subj_lang ?subj_lang)

        (desc_value ?desc_val) (desc_lang ?desc_lang) (language ?language)(identifier ?identifier))

)