From 96757772a9a7b2b5e368d3d16ffbd09f3e95719a Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 18 Jul 2023 16:09:17 +0300 Subject: Make string->identifier take optional keyword args Signed-off-by: Munyoki Kilyungi --- dump/triples.scm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'dump') 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 -- cgit v1.2.3