Wrap with js

main
Eric Ihli 4 years ago
parent f64217968e
commit 0d3f91a966

@ -1,5 +1,40 @@
#+TITLE: Capstone Documentation
* C
Design and develop a fully functional data product that addresses your identified business problem or organizational need. Include each of the following attributes as they are the minimum required elements for the product:
** one descriptive method and one non-descriptive (predictive or prescriptive) method
*** Descriptive Method
- 10 most common sentence structures
- Average lyric length
- 5-number analysis of lyric length
** collected or available datasets
** decision-support functionality
** ability to support featurizing, parsing, cleaning, and wrangling datasets
** methods and algorithms supporting data exploration and preparation
** data visualization functionalities for data exploration and inspection
** implementation of interactive queries
** implementation of machine-learning methods and algorithms
** functionalities to evaluate the accuracy of the data product
** industry-appropriate security features
** tools to monitor and maintain the product
** a user-friendly, functional dashboard that includes at least three visualization types
* Documentation
D. Create each of the following forms of documentation for the product you have developed:

@ -0,0 +1,15 @@
# find ~/src/prhyme/dark-corpus -type f -print0 | xargs -0 wc -l | grep -v '[0-9]\{4,\}.*total$' | sort -n
BEGIN {
}
{
a += $1;
b[++i] = $1;
}
END {
m = a/NR;
q1 = sprintf("%d", NR * 0.25);
q2 = sprintf("%d", NR * 0.5);
q3 = sprintf("%d", NR * 0.75);
print sprintf("Min: %d, Q1: %d, Median: %d, Q3: %d, Max: %d", b[0], b[q1], b[q2], b[q3], b[NR]);
}

@ -0,0 +1,7 @@
#!/usr/bin/env sh
find ~/src/prhyme/dark-corpus -type f -print0 | \
xargs -0 wc -l | \
grep -v '[0-9]\{4,\}.*total$' | \
sort -n | \
awk -f five-number-summary.awk

@ -135,7 +135,7 @@
perfect-sans-consonants? (if (perfect-rhyme-sans-consonants? phones1 phones2) 1 0)
num-matching-stressed (number-of-matching-vowels-with-stress phones1 phones2)
num-matching-any-stress (number-of-matching-vowels-any-stress phones1 phones2)
same-number-of-syllables (same-number-of-syllables? phones1 phones2)]
same-number-of-syllables (if (same-number-of-syllables? phones1 phones2) 1 0)]
(+ perfect?
perfect-sans-consonants?
num-matching-stressed
@ -258,6 +258,25 @@
;; ["bog" ["B" "AO1" "G"] 42 "log" ["L" "AO1" "G"] 4])
)
(defn distinct-by
"Returns a stateful transducer that removes elements by calling f on each step as a uniqueness key.
Returns a lazy sequence when provided with a collection."
([f]
(fn [rf]
(let [seen (volatile! #{})]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [v (f input)]
(if (contains? @seen v)
result
(do (vswap! seen conj v)
(rf result input)))))))))
([f xs]
(sequence (distinct-by f) xs)))
(defn rhymes-with-frequencies-and-rhyme-quality
[target trie database]
(let [rhymes- (rhymes target)
@ -266,7 +285,9 @@
(assoc-phrases-with-phones)
(append-freqs models/database models/markov-trie [1 1 1])
(append-rhyme-quality target))]
(distinct
(into
[]
(distinct-by first)
(sort-by
(fn [[w1 p1 f w2 p2 q]]
[(- q) (- f)])

@ -258,21 +258,21 @@
(fn [request]
{:status 200
:headers {"Content-Type" "text/html; charset=utf-8"}
:body (views/wrapper
db
request
{}
:body (views/wrap-with-js
{:db db
:request request
:opts {}}
(views/wgu request))}))
(defn show-rhyme-suggestion [db cache]
(fn [request]
(let [suggestions (linguistics/rhymes-with-frequencies
(let [suggestions (linguistics/rhymes-with-frequencies-and-rhyme-quality
(:rhyme-target (:params request))
models/markov-trie
models/database)]
{:status 201
:headers {"Content-Type" "text/html; charset=utf-8"}
:body (views/wrapper
:body (views/wrap-with-js
db
request
{}

@ -85,6 +85,95 @@
num-artists)]
[:a.washed-yellow.pl1 {:href "#"} "LINKS"]]]]))))
(defn wrap-with-js
([{db :db
request :request
{title :title
js :js
css :css
:or {title "DarkLimericks"
css ["/assets/tachyons.css"]
js ["/assets/wgu-main.js"]}
:as opts} :opts}
& body]
(println (keys request))
(let [num-albums (db.albums/num-albums db)
num-artists (db.artists/num-artists db)]
(page/html5
[:head
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
(apply page/include-css css)
(apply page/include-js js)
[:title title]
[:link {:rel "shortcut icon" :href "/assets/favicon.ico"}]]
[:body.tc.washed-yellow.bg-near-black.avenir
[:h1
[:a.link.dim.washed-yellow {:href "/"} "DarkLimericks.com"]]
[:div.w-50-ns.w-90.center.bg-dark-gray.pa2
[:div.f6.lh-copy.flex.justify-between
[:a.washed-yellow.pl1
{:href (util/route-name->path
request
:com.darklimericks.server.router/submit)}
"SUBMIT LIMERICKS"]
[:span.dark-yellow
(format
"METAL LIMERICKS - CURRENTLY %d ALBUMS FROM %d+ BANDS"
num-albums
num-artists)]
[:a.washed-yellow.pr1 {:href "#"} "LINKS"]]
[:div.flex.items-stretch.bg-near-black.flex-wrap.flex-nowrap-l.f6
(let [letters (map (comp str char) (range 97 123))]
(for [letter letters]
[:a.link.washed-yellow.bg-mid-gray.pv2.w1.w-100-ns.flex-auto
{:href (format "/%s.html" letter)
:style "margin: 1px;"}
[:strong (string/upper-case letter)]]))]
[:div.flex.items-center.justify-center.pv2
[:span.f6.ph2 "Search the darkness for limericks most heartless"]
[:form.ph2
{:method "GET" :action "#"}
[:input.bg-white.w4.w5-ns
{:type "text"
:name "search"
:id "search"
:value ""}]]]
[:div.bg-near-black.br4.pa2
body]
[:div.flex.items-center.justify-center.pv2
[:span.f6.ph2 "Search the darkness for limericks most heartless"]
[:form.ph2
{:method "GET" :action "#"}
[:input.bg-white.w4.w5-ns
{:type "text"
:name "search"
:id "search"
:value ""}]]]
[:div.flex.items-stretch.bg-near-black.flex-wrap.flex-nowrap-l.f6
(let [letters (map (comp str char) (range 97 123))]
(for [letter letters]
[:a.link.washed-yellow.bg-mid-gray.pv2.w1.w-100-ns.flex-auto
{:href (format "/%s.html" letter)
:style "margin: 1px;"}
[:strong (string/upper-case letter)]]))]
[:div.f6.lh-copy.flex.justify-between
[:a.washed-yellow.pr1
{:href (util/route-name->path
request
:com.darklimericks.server.router/submit)}
"SUBMIT LIMERICKS"]
[:span.dark-yellow
(format
"METAL LIMERICKS - CURRENTLY %d ALBUMS FROM %d+ BANDS"
num-albums
num-artists)]
[:a.washed-yellow.pl1 {:href "#"} "LINKS"]]]]))))
(defn home [db request recent-albums artists-by-album]
(wrapper
db
@ -210,5 +299,5 @@
[request suggestions]
[:div
(wgu request)
(for [[suggestion freq] suggestions]
[:div suggestion freq])])
(for [[suggestion p1 freq _ p2 quality] suggestions]
[:div (string/join " - " [suggestion freq p1 p2])])])

Loading…
Cancel
Save