diff options
| author | Munyoki Kilyungi | 2025-12-23 14:14:51 +0300 |
|---|---|---|
| committer | Munyoki Kilyungi | 2026-01-13 12:02:50 +0300 |
| commit | f96056e48c83cb5d083bdb59dd5d11306bb5ac31 (patch) | |
| tree | 395e40de538554be40f87915c8c18e9e427323a4 /transform | |
| parent | 25f1f56a3ab2e76895dfb0268530fc6de291fc98 (diff) | |
| download | gn-transform-databases-f96056e48c83cb5d083bdb59dd5d11306bb5ac31.tar.gz | |
Use "-" in qnames.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'transform')
| -rw-r--r-- | transform/triples.scm | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/transform/triples.scm b/transform/triples.scm index f2dbcf7..55edf8a 100644 --- a/transform/triples.scm +++ b/transform/triples.scm @@ -35,27 +35,31 @@ (format #f "~s~a" string-field schema))))) (define* (string->identifier - prefix str - #:optional #:key - (ontology "gn:") - (separator "") - (proc string-capitalize-first)) + prefix str + #:optional #:key + (ontology "gn:") + (separator "") + (proc string-capitalize-first)) "Convert STR to a turtle identifier after replacing illegal characters with an underscore and prefixing with gn:PREFIX." (if (or (and (string? str) (string-null? str)) - (eq? str #f)) + (eq? str #f)) "" (string->symbol (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 #\.)))))))) + (string-delete + (lambda (c) + (eq? c #\))) + (string-map (lambda (c) + (case c + ((#\/ #\< #\> #\+ #\( #\space #\@) #\-) + (else c))) + (proc + (string-trim-right + (regexp-substitute/global + #f "_" + str + 'pre "-" 'post) #\.)))))))) (define* (prefix prefix iri #:optional (ttl? #t)) |
