<commit_before>(ns babel.english.demo
  (:require
   [babel.english :refer [generate]]
   [babel.english.morphology :refer [fo]]
   #?(:cljs [babel.logjs :as log])
   #?(:clj [clojure.tools.logging :as log])))

(declare run-demo-with)

(defn demo [ & [n]]
  (let [demo-specs
        [{:demo-name "Dog noun phrases"
          :synsem {:cat :noun
                   :sem {:pred :cane}}}

         {:demo-name "Noun Phrases"
          :synsem {:cat :noun}}
         
         {:demo-name "Sentences about dogs eating"
          :synsem {:cat :verb
                   :sem {:subj {:pred :cane}
                         :pred :mangiare}}}

         {:demo-name "Sentences about Eating"
          :synsem {:cat :verb
                   :sem {:pred :mangiare}}}

         {:synsem {:cat :verb}
          :demo-name "Sentences"}

         {:synsem :top
          :demo-name "Totally random expressions"}]]
         
    (count (map (fn [spec]
                  (let [log-message 
                        (str "running demo: " (:demo-name spec) "; " n " attempts.")]
                    (do (log/info log-message)
                        (println)
                        (println log-message)
                        (println)
                        (let [expressions (run-demo-with n spec)]
                          (count (pmap (fn [expression]
                                         (do
                                           (println (fo expression))))
                                       expressions))))))
                demo-specs))))

(defn run-demo-with [ & [n spec]]
  "print out _n_ generated sentences to stdout."
  (let [n (if n (Integer. n)
              100)
        spec (if spec spec
                 :top)]
    (filter #(not (nil? %)) 
            (take n (repeatedly
                     #(let [result
                            (generate spec)]
                        result))))))

<commit_msg>for now, only one demo to work on encyclopedia stuff<commit_after>(ns babel.english.demo
  (:require
   [babel.english :refer [generate]]
   [babel.english.morphology :refer [fo]]
   #?(:cljs [babel.logjs :as log])
   #?(:clj [clojure.tools.logging :as log])))

(declare run-demo-with)

(defn demo [ & [n]]
  (let [demo-specs
        [{:demo-name "Dog noun phrases"
          :synsem {:cat :noun
                   :sem {:pred :cane}}}

;         {:demo-name "Noun Phrases"
;          :synsem {:cat :noun}}
         
;         {:demo-name "Sentences about dogs eating"
;          :synsem {:cat :verb
;                   :sem {:subj {:pred :cane}
;                         :pred :mangiare}}}

;         {:demo-name "Sentences about Eating"
;          :synsem {:cat :verb
;                   :sem {:pred :mangiare}}}

;         {:synsem {:cat :verb}
;          :demo-name "Sentences"}

;         {:synsem :top
;          :demo-name "Totally random expressions"}
         ]]
         
    (count (map (fn [spec]
                  (let [log-message 
                        (str "running demo: " (:demo-name spec) "; " n " attempts.")]
                    (do (log/info log-message)
                        (println)
                        (println log-message)
                        (println)
                        (let [expressions (run-demo-with n spec)]
                          (count (pmap (fn [expression]
                                         (do
                                           (println (fo expression))))
                                       expressions))))))
                demo-specs))))

(defn run-demo-with [ & [n spec]]
  "print out _n_ generated sentences to stdout."
  (let [n (if n (Integer. n)
              100)
        spec (if spec spec
                 :top)]
    (filter #(not (nil? %)) 
            (take n (repeatedly
                     #(let [result
                            (generate spec)]
                        result))))))


{'fraction_non_alphanumeric': 0.13230769230769232, 'fraction_numerical': 0.0015384615384615385, 'mean_word_length': 1.1842105263157894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '213595', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1079, 'n_words': 297}