 
 (def DICTIONARY-FILENAME "resources/dictionary.txt")
 (def POSTINGS-LIST-FILENAME "resources/postings.txt")
+(def URL-MAPPING-FILENAME "resources/url-mapping.txt")
 
-(declare token-seq-from-file create-sorted-term-postings-mapping write-term-postings-mapping-to-files read-in-dictionary)
+(declare create-indicies-helper read-in-dictionary)
 
 (defn initialize-index
   []
   (def DICTIONARY (read-in-dictionary)))
+
+(defn docid->url
+  [docid]
+  (-> (some
+       #(when (.startsWith % docid) %)
+       (line-seq (io/reader URL-MAPPING-FILENAME)))
+      (s/split #"\t")
+      second))
 
 (defn term->postings
   [term]

        url (doc "url")
        comments (doc "comments")
        comment-string (concat (map #(get % "text") comments))]
    (->
     (apply str body " " comment-string)
     (clojure.string/replace #"[^a-zA-Z\s]" "")
     (clojure.string/split #"\s+")
     normalize-tokens)))

(defn token-seq-from-file
  "Returns [docid token] lazy seq from file"
  [json-datafile]
  (apply
   concat
   (map
    (fn [line id]
      (map #(vector id %) (get-tokens-from-doc (json/read-str line))))
    (line-seq (io/reader json-datafile))
    (iterate inc 0))))

(defn sort-id-token-pairs
  "Sorts id token pairs

  [tokens]
  (map s/lower-case tokens))

(defn sanitize-tokens
  [tokens]
  (-> tokens
      (clojure.string/replace #"[^a-zA-Z\s]" "")
      (clojure.string/split #"\s+")
      normalize-tokens))

(defn get-tokens-from-doc
  "Takes reddit doc from json data"
  [doc]
