|
|
@ -5,7 +5,10 @@
|
|
|
|
[com.darklimericks.db.albums :as db.albums]
|
|
|
|
[com.darklimericks.db.albums :as db.albums]
|
|
|
|
[com.darklimericks.db.artists :as db.artists]
|
|
|
|
[com.darklimericks.db.artists :as db.artists]
|
|
|
|
[com.darklimericks.server.util :as util]
|
|
|
|
[com.darklimericks.server.util :as util]
|
|
|
|
[com.darklimericks.server.models :as models]))
|
|
|
|
[com.darklimericks.server.models :as models]
|
|
|
|
|
|
|
|
[com.owoga.prhyme.core :as prhyme]
|
|
|
|
|
|
|
|
[com.owoga.corpus.markov :as markov]
|
|
|
|
|
|
|
|
[com.darklimericks.linguistics.core :as linguistics]))
|
|
|
|
|
|
|
|
|
|
|
|
(defn wrapper
|
|
|
|
(defn wrapper
|
|
|
|
([db request opts & body]
|
|
|
|
([db request opts & body]
|
|
|
@ -278,7 +281,7 @@
|
|
|
|
[:div line])]]))])
|
|
|
|
[:div line])]]))])
|
|
|
|
|
|
|
|
|
|
|
|
(defn wgu
|
|
|
|
(defn wgu
|
|
|
|
[request {:keys [rhymes rhyming-lyrics lyrics]}]
|
|
|
|
[request {:keys [rhymes rhyming-lyrics lyrics-from-seed]}]
|
|
|
|
[:div
|
|
|
|
[:div
|
|
|
|
[:h1 "WGU Capstone"]
|
|
|
|
[:h1 "WGU Capstone"]
|
|
|
|
[:div
|
|
|
|
[:div
|
|
|
@ -302,35 +305,39 @@
|
|
|
|
[:div
|
|
|
|
[:div
|
|
|
|
[:h2 "Generate Rhyming Lyric"]
|
|
|
|
[:h2 "Generate Rhyming Lyric"]
|
|
|
|
(form/form-to
|
|
|
|
(form/form-to
|
|
|
|
[:post (util/route-name->path
|
|
|
|
[:get (util/route-name->path
|
|
|
|
request
|
|
|
|
request
|
|
|
|
:com.darklimericks.server.router/wgu)]
|
|
|
|
:com.darklimericks.server.router/lyric-from-seed)]
|
|
|
|
(form/label
|
|
|
|
(form/label
|
|
|
|
"rhyming-lyric-target"
|
|
|
|
"lyric-from-seed"
|
|
|
|
"Target word or phrase for which to find a rhyming lyric")
|
|
|
|
"Target word or phrase for which to find a rhyming lyric")
|
|
|
|
" "
|
|
|
|
" "
|
|
|
|
(form/text-field
|
|
|
|
(form/text-field
|
|
|
|
{:placeholder "instead of war on poverty"}
|
|
|
|
{:placeholder "instead of war on poverty"}
|
|
|
|
"rhyming-lyric-target")
|
|
|
|
"seed")
|
|
|
|
(form/submit-button
|
|
|
|
(form/submit-button
|
|
|
|
{:class "ml2"}
|
|
|
|
{:class "ml2"}
|
|
|
|
"Show rhyming lyrics suggestions"))]
|
|
|
|
"Generate lyric from seed word or phrase"))
|
|
|
|
|
|
|
|
(when lyrics-from-seed
|
|
|
|
|
|
|
|
lyrics-from-seed)]
|
|
|
|
[:div
|
|
|
|
[:div
|
|
|
|
[:h2 "Generate Lyrics"]
|
|
|
|
[:h2 "Generate Lyric From Seed"]
|
|
|
|
(form/form-to
|
|
|
|
(form/form-to
|
|
|
|
[:post (util/route-name->path
|
|
|
|
[:get (util/route-name->path
|
|
|
|
request
|
|
|
|
request
|
|
|
|
:com.darklimericks.server.router/wgu)]
|
|
|
|
:com.darklimericks.server.router/rhyming-lyric)]
|
|
|
|
(form/label
|
|
|
|
(form/label
|
|
|
|
"lyric-target"
|
|
|
|
"rhyming-lyric-target"
|
|
|
|
"Seed word or phrase from which to generate lyric")
|
|
|
|
"Target word or phrase for which to find a rhyming lyric")
|
|
|
|
" "
|
|
|
|
" "
|
|
|
|
(form/text-field
|
|
|
|
(form/text-field
|
|
|
|
{:placeholder "instead of war on poverty"}
|
|
|
|
{:placeholder "instead of war on poverty"}
|
|
|
|
"lyric-target")
|
|
|
|
"rhyming-lyric-target")
|
|
|
|
(form/submit-button
|
|
|
|
(form/submit-button
|
|
|
|
{:class "ml2"}
|
|
|
|
{:class "ml2"}
|
|
|
|
"Show lyrics suggestions"))]
|
|
|
|
"Show rhyming lyrics suggestions"))
|
|
|
|
|
|
|
|
(when rhyming-lyrics
|
|
|
|
|
|
|
|
rhyming-lyrics)]
|
|
|
|
[:div#myChart]
|
|
|
|
[:div#myChart]
|
|
|
|
[:iframe {:src "/assets/README_WGU.htm"
|
|
|
|
[:iframe {:src "/assets/README_WGU.htm"
|
|
|
|
:style "background-color: white; width: 100%; height: 760px;"}]])
|
|
|
|
:style "background-color: white; width: 100%; height: 760px;"}]])
|
|
|
@ -338,8 +345,23 @@
|
|
|
|
(defn lyric-suggestions
|
|
|
|
(defn lyric-suggestions
|
|
|
|
[request suggestions]
|
|
|
|
[request suggestions]
|
|
|
|
[:div
|
|
|
|
[:div
|
|
|
|
(wgu request {:rhymes (for [suggestion suggestions]
|
|
|
|
(wgu
|
|
|
|
[:div suggestion])})])
|
|
|
|
request
|
|
|
|
|
|
|
|
{:rhyming-lyrics
|
|
|
|
|
|
|
|
[:table {:style "margin: auto;"}
|
|
|
|
|
|
|
|
[:tr
|
|
|
|
|
|
|
|
[:th "Lyric"]
|
|
|
|
|
|
|
|
[:th "OpenNLP Perplexity"]
|
|
|
|
|
|
|
|
[:th "Per-word OpenNLP Perplexity"]]
|
|
|
|
|
|
|
|
(let [suggestions
|
|
|
|
|
|
|
|
(for [suggestion suggestions]
|
|
|
|
|
|
|
|
(cons suggestion (linguistics/open-nlp-perplexity suggestion)))]
|
|
|
|
|
|
|
|
(for [[suggestion parse perplexity per-word-perplexity]
|
|
|
|
|
|
|
|
(sort-by (comp - last) suggestions)]
|
|
|
|
|
|
|
|
[:tr
|
|
|
|
|
|
|
|
[:td suggestion]
|
|
|
|
|
|
|
|
[:td perplexity]
|
|
|
|
|
|
|
|
[:td per-word-perplexity]]))]})])
|
|
|
|
|
|
|
|
|
|
|
|
(defn show-rhyme-suggestion
|
|
|
|
(defn show-rhyme-suggestion
|
|
|
|
[request suggestions]
|
|
|
|
[request suggestions]
|
|
|
@ -369,7 +391,6 @@
|
|
|
|
(juxt (comp - :rhyme-quality)
|
|
|
|
(juxt (comp - :rhyme-quality)
|
|
|
|
(comp - :freq))
|
|
|
|
(comp - :freq))
|
|
|
|
top-20-by-quality))]
|
|
|
|
top-20-by-quality))]
|
|
|
|
[:div
|
|
|
|
|
|
|
|
(wgu
|
|
|
|
(wgu
|
|
|
|
request
|
|
|
|
request
|
|
|
|
{:rhymes
|
|
|
|
{:rhymes
|
|
|
@ -377,4 +398,21 @@
|
|
|
|
[:table {:style "margin: auto;"}
|
|
|
|
[:table {:style "margin: auto;"}
|
|
|
|
[:tr [:th "Rhyme"] [:th "Pronunciation"] [:th "Quality"] [:th "Frequency"]]
|
|
|
|
[:tr [:th "Rhyme"] [:th "Pronunciation"] [:th "Quality"] [:th "Frequency"]]
|
|
|
|
(for [{:keys [word pronunciation rhyme-quality freq]} top-20-rhyme]
|
|
|
|
(for [{:keys [word pronunciation rhyme-quality freq]} top-20-rhyme]
|
|
|
|
[:tr [:td word] [:td (String/join "-" pronunciation)] [:td rhyme-quality] [:td freq]])]]})]))
|
|
|
|
[:tr [:td word] [:td (String/join "-" pronunciation)] [:td rhyme-quality] [:td freq]])]]})))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn lyrics-from-seed
|
|
|
|
|
|
|
|
[request seed]
|
|
|
|
|
|
|
|
(let [suggestions (linguistics/wgu-lyric-suggestions
|
|
|
|
|
|
|
|
(-> request :params :seed))]
|
|
|
|
|
|
|
|
(wgu
|
|
|
|
|
|
|
|
request
|
|
|
|
|
|
|
|
{:lyrics-from-seed
|
|
|
|
|
|
|
|
[:div
|
|
|
|
|
|
|
|
[:table {:style "margin: autoh"}
|
|
|
|
|
|
|
|
[:tr [:th "Rhyme"] [:th "Quality"] [:th "Lyric"] [:th "Perplexity"]]
|
|
|
|
|
|
|
|
(for [[seed [line [parse perp per-word-perp]]] suggestions]
|
|
|
|
|
|
|
|
[:tr
|
|
|
|
|
|
|
|
[:td (:word seed)]
|
|
|
|
|
|
|
|
[:td (:rhyme-quality seed)]
|
|
|
|
|
|
|
|
[:td line]
|
|
|
|
|
|
|
|
[:td per-word-perp]])]]})))
|
|
|
|