<commit_before>(ns babel.latin.morphology
  )

(def replace-patterns
  {:p [#"^(.)eo$" "$1ēre"]
   :g [#"^(.)eo$" "$1eo"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :1st}}}}}}
  {:p [#"^(.)as$" "$1ēre"]
   :g [#"^(.)eo$" "$1as"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :2nd}}}}}}
  {:p [#"^(.)at$" "$1ēre"]
   :g [#"^(.)eo$" "$1at"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :3rd}}}}}}
  {:p [#"^(.)amus$" "$1ēre"]
   :g [#"^(.)eo$" "$1amus"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :1st}}}}}}
  {:p [#"^(.)atis$" "$1ēre"]
   :g [#"^(.)eo$" "$1atis"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :2nd}}}}}}
  {:p [#"^(.)ant$" "$1ēre"]
   :g [#"^(.)eo$" "$1ant"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :3rd}}}}}})
   
(defn analyze [surface-form lexicon]
  "Analyze a single surface form into a set of lexical forms."
  )

(defn conjugate [infinitive unify-with]
  "Conjugate an infinitive into a surface form by taking the first 
   element of replace-patterns where the element's :u unifies successfully with
   unify-with."
  (first
   (take 1
         (remove #(nil? %)
                 (map
                  (fn [replace-pattern]
                    (let [from (nth (:g replace-pattern) 0)
                          to (nth (:g replace-pattern) 1)
                          unify-against (or (:u replace-pattern) :top)]
                      (if (and from to
                               (re-matches from infinitive)
                               (not (fail? (unifyc unify-against
                                                   unify-with))))
                        (string/replace infinitive from to))))
                  replace-patterns)))))
<commit_msg>corrected present endings of 2nd conjugation<commit_after>(ns babel.latin.morphology
  )

(def replace-patterns
  {:p [#"^(.)eo$" "$1ēre"]
   :g [#"^(.)eo$" "$1eo"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :1st}}}}}}
  {:p [#"^(.)as$" "$1ēre"]
   :g [#"^(.)eo$" "$1es"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :2nd}}}}}}
  {:p [#"^(.)at$" "$1ēre"]
   :g [#"^(.)eo$" "$1et"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :sing
                                   :person :3rd}}}}}}
  {:p [#"^(.)amus$" "$1ēre"]
   :g [#"^(.)eo$" "$1emus"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :1st}}}}}}
  {:p [#"^(.)atis$" "$1ēre"]
   :g [#"^(.)eo$" "$1etis"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :2nd}}}}}}
  {:p [#"^(.)ant$" "$1ēre"]
   :g [#"^(.)eo$" "$1ent"]
   :u {:synsem {:infl :present
                :sem {:tense :present}
                :subcat {:1 {:agr {:number :plur
                                   :person :3rd}}}}}})
   
(defn analyze [surface-form lexicon]
  "Analyze a single surface form into a set of lexical forms."
  )

(defn conjugate [infinitive unify-with]
  "Conjugate an infinitive into a surface form by taking the first 
   element of replace-patterns where the element's :u unifies successfully with
   unify-with."
  (first
   (take 1
         (remove #(nil? %)
                 (map
                  (fn [replace-pattern]
                    (let [from (nth (:g replace-pattern) 0)
                          to (nth (:g replace-pattern) 1)
                          unify-against (or (:u replace-pattern) :top)]
                      (if (and from to
                               (re-matches from infinitive)
                               (not (fail? (unifyc unify-against
                                                   unify-with))))
                        (string/replace infinitive from to))))
                  replace-patterns)))))

{'fraction_non_alphanumeric': 0.17770396512352085, 'fraction_numerical': 0.01141789495536641, 'mean_word_length': 1.3804347826086956, '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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4529482', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1481, 'n_words': 417}