   (let [tokens (t/tokenize source)]
     (do (fill-ngrams :n3 language (trigrams (wrap tokens)))
         (fill-ngrams :n2 language (bigrams (wrap tokens)))
-        (fill-ngrams :n1 language tokens))))
+        (fill-ngrams :n1 language tokens)
+        :ok)))
 
 (defn train-dir [dir]
   (let [langs (->> dir

        (doseq [f (remove #(.isDirectory %) 
                          (file-seq (io/file lang-dir)))]
          (train (slurp f) lang-key))))))
  
(defn- log-prob [token language]
  (Math/log
   (/ (double (inc (get (get @cat-map language {}) token 0)))
      (+ (get @global-map token 0) (reduce + (vals @global-map))))))

;; TODO probability of category
(defn- score [tokens language]
  (reduce +' (map #(log-prob % language) tokens))) 

(defn- scores [tokens languages]
  (map #(vec [% (score tokens %)]) languages))


;; TODO READABLE CODE WTF!
(defn- fill-ngrams [n-type lang tokens]
  (let [rm (-> tokens
               (frequencies)
               (assoc :size (count tokens)))]
    (do (swap! model ;; fill global model 
               #(assoc % n-type 
                       (merge-with + rm (get-in @model [n-type] {})
                                   )))
        (swap! model ;; fill lang specific model
               #(assoc-in % [:lang lang n-type] 
                          (merge-with + rm (get-in @model [:lang lang n-type] {})))))))
        

;; TODO avoid repetition
