<commit_before>(ns xanny.quiz
  (:require [xanny.texts :as t]
            [xanny.utilities :refer :all]
            [clojure.string :as s]
            [clojure.pprint :refer :all]))

;create a latin dictionary quiz. it'll supply one true definiton, and 3 other random ones. It'll also tell you what words match those false answers 

;these are the [XXXXX] codes: AGE, AREA, GEO, FREQ, SOURCE
;file://localhost/Users/PCEye/Downloads/words-1.97Ed/wordsdoc.htm#Dictionary Codes
;needs to handle words with multiple definitions, like malus
(defn latin-dict []
  (with-open [rdr (clojure.java.io/reader  "text-files/latin-dict.txt" :encoding "UTF-8")]
    (loop [seq (t/insert-line-if (line-seq rdr) "" #".+\[.+\]" :above)
           map {}
           entry []]
      (let [line (first seq)]
        ;(pprint entry)
        (cond (empty? seq)
              map
              (and (empty? line) (not (empty? entry)))
              (recur (rest seq) (conj map entry) [])
              (and (empty? entry) (not (empty? line)))
              (recur (rest seq) map [(first-word line) {:forms (rest-words line) :entry nil}])
              (empty? line)
              (recur (rest seq) map entry)
              :else (recur (rest seq) map 
                           [(first entry) (assoc (second entry) :entry
                                            (s/join " " [(:entry (second entry)) line]))]))))))

(def dict (latin-dict))


;have a different vocab lists for verbs
(def vocab {:nouns (s/split "agricola puella nihil fama forma fortuna ira nauta patria pecunia philosophia poena poeta porta puella rosa sententia vita ager amicus femina filia filius numerus populus puer sapientia vir avarus pauci basium bellum consillium cura donum exitium magister mora oculus officium otium periculum remedium Romanus adulescentia animus caelum culpa gloria verbum deus discipulus insidiae liber tyrannus vitium " #"\ ")
            :verbs (s/split "cogito amo debeo do erro laudo moneo salveo servo conservo terreo valeo habeo satio video voco iuvo tolero sum" #"\ ")
            :adjectives (s/split "pulcher non antiquus magnus multus tuus meus sanus plenus salvus secundus perpetuus"#"\ ")
            :adverbs (s/split "saepe semper bonus humanus bellus malus parvus stultus verus hodie ibi nunc quare ubi" #"\ ")
            :other (s/split "si" #"\ ")})

(defn all-vocab []
  (flatten (vals vocab)))


;keep a list of words chosen, so the list of words decrements each time. keep a map of correct and wrong guesses, then let you replay with the words you got wrong. 
;save attempts to a file, and access the most recent entry, or overwrite it each time, or overwrite the entry for each set, so it separates noun attempts from verb ones. 
(defn vocab-quiz [words]
  (println "Welcome to the vocab quiz!")
  (loop [words-left words
         wrong-answers []]
    (if (empty? words-left)
      (if (empty? wrong-answers)
        wrong-answers ;not working
        (println wrong-answers "\nBeginning quiz with missed words")) 
      (let [word (rand-nth words-left)
            pick (dict word)]
        (println "The word is:" word "; it's forms being" (:forms pick))
        (println "Do you know the meaning? ") ;put this after the entry to confirm if you're right.
        (let [correct? (re-matches #"(?i)y|yes" (read-line))]
          (println "ENTRY:" (:entry pick))
          (println "Continue?" "\n")
          (if-not (re-matches #"(?i)n|no" (read-line))
            (recur (remove #{word} words-left)
                   (if correct?
                     wrong-answers
                     (conj wrong-answers word)))
            (if correct?
              wrong-answers
              (conj wrong-answers word))))))))
;use rand-nth for the quiz

;put the vocab words in certain forms

(def pronunciation {:consonants {} :vowels {} :dipthongs {}})

(def cases {:nom {:sg {1 {:fem "-a" :masc "-a"} 
                       2 {:masc "-us" :neut "-um"}} 
                  :pl {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-i" :neut "-a"}}}

            :gen {:sg {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-i" :neut "-i"}} 
                  :pl {1 {:fem "-arum" :masc "-arum"} 
                       2 {:masc "-orum" :neut "-orum"}}} 

            :dat {:sg {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-o" :neut "-o"}}
                  :pl {1 {:fem "-is" :masc "-is"} 
                       2 {:masc "-is" :neut "-is"}}} 

            :acc {:sg {1 {:fem "-am" :masc "-am"} 
                       2 {:masc "-um" :neut "-um"}}
                  :pl {1 {:fem "-as " :masc "-as"} 
                       2 {:masc "-os" :neut "-a"}}} 

            :abl {:sg {1 {:fem "-a" :masc "-a"} 
                       2 {:masc "-o" :neut "-o"}}
                  :pl {1 {:fem "-is" :masc "-is"} 
                       2 {:masc "-is" :neut "-is"}}} 

            :voc {:sg {1 {:fem "-a" :masc "-a"}
                       2 {:masc "-e" :neut "-um"}}
                  :pl {1 {:fem "-ae" :masc "-ae"}
                       2 {:masc "-i" :neut "-a"}}}})
<commit_msg>changed to vectors in smush-chunk<commit_after>(ns xanny.quiz
  (:require [xanny.texts :as t]
            [xanny.utilities :refer :all]
            [clojure.string :as s]
            [clojure.pprint :refer :all]))

;create a latin dictionary quiz. it'll supply one true definiton, and 3 other random ones. It'll also tell you what words match those false answers 

;these are the [XXXXX] codes: AGE, AREA, GEO, FREQ, SOURCE
;file://localhost/Users/PCEye/Downloads/words-1.97Ed/wordsdoc.htm#Dictionary Codes
;needs to handle words with multiple definitions, like malus
(defn latin-dict []
  (with-open [rdr (clojure.java.io/reader  "text-files/latin-dict.txt" :encoding "UTF-8")]
    (loop [seq (t/insert-line-if (line-seq rdr) "" #".+\[.+\]" :above)
           map {}
           entry []]
      (let [line (first seq)]
        ;(pprint entry)
        (cond (empty? seq)
              map
              (and (empty? line) (not (empty? entry)))
              (recur (rest seq) (conj map entry) [])
              (and (empty? entry) (not (empty? line)))
              (recur (rest seq) map [(first-word line) {:forms (rest-words line) :entry nil}])
              (empty? line)
              (recur (rest seq) map entry)
              :else (recur (rest seq) map 
                           [(first entry) (assoc (second entry) :entry
                                            (s/join " " [(:entry (second entry)) line]))]))))))

(def dict (latin-dict))


;have a different vocab lists for verbs
(def vocab {:nouns (s/split "agricola puella nihil fama forma fortuna ira nauta patria pecunia philosophia poena poeta porta puella rosa sententia vita ager amicus femina filia filius numerus populus puer sapientia vir avarus pauci basium bellum consillium cura donum exitium magister mora oculus officium otium periculum remedium Romanus adulescentia animus caelum culpa gloria verbum deus discipulus insidiae liber tyrannus vitium " #"\ ")
            :verbs (s/split "cogito amo debeo do erro laudo moneo salveo servo conservo terreo valeo habeo satio video voco iuvo tolero sum" #"\ ")
            :adjectives (s/split "pulcher non antiquus magnus multus tuus meus sanus plenus salvus secundus perpetuus"#"\ ")
            :adverbs (s/split "saepe semper bonus humanus bellus malus parvus stultus verus hodie ibi nunc quare ubi" #"\ ")
            :other (s/split "si" #"\ ")})

(defn all-vocab []
  (flatten (vals vocab)))


;keep a list of words chosen, so the list of words decrements each time. keep a map of correct and wrong guesses, then let you replay with the words you got wrong. 
;save attempts to a file, and access the most recent entry, or overwrite it each time, or overwrite the entry for each set, so it separates noun attempts from verb ones. 
(defn vocab-quiz [words]
  (println "Welcome to the vocab quiz!")
  (loop [words-left words
         wrong-answers []]
    (if (empty? words-left)
      (if (empty? wrong-answers)
        wrong-answers ;not working
        (println wrong-answers "\nBeginning quiz with missed words")) 
      (let [word (rand-nth words-left)
            pick (dict word)]
        (println "The word is:" word "; it's forms being" (:forms pick))
        (println "Do you know the meaning? ") ;put this after the entry to confirm if you're right.
        (let [correct? (re-matches #"(?i)y|yes" (read-line))]
          (println "ENTRY:" (:entry pick))
          (println "Continue?" "\n")
          (if-not (re-matches #"(?i)n|no" (read-line))
            (recur (remove #{word} words-left)
                   (if correct?
                     wrong-answers
                     (conj wrong-answers word)))
            (if correct?
              wrong-answers
              (conj wrong-answers word))))))))
;use rand-nth for the quiz

;put the vocab words in certain forms

(def pronunciation {:consonants {} :vowels {} :dipthongs {}})

(def cases {:nom {:sg {1 {:fem "-a" :masc "-a"} 
                       2 {:masc "-us" :neut "-um"}
                       3 {:masc "" :fem "-us" :neut "-us"}} 
                  :pl {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-i" :neut "-a"}
                       3 {:masc "-es" :fem "-es" :neut "-a"}}}

            :gen {:sg {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-i" :neut "-i"}
                       3 {:masc "-is" :fem "-is" :neut "-is"}} 
                  :pl {1 {:fem "-arum" :masc "-arum"} 
                       2 {:masc "-orum" :neut "-orum"}
                       3 {:masc "-um" :fem "-um" :neut "-um"}}} 

            :dat {:sg {1 {:fem "-ae" :masc "-ae"} 
                       2 {:masc "-o" :neut "-o"}
                       3 {:masc "-i" :fem "-i" :neut "-i"}}
                  :pl {1 {:fem "-is" :masc "-is"} 
                       2 {:masc "-is" :neut "-is"}
                       3 {:masc "-ibus" :fem "-ibus" :neut "-ibus"}}} 

            :acc {:sg {1 {:fem "-am" :masc "-am"} 
                       2 {:masc "-um" :neut "-um"}
                       3 {:masc "-em" :fem "-em" :neut "-em"}}
                  :pl {1 {:fem "-as " :masc "-as"} 
                       2 {:masc "-os" :neut "-a"}
                       3 {:masc "-es" :fem "-es" :neut "-a"}}} 

            :abl {:sg {1 {:fem "-a" :masc "-a"} 
                       2 {:masc "-o" :neut "-o"}
                       3 {:masc "-e" :fem "-e" :neut "-e"}}
                  :pl {1 {:fem "-is" :masc "-is"} 
                       2 {:masc "-is" :neut "-is"}
                       3 {:masc "-ibus" :fem "-ibus" :neut "-ibus"}}} 

            
            :voc {:sg {1 {:fem "-a" :masc "-a"}
                       2 {:masc "-e" :neut "-um"}
                       3 {:masc "" :fem "-us" :neut "-us"}} ;the vocative is the same as nominative except for -us/-ius words
                  :pl {1 {:fem "-ae" :masc "-ae"}
                       2 {:masc "-i" :neut "-a"}
                       3 {:masc "-es" :fem "-es" :neut "-a"}}}})

{'fraction_non_alphanumeric': 0.14876856211517567, 'fraction_numerical': 0.006338283230713509, 'mean_word_length': 1.799746514575412, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5351976', 'n_tokens_mistral': 3726, 'n_tokens_neox': 3478, 'n_words': 1261}