about summary refs log tree commit diff
path: root/transform/special-forms.scm
diff options
context:
space:
mode:
authorMunyoki Kilyungi2026-02-09 14:49:54 +0300
committerMunyoki Kilyungi2026-02-09 14:49:54 +0300
commit99d31d2be7bfc2e900db8fbd2c835ef7931360ba (patch)
tree19136398ef6c58afeee234de20321c3e93b7030c /transform/special-forms.scm
parent9805ce49a8b577204931ed736e082a862e0ac05e (diff)
downloadgn-transform-databases-99d31d2be7bfc2e900db8fbd2c835ef7931360ba.tar.gz
Don't create triple when string is blank. HEAD master
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'transform/special-forms.scm')
-rw-r--r--transform/special-forms.scm53
1 files changed, 31 insertions, 22 deletions
diff --git a/transform/special-forms.scm b/transform/special-forms.scm
index 8de4966..35dc2f3 100644
--- a/transform/special-forms.scm
+++ b/transform/special-forms.scm
@@ -6,6 +6,7 @@
   #:use-module (transform sql)
   #:use-module (transform table)
   #:use-module (transform triples)
+  #:use-module (transform strings)
   #:export (translate-forms
             collect-forms
             collect-keys
@@ -25,29 +26,37 @@
 (define (emit-short-turtle subject po-alist)
   (let loop ((pairs po-alist) (first? #t))
     (match pairs
+      ;; Skip pairs with blank string objects
       (((p . o) rest ...)
-       ;; subject only on first line
-       (when first?
-         (format #t "~a " subject))
-       (when (not first?)
-         (format #t "\t"))   ; indent following lines
-
-       (match o
-         ((? symbol?)
-          (format #t "~a ~a" p (symbol->string o)))
-         ((or (? (lambda (el) (and (string? el)
-                                   (string-match "^\\(.*\\)$" el))))
-              (? (lambda (el) (and (string? el)
-                                   (string-match "^\\[.*\\]$" el)))))
-          (format #t "~a ~s" p o))
-         (_
-          (format #t "~a \"~a\"" p o)))
-
-       (if (null? rest)
-           (format #t " .~%")   ; last triple
-           (format #t " ;~%"))  ; continuation
-
-       (loop rest #f))
+       (if (and (string? o) (string-blank? o))
+           (loop rest first?)     ; ← skip entirely
+           (begin
+             ;; subject only on first emitted line
+             (when first?
+               (format #t "~a " subject))
+             (when (not first?)
+               (format #t "\t"))  ; indent following lines
+
+             ;; emit predicate–object
+             (match o
+               ((? symbol?)
+                (format #t "~a ~a" p (symbol->string o)))
+               ((or (? (lambda (el)
+                          (and (string? el)
+                               (string-match "^\\(.*\\)$" el))))
+                    (? (lambda (el)
+                          (and (string? el)
+                               (string-match "^\\[.*\\]$" el)))))
+                (format #t "~a ~s" p o))
+               (_
+                (format #t "~a \"~a\"" p o)))
+
+             ;; separator
+             (if (null? rest)
+                 (format #t " .~%")
+                 (format #t " ;~%"))
+
+             (loop rest #f))))
 
       (() #f))))