12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- (library (user-defined)
- (export data/filter
- get-learned
- get-not-learned
- filter-attributes
- default-filter-word-attr
- train-not-learned
- display-word)
- (import (except (rnrs base)
- vector-map
- vector-for-each)
- (only (guile)
- lambda* λ
- ;; control structures
- when
- ;; output
- display
- simple-format
- ;; strings
- string-join
- string=)
- (ice-9 pretty-print)
- (srfi srfi-1) ; lists
- (srfi srfi-43) ; vectors
- (vector-utils)
- (alist-utils)
- (random-utils)
- (prefix (io) io:)
- (model))
- ;;; Add your own procedures here.
- (define data/filter
- (lambda* (data accessor condition #:key (filter vector-filter))
- "Access part of a data structure DATA using ACCESSOR and
- filter that part using CONDITION."
- (filter (λ (item) (condition item))
- (accessor data))))
- (define filter-attributes
- (λ (word
- metadata-attr-pred
- translation-data-attr-pred)
- `(("metadata"
- . ,(filter metadata-attr-pred
- (alist-refs word '("metadata"))))
- ("translation-data"
- . ,(filter translation-data-attr-pred
- (alist-refs word '("translation-data")))))))
- (define default-filter-word-attr
- (λ (ind word)
- (filter-attributes word
- (λ (meta-datum)
- (and (not (string= (car meta-datum) "usage-examples"))
- (not (string= (car meta-datum) "tags"))
- (not (string= (car meta-datum) "explanations"))))
- (λ (translation-datum)
- (and
- (not (string= (car translation-datum) "simplified"))
- (not (string= (car translation-datum) "traditional"))
- (not (string= (car translation-datum) "phonetic-script")))))))
- (define train-not-learned
- (λ (voc)
- (let ([not-learned
- (vector-map default-filter-word-attr
- (vocabulary-words voc))])
- (vector-for-each (λ (ind word)
- ;; (alist-print word)
- (io:read-line))
- not-learned)))))
|