Define rules for AllegroGraph triples and how to apply them

I use AllegroGraph to store instructions as follows:

<newsid1  hasAnnotation  Gamma>
<newsid1  hasAnnotation Beta>

I would like to define a rule on these lines that states: if the subject is newsid1 hasAnnotationeither Gamma, or Beta, add a new expression to the tripestor, which says that the subject hasAnnotation Theta, i.e. expression

<newsid1  hasAnnotation Theta>

My questions are as follows:

  • How can I define such a rule for Allegro?
  • How can I apply these rules to operators?
+5
source share
1 answer

1) You can define prolog functions to define these rules. In your case, you determine.

;; 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) ( AGview ),

(select (?news)
(shouldHaveAnnotationTheta ?news)
(a-- ?news !namespace:hasAnnotation !"Theta")
(fail))

, :

+4

All Articles