aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-03-16 18:40:19 +0300
committerBonfaceKilz2023-04-05 16:17:11 +0300
commit6aebd73eeeef944e555fec225c529c7674d7336d (patch)
tree372bf029dc2e44df7e87401397b1f76c37156283
parentbe42b42be2a87a9872c153a9b6f3da7ed135efa1 (diff)
downloadgn-transform-databases-6aebd73eeeef944e555fec225c529c7674d7336d.tar.gz
Annotate fields with a custom scheme such as "^^xsd:datetime"
* dump.scm (annotate-field): New function. * dump/triples.scm (triple): Print a string as they appear with DISPLAY should they contain "\"" thus enabling a triple that looks like: gn:species_mus_musculus gn:name "Mouse"^^xsd:string Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rwxr-xr-xdump.scm9
-rw-r--r--dump/triples.scm11
2 files changed, 19 insertions, 1 deletions
diff --git a/dump.scm b/dump.scm
index 9650de5..01376b2 100755
--- a/dump.scm
+++ b/dump.scm
@@ -89,6 +89,15 @@
;;; Dump tables
+(define (annotate-field field schema)
+ (let ([schema (cond ((symbol? schema)
+ (symbol->string schema))
+ ((string? schema) schema)
+ (else
+ (error "Use a string/symbol")))])
+ (string->symbol
+ (format #f "~s~a" field schema))))
+
(define (delete-substrings str . substrings)
"Delete SUBSTRINGS, a list of strings, from STR."
(fold (lambda (substring result)
diff --git a/dump/triples.scm b/dump/triples.scm
index 1509ded..6ccf137 100644
--- a/dump/triples.scm
+++ b/dump/triples.scm
@@ -40,7 +40,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)))
- (format #t "~a ~a ~s .~%" 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)))
(define (scm->triples alist id)
(for-each (match-lambda