From ae9d5bae9b7b8f53d6a7344e0c857fe5609793c2 Mon Sep 17 00:00:00 2001 From: Eric Ihli Date: Mon, 21 Jun 2021 15:12:21 -0500 Subject: [PATCH] More demo markov --- src/com/owoga/corpus/markov.clj | 54 +++++++++++++++++++++++++ src/com/owoga/prhyme/data_transform.clj | 5 +++ 2 files changed, 59 insertions(+) diff --git a/src/com/owoga/corpus/markov.clj b/src/com/owoga/corpus/markov.clj index fdd6ada..786f897 100644 --- a/src/com/owoga/corpus/markov.clj +++ b/src/com/owoga/corpus/markov.clj @@ -467,5 +467,59 @@ reverse)) (map (partial remove #{prhyme/BOS})) (map (partial string/join " ")))) + ;; => ("funeral has just begun" + ;; "dead illusion overdone" + ;; "all shout boy for then , outrun" + ;; "and those that turn till rerun" + ;; "heading for a pack of rerun" + ;; "furnace of end outrun" + ;; "the deaths outrun" + ;; "our funeral has begun" + ;; "paper that looking dark rerun" + ;; "walk overdone") + + (let [target-rhyme (->(prhyme/phrase->all-flex-rhyme-tailing-consonants-phones + "filling") + first + first + reverse)] + (->> (repeatedly + 10 + #(->> (tightly-generate-n-syllable-sentence-rhyming-with + database + markov-trie + rhyme-trie + target-rhyme + 3 + 3 + 7) + (map second) + reverse)) + (map (partial remove #{prhyme/BOS})) + (map data-transform/untokenize))) + + (rhyme-choices-walking-target-rhyme + rhyme-trie + (->> (prhyme/phrase->all-flex-rhyme-tailing-consonants-phones + "filling") + first + first + reverse)) + + (let [target-rhyme ["IY1" "ER"]] + (->> (repeatedly + 10 + #(->> (tightly-generate-n-syllable-sentence-rhyming-with + database + markov-trie + rhyme-trie + target-rhyme + 3 + 3 + 7) + (map second) + reverse)) + (map (partial remove #{prhyme/BOS})) + (map (partial string/join " ")))) ) diff --git a/src/com/owoga/prhyme/data_transform.clj b/src/com/owoga/prhyme/data_transform.clj index b99ccfa..61e0b15 100644 --- a/src/com/owoga/prhyme/data_transform.clj +++ b/src/com/owoga/prhyme/data_transform.clj @@ -42,6 +42,11 @@ (map (partial map second)) (map (partial mapv string/lower-case)))) +(defn untokenize + [coll] + (->> coll + (map #(string/join " " %)) + (map #(string/replace % #" (['\-,\?\.] ?)" "$1")))) (def xf-untokenize (comp (map #(string/join " " %))