    (let [train-set (java.io.File. (expand-home train-path))
          test-set (java.io.File. (expand-home test-path))]
 
-     (doto-class LexerRunner
-                 (setLexer (JavaLexer.))
-                 (setPerLine false)
-                 (addSentenceMarkers true)
-                 (useExtension "java"))
+     (init-java-lexer)
+     (init-modeler :self-test (= train-path test-path))
 
-     (let [jm-giga-model (JMModel. (GigaCounter.))]
+     (let [model (-<>> (JMModel. (GigaCounter.))
+                       (doto <> (ModelRunner/learn train-set))
+                       (NestedModel. test-set)
+                       (InverseMixModel. <> (CacheModel.))
+                       (doto <> (.setDynamic true)))]
 
-     (doto-class ModelRunner
-                 (perLine false)
-                 (selfTesting (.equals train-set test-set))
-                 (setNGramOrder 6)
-                 (learn jm-giga-model train-set))
+       {:model model
+        :modeled-files (->> (ModelRunner/model model test-set)
+                            .iterator iterator-seq (map pair->vec) (into {}))}
+       ))))
 
-     (let [nested-model (NestedModel. test-set jm-giga-model)
-           mix-model (doto (InverseMixModel. nested-model (CacheModel.))
-                           (.setDynamic true))]
-
-       (let [modeled-files (->> (ModelRunner/model mix-model test-set)
-                            .iterator iterator-seq (map pair->vec) (into {}))]
-
-       {:model model :modeled-files modeled-files}))))))
-
-(def ngram-res (ngram-java "~/atom-finder/src/java"))
+(def ngram-res (time-mins (ngram-java "~/atom-finder/src/java")))
 
 (def statistics (->> ngram-res :modeled-files ModelRunner/getStats))
 
 (printf "Modeled %d tokens, average entropy:\t%.4f\n" (.getCount statistics) (.getAverage statistics))
-))
 
+(defn random-split [amount lst]
+  (let [shuffled-lst (shuffle lst)]
+    (-> shuffled-lst count (* amount) double java.lang.Math/round (split-at shuffled-lst))))
+
+(def nginx-c-files (->> "~/opt/src/atom-finder/nginx" expand-home c-files (random-split 0.9)))
+
+(defn model-files [train-files test-files]
+  (init-java-lexer)
+  (init-modeler :self-test false)
+
+  (let [model (-<>> (JMModel. (GigaCounter.))
+                    (doto <> (ModelRunner/learn train-set))
+                    (NestedModel. test-set)
+                    (InverseMixModel. <> (CacheModel.))
+                    (doto <> (.setDynamic true)))]
+
+    {:model model
+     :modeled-files (->> (ModelRunner/model model test-set)
+                         .iterator iterator-seq (map pair->vec) (into {}))}
+    ))


(defn pair->vec [p] [(.left p) (.right p)])

(time-mins (do

;(def train-set (java.io.File. (expand-home "~/opt/src/SLP-Core")))
(def train-set (java.io.File. (expand-home )))

(defn ngram-java
  ([train-path] (ngram-java train-path train-path))

            [clojure.pprint :refer [pprint]]
            [clojure.string :as str]
            [atom-finder.util :refer :all]
            [swiss.arrows :refer :all]
            )
  (:import
            [slp.core.counting.giga GigaCounter]
