Created
November 28, 2012 07:02
-
-
Save dbasch/4159527 to your computer and use it in GitHub Desktop.
Indexing using state, not thread safe.
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
;; 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