   (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


(defn classify [source]
  (-> source
      (t/tokenize)
      (trigrams)
      (scores (keys @cat-map))
      (best)))

(defn languages []
  (keys @cat-map))


;; 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
