Created
September 9, 2015 21:01
-
-
Save davidblurton/9a3ea353ef5a158a7c5d 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
(ns verbs.core | |
(:require [clojure.data.csv :as csv] | |
[clojure.java.io :as io]) | |
(:gen-class)) | |
(def types { | |
:verb "so" | |
:pronoun "pfn" | |
:adjective "lo" | |
:number "to" | |
:adverb "ao"}) | |
(def data (with-open [in-file (io/reader "resources/in-file.csv")] | |
(doall | |
(csv/read-csv in-file :separator \;)))) | |
(def fields | |
[:word :id :type :section :form :tag]) | |
(def words | |
(map #(zipmap fields %) data)) | |
(defn find-word [query] | |
#(= (:form %) query)) | |
(defn find-by-type [type] | |
#(= (:type %) (type types))) | |
(def verbs | |
(map :form | |
(filter (find-by-type :adjective) words))) | |
(defn -main | |
"Show me all the verbs" | |
[& args] | |
(doseq [i verbs] | |
(println i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment