Advertisement
Guest User

Retriever V2

a guest
Aug 29th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns retriever.core                                                                                                
  2.   (:require [clojure.string :as str]
  3.             [clojure.pprint :refer [pprint]]))
  4.  
  5. (def text
  6.   (-> (slurp "resources/article.txt")
  7.       (str/replace #"[\.,();]" "")
  8.       (str/split #"\s+|—")
  9.       frequencies))
  10. (def cities (next (str/split-lines (slurp "resources/city.txt"))))
  11. (def countries (next (str/split-lines (slurp "resources/countries.txt"))))
  12.  
  13. (defn match [text file]
  14.   (remove (fn [v] (let [[_ b] v] (nil? b)))
  15.           (pmap (juxt (fn [a] a) text) file)))
  16.  
  17. (defn -main []
  18.   (pprint (match text cities))
  19.   (pprint (match text countries))
  20.   (pprint "The End"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement