Skip to content

Instantly share code, notes, and snippets.

@dbasch
Created November 28, 2012 07:02
Show Gist options
  • Save dbasch/4159527 to your computer and use it in GitHub Desktop.
Save dbasch/4159527 to your computer and use it in GitHub Desktop.
Indexing using state, not thread safe.
;; Create in-memory mappings from each word to a set of files that contain it.
(defn build-index[dirname]
(def idx (com.google.common.collect.ArrayListMultimap/create))
(doseq [file (map #(.getName %) (.listFiles (java.io.File. dirname)))]
(doseq [token (-> (str dirname "/" file) slurp tokenize)]
(.put idx token file)))
idx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment