Skip to content

Instantly share code, notes, and snippets.

@davidblurton
Created September 9, 2015 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidblurton/9a3ea353ef5a158a7c5d to your computer and use it in GitHub Desktop.
Save davidblurton/9a3ea353ef5a158a7c5d to your computer and use it in GitHub Desktop.
(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