Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; LEFTOFF: Conjugating works and you can print the conjugation now properly aligned.
- ;; We should definte the future indicative, and then have a way to pass the mood-tense
- ;; to the conjugate function to get the conjugation list.
- (in-package #:spanisher)
- (defparameter *moods* '(indicative subjunctive imperative))
- ;; TODO Visually organize all tenses
- (defparameter *indicative-tenses* '(present progressive present-perfect
- past-perfect preterit preterit-perfect imperfect
- future-ir future future-perfect conditional
- conditional-perfect))
- (defparameter *subjunctive-tenses* '(present imperfect future
- present-perfect past-perfect future-perfect))
- ;; Maybe rename symbols to tu/nosotros/etc.
- (defparameter *imperative-tenses* '(second-singular-informal
- second-plural-informal
- second-singular-formal
- second-plural-formal
- first-plural))
- (defun index-from-right (str index) (- (length str) index))
- (defun last-n-chars (str n) (subseq str (index-from-right str n)))
- (defun max-length-of-strings (strings) (apply #'max (mapcar #'length strings)))
- (defun make-string-with-spaces (num-spaces)
- (apply #'concatenate (append '(string) (loop for i from 1 to num-spaces collect " "))))
- (defun pad-string (str max-length)
- (concatenate 'string str (make-string-with-spaces (- max-length (length str)))))
- (defun print-conjugated-verb (verb-with-endings)
- (defun get-singular-tenses () (subseq verb-with-endings 0 3))
- (let* ((plural-start-index (+ 2 (max-length-of-strings (get-singular-tenses))))
- (singular-strings-ready (mapcar (lambda (str) (pad-string str plural-start-index))
- (get-singular-tenses)))
- (plural-strings-ready (subseq verb-with-endings 3)))
- (loop for singular in singular-strings-ready for plural in plural-strings-ready do
- (format 't "~a~a~%" singular plural))))
- (defun warn-reflexive-not-implemented (verb)
- (if (is-reflexive? verb) (print "Reflexive not imp")))
- ;; TODO Fix bug where reflexive verbs don't return their proper type.
- (defun get-verb-type (verb) (read-from-string (last-n-chars verb 2)))
- (defun is-reflexive? (verb) (equal (string-upcase (last-n-chars verb 3)) "RSE"))
- (defun get-verb-root (verb) (let ((last-index (if (is-reflexive? verb) 4 2)))
- (subseq verb 0 (index-from-right verb last-index))))
- ;; TODO fix reflexive verbs.
- (defun is-verb-type? (verb type) (eq (get-verb-type verb) type))
- (defun add-ending-to-infinative (verb ending)
- (concatenate 'string (get-verb-root verb) ending))
- (defun get-conjugated-list (verb endings)
- (loop for ending in endings collect (add-ending-to-infinative verb ending)))
- (defparameter +present-indicative-conjugations+
- (list 'ar '("o" "as" "a" "amos" "áis" "an")
- 'er '("o" "es" "e" "emos" "éis" "en")
- 'ir '("o" "es" "e" "imos" "ís" "en")))
- (defparameter +preterit-indicative-conjugations+
- (list 'ar '("é" "aste" "ó" "amos" "asteis" "aron")
- 'er '("í" "iste" "ió" "imos" "isteis" "ieron")
- 'ir '("í" "iste" "ió" "imos" "isteis" "ieron")))
- ;; Note that they are all the same.
- (defparameter +imperfect-indicative-conjugations+
- (list 'ar '("ía" "ías" "ía" "íamos" "íais" "ían")
- 'er '("ía" "ías" "ía" "íamos" "íais" "ían")
- 'ir '("ía" "ías" "ía" "íamos" "íais" "ían")))
- ;; Note that they are the same as the imperfect, except they keep the infinative
- ;; stem.
- (defparameter +conditional-indicative-conjugations+
- (list 'ar '("aría" "arías" "aría" "aríamos" "aríais" "arían")
- 'er '("ería" "erías" "ería" "eríamos" "eríais" "erían")
- 'ir '("iría" "irías" "iría" "iríamos" "iríais" "irían")))
- (defun conj-present-indactive (verb)
- (warn-reflexive-not-implemented verb)
- (get-conjugated-list verb (getf +present-indicative-conjugations+
- (get-verb-type verb))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement