Cache calculated frequency data
This doesn't help that much because it's not streamed data.
This commit is contained in:
parent
1fb756d647
commit
9dc8e4bb5e
18
toplevel.scm
18
toplevel.scm
|
@ -1,11 +1,23 @@
|
||||||
(load "markov.chicken.so")
|
(load "markov.chicken.so")
|
||||||
(import markov
|
(import markov
|
||||||
(chicken format)
|
(chicken format)
|
||||||
srfi-18)
|
srfi-18
|
||||||
|
srfi-69
|
||||||
|
(chicken file))
|
||||||
|
|
||||||
|
(define table
|
||||||
|
(if (file-exists? "kjv-data.scm")
|
||||||
|
(with-input-from-file "kjv-data.scm"
|
||||||
|
(lambda ()
|
||||||
|
(display "Reading previously generated data.\n" (current-error-port))
|
||||||
|
(alist->hash-table (read))))
|
||||||
|
(with-output-to-file "kjv-data.scm"
|
||||||
|
(lambda ()
|
||||||
(display "Generating table (this may take a while)\n" (current-error-port))
|
(display "Generating table (this may take a while)\n" (current-error-port))
|
||||||
(define table (make-table-from-file "kjv.txt"))
|
(let ((table (make-table-from-file "kjv.txt")))
|
||||||
(display "Done generating.\n")
|
(display "done generating.\n" (current-error-port))
|
||||||
|
(write (hash-table->alist table))
|
||||||
|
table)))))
|
||||||
|
|
||||||
(define (generate-until-word* current collected limits)
|
(define (generate-until-word* current collected limits)
|
||||||
(if (member current limits)
|
(if (member current limits)
|
||||||
|
|
Loading…
Reference in New Issue