SHOW:
|
|
- or go back to the newest paste.
| 1 | - | (ns retriver.core |
| 1 | + | (ns retriever.core |
| 2 | - | (:gen-class)) |
| 2 | + | (:require [clojure.string :as str] |
| 3 | [clojure.pprint :refer [pprint]])) | |
| 4 | - | (def text (slurp "text\\potato.txt" :encoding "UTF-8")) |
| 4 | + | |
| 5 | - | (def countries (re-seq #".+(?=[\n,\r])|.+" (slurp "text\\countries.txt" :encoding "UTF-8"))) |
| 5 | + | (def text |
| 6 | - | (def cities (re-seq #".+(?=[\n,\r])|.+" (slurp "text\\cities.txt" :encoding "UTF-8"))) |
| 6 | + | (-> (slurp "resources/article.txt") |
| 7 | (str/replace #"[\.,();]" "") | |
| 8 | (str/split #"\s+|—") | |
| 9 | - | (defn count-match [string,file] |
| 9 | + | frequencies)) |
| 10 | - | (let [c (count (re-seq (re-pattern string) |
| 10 | + | (def cities (next (str/split-lines (slurp "resources/city.txt")))) |
| 11 | - | file))] |
| 11 | + | (def countries (next (str/split-lines (slurp "resources/countries.txt")))) |
| 12 | - | (when (> c 0) |
| 12 | + | |
| 13 | - | (format "%s : %d" string c)))) |
| 13 | + | (defn match [text file] |
| 14 | (remove (fn [v] (let [[_ b] v] (nil? b))) | |
| 15 | (pmap (juxt (fn [a] a) text) file))) | |
| 16 | - | (println (remove nil? (pmap (fn [word](count-match word text)) countries))) |
| 16 | + | |
| 17 | - | (println (remove nil? (pmap (fn [word](count-match word text)) cities))) |
| 17 | + | |
| 18 | - | (println "The end")) |
| 18 | + | (pprint (match text cities)) |
| 19 | (pprint (match text countries)) | |
| 20 | (pprint "The End")) |