@@ -43,10 +43,11 @@ series-folder images-folder articles-pagetree series-pagetree first-words + normalize build-note-id notes->last-disposition-values disposition-values ) @@ -259,10 +260,16 @@ (check-equal? (first-words txs-punc+split-elems 5) "Stop! she called. She was") (check-equal? (first-words txs-dashes 5) "One and only one. That") (check-equal? (first-words txs-dashes 4) "One and only one.") (check-equal? (first-words txs-parens-commas 5) "She counted one two silently") (check-equal? (first-words txs-short 5) "Not much here!")) + +;; Convert a string into all lowercase, replace all non-alphanum chars with ‘-’ +(define (normalize str) + (~> (regexp-replace* #rx"[^A-Za-z0-9 ]" str "") + string-downcase + (string-normalize-spaces #px"\\s+" "-"))) ;; Convert, e.g., "* thoroughly recanted" into (values "*" "thoroughly recanted") (define (disposition-values str) (cond [(string=? "" str) (values "" "")] [else (let ([splut (string-split str)])