diff options
Diffstat (limited to 'transform')
| -rw-r--r-- | transform/special-forms.scm | 53 |
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)))) |
