Hi,
I am trying to store into a map the frequency of each [a-z]+ word in a
file. When I run this code in the repl the resulting dictionary is
empty. How should I adapt my code to get this functionality right?.
Thank you in advance
(import (java.io BufferedReader FileReader))
(def dictionary {})
(defn process-file [file-name]
(with-open
[rdr (BufferedReader. (FileReader. file-name))]
(doseq
[line (line-seq rdr)]
(reduce #(assoc %1 %2 (inc (get %1 %2 1))) dictionary (re-seq
#"[a-z]+" (.toLowerCase line))))))
(process-file "src/SpellChecker.clj")
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en