 (ns babel.english.grammar
   (:refer-clojure :exclude [get-in])
   (:require 
-   [babel.english.lexicon :refer [deliver-lexicon vocab-entry-to-lexeme]]
+   [babel.english.lexicon :refer [deliver-lexicon transform-with-english-lexical-rules
+                                  vocab-entry-to-lexeme]]
    [babel.english.morphology :refer (analyze fo)]
    [babel.generate :as generate]
    [babel.index :refer [create-indices lookup-spec]]
-   [babel.lexiconfn :refer [edn2lexicon read-lexicon]]
+   [babel.lexiconfn :refer [edn2lexicon filtered-lexicon read-lexicon]]
    [babel.parse :as parse]
    [babel.ug :as ug
     :refer [apply-default-if comp-modifies-head

         :lookup (fn [arg]
                   (analyze arg lexicon))
         :morph morph
         :morph-ps fo-ps}]
    (assoc model
          :generate-fn
          (fn [spec]
            (generate/generate spec model)))))

(defn model-with-vocab-items [vocab-items filter-lexicon-fn model]
  (let [input-lexicon (reduce merge (map vocab-entry-to-lexeme vocab-items))
        synthetic-noun (babel.lexiconfn/edn2lexicon input-lexicon)
        new-lexicon (merge-with concat
                                synthetic-noun
                                (babel.lexiconfn/filtered-lexicon
                                 (:lexicon model)
                                 filter-lexicon-fn))]
    (merge model
           {:lexicon new-lexicon})))

    [result]))

(declare cache)
(declare model-with-vocab-items)

(defn fo-ps [expr]
  (parse/fo-ps expr fo))
