12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- (library (training)
- (export display-word
- display-solution
- train)
- (import (except (rnrs base)
- vector-map
- vector-for-each)
- (only (guile)
- lambda* λ
- ;; control structures
- when
- ;; output
- display
- simple-format
- ;; strings
- string-join)
- (alist-utils)
- (prefix (io) io:)
- (model))
- (define display-word
- (lambda* (word #:key (confirm #t))
- (display
- (simple-format
- #f "~a"
- (string-join (vector->list (alist-refs word '("translation-data" "native")))
- ", ")))
- (when confirm (io:read-line))))
- (define display-solution
- (lambda* (word #:key (confirm #t))
- (display
- (simple-format
- #f "phonetic script: ~a\n"
- (alist-refs word '("translation-data" "phonetic-script"))))
- (display
- (simple-format
- #f "simplified: ~a\n"
- (alist-refs word '("translation-data" "simplified"))))
- (display
- (simple-format
- #f "usage:\n ~a\n"
- (string-join (vector->list (alist-refs word '("metadata" "usage-examples")))
- "\n ")))
- (when confirm (io:read-line))))
- (define train
- (λ (vocabulary)
- (let* ([words (vocabulary-words vocabulary)]
- [num-words (vector-length words)])
- (let iter ([index° 0])
- (cond
- [(= index° num-words)
- (display (simple-format #f "training finised\n"))]
- [else
- (let ([word (vector-ref words index°)])
- (display-word word)
- (display-solution word)
- (display (simple-format #f "---\n"))
- (iter (+ index° 1)))]))))))
|