feat: add verb declension for Eittlandic
All checks were successful
CI / build (29.4) (push) Successful in 1m14s
CI / build (snapshot) (push) Successful in 1m15s

This commit is contained in:
Lucien Cartier-Tilet 2024-09-14 11:25:02 +02:00
parent 75a0d5887e
commit 00d0b2f1ae
Signed by: phundrak
GPG Key ID: 347803E8073EACE0

View File

@ -30,6 +30,57 @@
(require 'dash)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Constants ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Verbs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst conlanging-eittlandic--generic-verb-inflexion-indicative-present
'(("" . "r") ("" . "r") ("" . "r") (nil . "um") (nil . "") (nil . ""))
"Generic indicative present declension for Eittlandic verbs.
This table shows the declension of verbs for the indicative
present. The order of the declensions is first, second, and
third person, first singular, then plural.
Each declension is a cons cell containing first the default
underlying vowel, and second the generic suffix.")
(defconst conlanging-eittlandic--generic-verb-inflexion-subjunctive-present
'((nil . "ir") (nil . "ir") (nil . "ir")
(nil . "im") (nil . "") (nil . ""))
"Generic subjunctive present declension for Eittlandic verbs.
See
`conlanging-eittlandic--generic-verb-inflexion-indicative-present'.")
(defconst conlanging-eittlandic--generic-verb-inflexion-past
'((nil . "t") (nil . "t") (nil . "t")
(nil . "um") (nil . "") (nil . ""))
"Generic past declension for Eittlandic verbs.
See
`conlanging-eittlandic--generic-verb-inflexion-indicative-present'.")
(defconst conlanging-eittlandic--strong-verb-inflexion-passive
'((nil . "umk") (nil . "sk") ("" . "sk")
(nil . "umk") ("" . "sk") ("" . "sk"))
"Strong passive inflexion for Eittlandic verbs.
See
`conlanging-eittlandic--generic-verb-inflexion-indicative-present'.")
(defconst conlanging-eittlandic--weak-verb-inflexion-passive
'((nil . "umk") ("" . "isk") ("" . "isk")
(nil . "umk") ("" . "isk") ("" . "isk"))
"Weak passive inflexion for Eittlandic verbs.
See
`conlanging-eittlandic--generic-verb-inflexion-indicative-present'.")
; Nouns ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst conlanging-eittlandic--strong-common-noun-declension
'((nil . "r") (nil . nil) (nil . nil) ("a" . "r")
(nil . "r") (nil . nil) (nil . "um") ("a" . "r"))
@ -76,6 +127,12 @@ See `conlanging-eittlandic--strong-common-noun-declension' for more info.")
See `conlanging-eittlandic--strong-common-noun-declension' for more info.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Functions ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Generic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun conlanging-eittlandic--maybe-underlying-vowel (underlying-vowel default-vowel)
"Return which underlying vowel should be used.
@ -93,8 +150,8 @@ UNDERLYING-VOWEL is non-nil."
(second-half (seq-subseq list half)))
(cons first-half second-half)))
(defun conlanging-eittlandic--make-noun-declension-from-table (root underlying-vowel table)
"Decline a noun ROOT (with maybe an UNDERLYING-VOWEL) with TABLE."
(defun conlanging-eittlandic--generate-declension-from-table (root underlying-vowel table)
"Decline a ROOT (with maybe an UNDERLYING-VOWEL) with TABLE."
(seq-reverse
(let (result)
(dolist (declension table result)
@ -103,6 +160,79 @@ UNDERLYING-VOWEL is non-nil."
(cdr declension))
result)))))
; Verbs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro conlanging-eittlandic--build-verb-declension-org ()
"Just to avoid typing all of this out.
ROOT, IMPERATIVE-PASSIVE, PRESENT-PARTICIPLE, PAST-PARTICIPLE,
IND-PRES, SUBJ-PRES, PAST, and PASSIVE are all different forms of
the verb that will be inserted in the org text."
`(format "Declensions:
- infinitive :: %s
- imperative :: %s
- imperative passive voice :: %s
- present participle :: %s
- past participle :: %s
| <c> | | | | | |
| person | | Ind. Pres. | Subj. Pres. | Past | Passive |
|--------+-+------------+-------------+------+---------|
| 1s | | %s | %s | %s | %s |
| 2s | | %s | %s | %s | %s |
| 3s | | %s | %s | %s | %s |
| 1p | | %s | %s | %s | %s |
| 2p | | %s | %s | %s | %s |
| 3p | | %s | %s | %s | %s |"
root root (concat root "ask") (concat root "and") (concat root "it")
,@(let (accessor i)
(reverse (dolist (declension
'(indicative-present subjunctive-present past passive)
accessor)
(setq i 0)
(while (< i 6)
(push `(nth ,i ,declension) accessor)
(setq i (1+ i))))))))
(defun conlanging-eittlandic--make-passive-verb-declension (root strength underlying-vowel passive-consonant passive-vowel)
"Create a verb declension for the passive mood.
Generates a passive declension for a verb with its ROOT based on
its STRENGTH and UNDERLYING-VOWEL. If there is no underlying
vowel for weak verbs, then the PASSIVE-VOWEL may be used instead.
If the verb is a verb is a strong verb, the PASSIVE-CONSONANT
will be used in some declensions."
(if (eq 'strong strength)
(conlanging-eittlandic--generate-declension-from-table root (or passive-vowel underlying-vowel)
conlanging-eittlandic--strong-verb-inflexion-passive)
(conlanging-eittlandic--generate-declension-from-table root passive-consonant
conlanging-eittlandic--weak-verb-inflexion-passive)))
(defun conlanging-eittlandic--make-verb-declension (root strength underlying-vowel passive-consonant passive-vowel mood tense)
"Create a verb declension based on its MOOD and TENSE.
Based on a verbs ROOT, STRENGTH, UNDERLYING-VOWEL, and potential
PASSIVE-CONSONANT or PASSIVE-VOWEL, create a verbs declension as
a list, in the following order:
- first person singular
- second person singular
- third person singular
- first person plural
- second person plural
- third person plural"
(if (eq 'passive mood)
(conlanging-eittlandic--make-passive-verb-declension root strength underlying-vowel passive-consonant passive-vowel)
(if (eq 'past tense)
(conlanging-eittlandic--generate-declension-from-table root underlying-vowel
conlanging-eittlandic--generic-verb-inflexion-past)
(conlanging-eittlandic--generate-declension-from-table
root underlying-vowel
(if (eq 'indicative mood)
conlanging-eittlandic--generic-verb-inflexion-indicative-present
conlanging-eittlandic--generic-verb-inflexion-subjunctive-present)))))
; Nouns ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun conlanging-eittlandic--make-noun-declension (root gender strength underlying-vowel &optional definite)
"Create declensions of a word in Eittlandic.
@ -117,7 +247,7 @@ list, going in the following order:
- plural accusative
- plural dative
- plural genitive"
(conlanging-eittlandic--make-noun-declension-from-table
(conlanging-eittlandic--generate-declension-from-table
root underlying-vowel
(if definite
(if (and (eq 'strong strength) (eq 'common gender))
@ -144,6 +274,42 @@ list, going in the following order:
(push `(nth ,i ,case) accessors)
(setq i (1+ i))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public functions ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;###autoload
(defun conlanging-eittlandic-insert-verb-declension (root strength underlying-vowel)
"Insert declensions of ROOT in org format at point.
Determines how to make declensions of the verb depending on its
STRENGTH and UNDERLYING-VOWEL."
(interactive
(list
(read-string "Verb root: ")
(pcase (completing-read "Strength: " '("strong" "weak") nil t)
("strong" 'strong)
("weak" 'weak)
(other (error (format "Unknown strength: %S" other))))
(let ((vowel (read-string "Underlying vowel (leave blank if none): ")))
(if (string= "" vowel) nil vowel))))
(let* ((passive-consonant (when (eq 'weak strength)
(completing-read "Consonant for passive declension: " '("d" "t" "ð") nil t)))
(passive-vowel (when (eq 'strong strength)
(completing-read "Vowel for passive declension: " '("a" "i") nil t)))
(indicative-present (conlanging-eittlandic--make-verb-declension root strength underlying-vowel
passive-consonant passive-vowel
'indicative 'present))
(subjunctive-present (conlanging-eittlandic--make-verb-declension root strength underlying-vowel
passive-consonant passive-vowel
'subjunctive 'present))
(past (conlanging-eittlandic--make-verb-declension root strength underlying-vowel passive-consonant
passive-vowel nil 'past))
(passive (conlanging-eittlandic--make-verb-declension root strength underlying-vowel
passive-consonant passive-vowel
'passive nil)))
(insert (conlanging-eittlandic--build-verb-declension-org))))
;;;###autoload
(defun conlanging-eittlandic-insert-noun-declensions (root gender strength underlying-vowel)
"Insert declensions of ROOT in org format at point.