summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2020-09-07 12:14:24 +0200
committerpukkamustard <pukkamustard@posteo.net>2020-09-07 12:14:24 +0200
commit141b00c1267953860ef20b89ce524967d08af681 (patch)
treed95d56e3c3b53f35039962734123498dd700a517
parente65ac1caf77e8ef6ca63ab0f67efb6e2884e8196 (diff)
(schemantic rdf): add generic graph-add method that unpacks triple
-rw-r--r--schemantic/graph/vhash.scm10
-rw-r--r--schemantic/rdf.scm7
2 files changed, 12 insertions, 5 deletions
diff --git a/schemantic/graph/vhash.scm b/schemantic/graph/vhash.scm
index 8935029..a24b6f6 100644
--- a/schemantic/graph/vhash.scm
+++ b/schemantic/graph/vhash.scm
@@ -25,14 +25,14 @@
(define (make-vhash-graph)
(make <vhash-graph>))
-(define-method (graph-add (g <vhash-graph>) (t <triple>))
- (let ((s (triple-subject t))
- (p (triple-predicate t))
- (o (triple-object t)))
+(define-method (graph-add (g <vhash-graph>)
+ (s <term>)
+ (p <term>)
+ (o <term>))
;; add to spo index
(set! (spo g) (index-add (spo g) (list s p o)))
;; return graph to allow chaining of multiple adds
- g))
+ g)
(define-method (graph-match (g <vhash-graph>) (s <term>) (p <term>) (o <term>))
(map (match-lambda ((s p o) (make-triple s p o))) ; transform result when querying the index to a triple
diff --git a/schemantic/rdf.scm b/schemantic/rdf.scm
index 5253572..6fe3c9c 100644
--- a/schemantic/rdf.scm
+++ b/schemantic/rdf.scm
@@ -107,6 +107,13 @@
(is-a? x <graph>))
(define-generic graph-add)
+
+(define-method (graph-add (g <graph>) (t <triple>))
+ (let ((s (triple-subject t))
+ (p (triple-predicate t))
+ (o (triple-object t)))
+ (graph-add g s p o)))
+
(define-generic graph-match)
(define-method (graph-radd (g <graph>))