about summary refs log tree commit diff
path: root/dump
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-07-18 16:09:17 +0300
committerMunyoki Kilyungi2023-07-21 14:36:39 +0300
commit96757772a9a7b2b5e368d3d16ffbd09f3e95719a (patch)
tree8722ad7291763248b942c65ad878762ac0c5a0cc /dump
parente209abefb3816a0a26ea04a27a55a23c26b1b1cc (diff)
downloadgn-transform-databases-96757772a9a7b2b5e368d3d16ffbd09f3e95719a.tar.gz
Make string->identifier take optional keyword args
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'dump')
-rw-r--r--dump/triples.scm24
1 files changed, 16 insertions, 8 deletions
diff --git a/dump/triples.scm b/dump/triples.scm
index 33b4ae3..2b43d68 100644
--- a/dump/triples.scm
+++ b/dump/triples.scm
@@ -21,19 +21,27 @@
         (string->symbol
          (format #f "~s~a" string-field schema)))))
 
-(define (string->identifier prefix str)
+(define* (string->identifier prefix str
+                             #:optional #:key
+                             (ontology "gn:")
+                             (separator "_")
+                             (proc string-downcase))
   "Convert STR to a turtle identifier after replacing illegal
 characters with an underscore and prefixing with gn:PREFIX."
   (if (string-null? str)
       ""
       (string->symbol
-       (string-append "gn:" prefix "_"
-                      (string-map (lambda (c)
-                                    (case c
-                                      ((#\/ #\< #\> #\+ #\( #\) #\space #\@) #\_)
-                                      (else c)))
-                                  (string-downcase
-                                   (string-trim-right str #\.)))))))
+       (string-append ontology prefix separator
+                      (string-delete
+                       (lambda (c)
+                         (eq? c #\)))
+                       (string-map (lambda (c)
+                                     (case c
+                                       ((#\/ #\< #\> #\+ #\( #\space #\@) #\_)
+                                       (else c)))
+                                   (proc
+                                    (string-trim-right str #\.))))))))
+
 
 (define* (prefix prefix iri #:optional (ttl? #t))
   (format #t