Created
May 4, 2012 20:40
-
-
Save MichaelDrogalis/2597592 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (use '[clojure.string :only (split-lines split)]) | |
| (defn read-lines [args] | |
| { :lines (split-lines (slurp (:filename args))) }) | |
| (defn lines-to-words [args] | |
| { :words (map #(split % #"\s") (:lines args)) }) | |
| (defn words-to-freqs [args] | |
| { :word-freqs (map #(frequencies %) (:words args)) }) | |
| (defn merge-freqs [args] | |
| { :freqs (apply merge-with + (:word-freqs args)) }) | |
| (merge-freqs | |
| (words-to-freqs | |
| (lines-to-words | |
| (read-lines { :filename "data.txt" })))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment