From 56e5e486abb5357c1cd113dae169ff969bed7886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Gari=C3=A9py?= Date: Wed, 23 Dec 2015 23:43:13 -0500 Subject: [PATCH] can now build a uberjar containing only the web client --- .gitignore | 1 + project.clj | 11 ++++++----- src/reddit_nlp/core.clj | 9 ++++++++- src/reddit_nlp/dataset.clj | 12 ++---------- src/reddit_nlp/web.clj | 4 ++++ 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 5af1c71..d2aa971 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ pom.xml.asc /report/*.aux /report/*.log /report/*.out +/report/*.pdf # emacs *~ diff --git a/project.clj b/project.clj index f6b59fc..46549bc 100644 --- a/project.clj +++ b/project.clj @@ -5,11 +5,12 @@ [cheshire "5.5.0"] [http-kit "2.1.18"] [hiccup "1.0.5"] - [compojure "1.4.0" :exclusions [joda-time]] - [ring/ring-defaults "0.1.5"] - [edu.stanford.nlp/stanford-corenlp "3.5.2"]] - :resource-paths ["resources" "lib/stanford-corenlp-models-current.jar"] + [compojure "1.4.0"] + [ring/ring-defaults "0.1.5"]] + :resource-paths ["resources"] :main ^:skip-aot reddit-nlp.web :test-paths ["test"] :target-path "target/%s" - :profiles {:uberjar {:aot :all}}) + :profiles {:dev {:dependencies [[edu.stanford.nlp/stanford-corenlp "3.5.2"]] + :resource-paths ["lib/stanford-corenlp-models-current.jar"]} + :uberjar {:aot [reddit-nlp.web]}}) diff --git a/src/reddit_nlp/core.clj b/src/reddit_nlp/core.clj index a9a00bf..2078b16 100644 --- a/src/reddit_nlp/core.clj +++ b/src/reddit_nlp/core.clj @@ -1,7 +1,8 @@ (ns reddit-nlp.core (:require [reddit-nlp.reddit :as reddit] [reddit-nlp.stanford-nlp-wrapper :as nlp] - [reddit-nlp.duckduckgo :as ddgo])) + [reddit-nlp.duckduckgo :as ddgo] + [reddit-nlp.dataset :as dataset])) (defn- count-or-two [elements] @@ -26,3 +27,9 @@ :sentiment (comments-average-sentiment (reddit/flatten-comments (reddit/comments-of-post post))) :topics (ddgo/structured-instant-answers (nlp/analyze-named-entities (reddit/title-of-post post))) })))) + +;; The simplest way to run this is with 'lein run -m reddit-nlp.core subreddit-name' +(defn -main + [subreddit & args] + (dataset/create-webdataset! subreddit (cards subreddit 20)) + (println "dataset has been created")) diff --git a/src/reddit_nlp/dataset.clj b/src/reddit_nlp/dataset.clj index 6cf582e..1508268 100644 --- a/src/reddit_nlp/dataset.clj +++ b/src/reddit_nlp/dataset.clj @@ -1,7 +1,6 @@ (ns reddit-nlp.dataset (:require [clojure.java.io :as io] - [reddit-nlp.reddit :as reddit] - [reddit-nlp.core :as core])) + [reddit-nlp.reddit :as reddit])) (def dataset-base-dir "resources/dataset/") @@ -42,15 +41,8 @@ (defn webdataset [subreddit] - (let [file (io/file (io/resource (str "webdataset/" subreddit)))] + (let [file (io/resource (str "webdataset/" subreddit))] (if file (read-string (slurp file)) {:cards []}))) -;; The simplest way to run this is with 'lein run -m reddit-nlp.dataset subreddit-name' -(defn -main - [subreddit & args] - ;; (let [posts (reddit/hot-posts-of-subreddit subreddit)] - ;; (create-dataset! posts)) - (create-webdataset! subreddit (core/cards subreddit 20)) - (println "dataset has been created")) diff --git a/src/reddit_nlp/web.clj b/src/reddit_nlp/web.clj index dde429d..04771ef 100644 --- a/src/reddit_nlp/web.clj +++ b/src/reddit_nlp/web.clj @@ -1,4 +1,5 @@ (ns reddit-nlp.web + (:gen-class) (:require [reddit-nlp.dataset :as dataset] [org.httpkit.server :as httpkit] [hiccup.page :as hiccup] @@ -18,6 +19,9 @@ (def subreddits ["news" "worldnews" + "justintrudeau" + "Pets" + "comicbookmovies" "johncena"]) (defn color-picker-generator