3 ms·
It works fine with code -- it basically just splits on whitespace and considers anything in the result to be a "word". The code won't make sense, and parens/br
by stevelosh 15y ago
It works fine with code -- it basically just splits on whitespace and considers anything in the result to be a "word".
The code won't make sense, and parens/brackets/etc won't be balanced, but you can definitely use it for practicing.
EDIT:
Here are a few drills it generated when I gave it its own source code:
# Lesson generated by Typkov
Lesson 1
(string/split (sanitize text) #"\s+"))) dict [w n] 0))) (rest words))))))
lessons)))) (defn sanitize [s] (-> s (string/replace \" \"))) (defn
[lesson n] (let [w n] (let [initial-word (random-choice (keys dict))))
(defn markov-dict ([words] (markov-dict words) n "\n" (join-n lines)))) (defn
Lesson 2
text 24) [:text "You must enter a decent amount of
"])))) "G:MENU\n"))) (defn random-choice [coll] (nth coll (rand-int n))] (loop
data))) (render "/" data) (not (form-valid? data))) (render "/" data)
data} (t/home (:text data) (t/home (:text data) (not (second words)]
Lesson 3
n] (let [initial-word (random-choice (keys dict))] (case format n] (let
[w (first words) lessons (repeatedly n (partial string/join "\n")) (def
\' \') (string/replace \" \"))) (defn markov-dict ([words] (markov-dict {}
get-lesson [text format n] 0))) (rest choices))))))) (def join-nn (partial