I'm using AllegroGraph to store statement like this:
<newsid1 hasAnnotation Gamma>
<newsid1 hasAnnotation Beta>
I would like to define a rule on this staments that says: if the subject newsid1 hasAnnotation
either Gamma
or Beta
, then add a new statement in the triplestore that says that the subject hasAnnotation Theta
, i.e. the statement
<newsid1 hasAnnotation Theta>
My questions are the following:
1) You can define use Prolog functors to define these rules. In your case you will define.
;; Functors to add triples.
(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lispp (not (get-triple :s ?s :p ?p :o ?o)))
(lisp (add-triple ?s ?p ?o)))
;; Functors to seek news that should have theta annotation
(<-- (shouldHaveAnnotationTheta ?news)
(q- ?news !namespace:hasAnnotation !"Gamma"))
(<- (shouldHaveAnnotationTheta ?news)
(q- ?news !namespace:hasAnnotation !"Beta"))
2) Run then the following prolog query (using the AGview for exemple) to add these news statements
(select (?news)
(shouldHaveAnnotationTheta ?news)
(a-- ?news !namespace:hasAnnotation !"Theta")
(fail))
You can read the following documents to understand this code :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With