Improve wording
This commit is contained in:
parent
dcc44c6f99
commit
bd114d4ae0
2 changed files with 7 additions and 8 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
next-phrase
|
next-phrase
|
||||||
(recur next-phrase)))))
|
(recur next-phrase)))))
|
||||||
|
|
||||||
(defn elements
|
(defn states
|
||||||
"Returns all items in the markov chain for which a transition is defined."
|
"Returns all items in the markov chain for which a transition is defined."
|
||||||
[markov-chain]
|
[markov-chain]
|
||||||
(vec (keys markov-chain)))
|
(vec (keys markov-chain)))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
(ns heyarne.frantisek-kafka.samsa
|
(ns heyarne.frantisek-kafka.samsa
|
||||||
"Create your own Kafka."
|
"Create your own Kafka."
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.string :as str]
|
||||||
[clojure.string :as str]
|
|
||||||
[clojure.tools.cli :refer [parse-opts]]
|
[clojure.tools.cli :refer [parse-opts]]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[clj-http.client :as http]
|
[clj-http.client :as http]
|
||||||
|
|
@ -19,19 +18,19 @@
|
||||||
|
|
||||||
(def sentence-ending? #(some? (re-find #"[.?!]$" %)))
|
(def sentence-ending? #(some? (re-find #"[.?!]$" %)))
|
||||||
|
|
||||||
(defn valid-start? [elem]
|
(defn sentence-start? [state]
|
||||||
(some? (re-find #"^[A-Z]" (first elem))))
|
(some? (re-find #"^[A-Z]" (first state))))
|
||||||
|
|
||||||
(defn generate-sentence [markov-chain]
|
(defn generate-sentence [markov-chain]
|
||||||
(let [start (->> (markov/elements markov-chain)
|
(let [start (->> (markov/states markov-chain)
|
||||||
(filter valid-start?)
|
(filter sentence-start?)
|
||||||
(rand-nth))]
|
(rand-nth))]
|
||||||
(str/join " " (markov/generate markov-chain start sentence-ending?))))
|
(str/join " " (markov/generate markov-chain start sentence-ending?))))
|
||||||
|
|
||||||
;; interacting with the API
|
;; interacting with the API
|
||||||
|
|
||||||
(defn environment-setup? []
|
(defn environment-setup? []
|
||||||
(and (and (:mastodon-instance env) (:access-token env))))
|
(and (:mastodon-instance env) (:access-token env)))
|
||||||
|
|
||||||
(defn send-toot! [text]
|
(defn send-toot! [text]
|
||||||
(when (environment-setup?)
|
(when (environment-setup?)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue