aboutsummaryrefslogtreecommitdiff
path: root/dump
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-07-26 13:32:16 +0300
committerBonfaceKilz2023-07-30 12:29:56 +0300
commitddf6bd5b1016df4a4d8d4727852a7ed80cc90407 (patch)
tree40dcd9c1dc2dd7b39ba325414ec38ff56851e1c9 /dump
parentb9a322a1e37c3e535b6e7bbe718d06ba0da85952 (diff)
downloadgn-transform-databases-ddf6bd5b1016df4a4d8d4727852a7ed80cc90407.tar.gz
Add new method "string->binomial-name"
* dump/triples.scm: Export string->binomial-name. (string->binomial-name): New procedure. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'dump')
-rw-r--r--dump/triples.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/dump/triples.scm b/dump/triples.scm
index 2b43d68..0206ba3 100644
--- a/dump/triples.scm
+++ b/dump/triples.scm
@@ -7,7 +7,8 @@
prefix
triple
scm->triples
- annotate-field))
+ annotate-field
+ string->binomial-name))
(define (annotate-field field schema)
(let ([schema (cond ((symbol? schema)
@@ -89,3 +90,19 @@ characters with an underscore and prefixing with gn:PREFIX."
(else object))
(fn id predicate object))))
alist))
+
+(define (string->binomial-name name)
+ (let ((binomial?
+ (string-match
+ "\\\(.+\\)"
+ name)))
+ (string->identifier
+ ""
+ (if binomial?
+ (regexp-substitute/global
+ #f "[^[:space:]A-Za-z0-9:]"
+ (match:substring binomial?)
+ 'pre "" 'post)
+ name)
+ #:separator ""
+ #:proc string-capitalize-first)))