Skip to content

Instantly share code, notes, and snippets.

@shayanjm
Created June 29, 2014 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shayanjm/469a8f0484753f777672 to your computer and use it in GitHub Desktop.
Save shayanjm/469a8f0484753f777672 to your computer and use it in GitHub Desktop.
(defn update-sentiments
"Updates the given atom's sentiments & average-sentiments fields with the sentiment-analyzed body text of each article."
[atomstore]
(let [sentiments (apply list (doall (pmap #(find-sentiment (get-nyt-article-contents %)) (:urls @atomstore))))]
(dosync
(swap! atomstore assoc-in [:sentiments] (identity sentiments))
(swap! atomstore assoc-in [:average-sentiments] (map mean sentiments)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment