aboutsummaryrefslogtreecommitdiff
path: root/dump
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-03-27 22:54:44 +0300
committerBonfaceKilz2023-04-05 16:17:11 +0300
commit98865301aebfe704dbaa4cb0790972c019c798ca (patch)
tree6da2d4ddbcf03989115a17fca2a8f1ead72215fe /dump
parente7aafff4225965effcf7415d31c558a78b7c0cca (diff)
downloadgn-transform-databases-98865301aebfe704dbaa4cb0790972c019c798ca.tar.gz
Use match syntax to print object correctly during dump
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'dump')
-rw-r--r--dump/triples.scm21
1 files changed, 11 insertions, 10 deletions
diff --git a/dump/triples.scm b/dump/triples.scm
index 6ccf137..1f2ab87 100644
--- a/dump/triples.scm
+++ b/dump/triples.scm
@@ -1,4 +1,5 @@
(define-module (dump triples)
+ #:use-module (ice-9 regex)
#:use-module (ice-9 match)
#:use-module (dump utils)
#:export (ontology
@@ -40,16 +41,16 @@ characters with an underscore and prefixing with gn:PREFIX."
(number? object))
(error "Triple object not a string, symbol or number:"
(list subject predicate object)))
- (let ([format-string
- (if (symbol? object)
- "~a ~a ~a .~%" "~a ~a ~s .~%")]
- [object
- (if (and (symbol? object)
- (string-contains (symbol->string object)
- "\""))
- (symbol->string object)
- object)])
- (format #t format-string subject predicate object)))
+ (match object
+ ((and (? string? object)
+ (? (lambda (el) (string-match "^\\[ .* \\]$" object))))
+ (format #t "~a ~a ~a .~%" subject predicate object))
+ ((? symbol? object)
+ (format #t "~a ~a ~a .~%" subject predicate object))
+ ((or (? string? object)
+ (? number? object))
+ (format #t "~a ~a ~s .~%" subject predicate object))
+ (_ (error "Trible object must be a string, symbol, number or blank node"))))
(define (scm->triples alist id)
(for-each (match-lambda