|
(load "srfi-1.scm") ;;you pretty much have to roll your own stripped down version of list library |
|
|
|
(define (apropos sym) |
|
(let ((name (format nil "%s" sym))) |
|
(filter (lambda (x) |
|
(and |
|
(symbol-bound? x) |
|
(string-matches |
|
(format nil "%s" x) |
|
(string-append ".*" name ".*")))) |
|
(oblist)))) |
|
|
|
(define (duplicate n x) |
|
(map (lambda (_) x) |
|
(iota nil 0 n))) |
|
|
|
(define bt2w builtin_english_token_to_words) |
|
|
|
(define (token_to_words token name) |
|
(let ((prepunc (item.feat token "prepunctuation")) |
|
(punc (item.feat token "punc")) |
|
(tok-name (item.feat token "name"))) |
|
(cond |
|
((string-matches tok-name ".*\-.*") |
|
(append (bt2w token (string-before tok-name "-")) |
|
'("dash") |
|
(bt2w token (string-after tok-name "-")))) |
|
((string-equal name "(") |
|
(cons "khakho" (bt2w token name))) |
|
((string-equal name ")") |
|
(append (bt2w token name) (list "kohkha"))) |
|
((string-matches prepunc "\(+") |
|
(append (duplicate (length prepunc) "khakho") |
|
(bt2w token name) |
|
(if (string-matches punc "\)+") |
|
(duplicate (length punc) "kohkha") |
|
'()))) |
|
((string-matches punc "\)+") |
|
(append (bt2w token name) |
|
(duplicate (length punc) "kohkha"))) |
|
|
|
((string-matches prepunc "'") |
|
(cons "quote" (bt2w token name))) |
|
|
|
(t (bt2w token name))))) |
|
|
|
|
|
(define (name->words name) |
|
(cond ((string-matches name ".*-.*") |
|
(append (name->words (string-before name "-")) |
|
(list "dash") |
|
(name->words (string-after name "-")))) |
|
|
|
((string-equal name "*") |
|
(list "star")) |
|
((string-equal name "/") |
|
(list "division")) |
|
|
|
(t (let ((utt0 (eval (list 'Utterance 'Text name)))) |
|
;;just needs to get Token from name. Don't do this if possible. |
|
(utt.synth utt0) |
|
(token_to_words (cadr (utt.relation.items utt0 'Token)) name))))) |
|
|
|
|
|
(define (sexpr->words expr) |
|
(cond |
|
((pair? expr) |
|
(append '("khakho") |
|
(apply append (map sexpr->words expr)) |
|
'("khohkha"))) |
|
(t (name->words (format nil "%s" expr))))) |