diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-20 17:06:59 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-20 17:06:59 +0300 |
commit | b6bbb4f2cf0144aa58701cd2b46277838743a277 (patch) | |
tree | 1e9bcd3bd7871f2d38ee804b8d803f85317c788b /src/ellinika | |
parent | 554d5663361e1506a757e7639524ce4d461d043c (diff) | |
download | ellinika-b6bbb4f2cf0144aa58701cd2b46277838743a277.tar.gz ellinika-b6bbb4f2cf0144aa58701cd2b46277838743a277.tar.bz2 |
Allow for alternative stems in a same tense.
* data/irregular-verbs.xml: Add alternative passive aorist stem
for "lev".
* scm/verbop.scm (conjugation-set): When setting #:root,
keep a list of alternative stems.
(flush-mood): Update for changes in #:root storage.
* src/cgi-bin/conj.scm4 (show-best-matches): If only one
match is produced, show it immediately.
* src/ellinika/conjugator.scm: Allow for multiple stems.
* src/ellinika/sql.scm (->string): Bugfix.
Diffstat (limited to 'src/ellinika')
-rw-r--r-- | src/ellinika/conjugator.scm | 73 | ||||
-rw-r--r-- | src/ellinika/sql.scm | 2 |
2 files changed, 47 insertions, 28 deletions
diff --git a/src/ellinika/conjugator.scm b/src/ellinika/conjugator.scm index 0abec8d..f70e20c 100644 --- a/src/ellinika/conjugator.scm +++ b/src/ellinika/conjugator.scm @@ -44,13 +44,16 @@ (list-set! verb 0 value)) ((#:verb) (list-set! verb 1 value)) ((#:attested) (list-set! verb 3 (append (list-ref verb 3) (list value)))) (else - (let ((container (assoc key (list-ref verb 2)))) + (let ((container (assoc key (list-ref verb 2))) + (value (if (and (eq? key #:root) (not (list? value))) + (list value) + value))) (if container (set-cdr! container value) (list-set! verb 2 (append (list-ref verb 2) (list (cons key value))))))))) @@ -98,27 +101,39 @@ (define (load-verb-info verb voice mood tense) ; (format #t "LOAD ~A~%" verb) (let ((verbprop (ellinika:sql-query "SELECT property,value FROM verbtense WHERE \ verb=\"~A\" AND voice=\"~A\" AND mood=\"~A\" AND tense=\"~A\"" verb voice mood tense))) - (create-basic-verb-info verb - (if (null? verbprop) - '() - (map - (lambda (elt) - (let ((name (car elt)) - (value (cadr elt))) - (if (string=? name "override") - (cons #:override - (string-split value #\,)) - (cons (symbol->keyword - (string->symbol name)) - value)))) - verbprop))))) - + (create-basic-verb-info + verb + (let loop ((inlist (if (null? verbprop) + '() + (map + (lambda (elt) + (let ((name (car elt)) + (value (cadr elt))) + (if (string=? name "override") + (cons #:override + (string-split value #\,)) + (cons (symbol->keyword + (string->symbol name)) + value)))) + verbprop))) + (rootlist '()) + (outlist '())) +; (format #t "ARGS: ~A/~A/~A~%" inlist rootlist outlist) + (cond + ((null? inlist) + (if (null? rootlist) + outlist + (cons (cons #:root rootlist) outlist))) + ((eq? (caar inlist) #:root) + (loop (cdr inlist) (cons (cdar inlist) rootlist) outlist)) + (else + (loop (cdr inlist) rootlist (cons (car inlist) outlist)))))))) (define (thema-aoristoy-mesapathitikis-A root) (cond ((elstr-suffix? root "αίν") (elstr-append (elstr-trim root -3) "ανθ")) ;; FIXME: Also αθ, ηθ ((and @@ -189,13 +204,13 @@ WHERE verb=\"~A\" AND voice=\"~A\" AND thema=\"~A\"" (lookup-verb-info verb voice "aor") tmpres)))) (verb-set! vinfo #:root (cond ((not (null? result)) (verb-set! vinfo #:attested 'root) - (caar result)) + (map car result)) ((string=? (verb-get vinfo #:conj) "A") (let ((root (verb-A-root elverb))) (cond ((string=? thema "pres") (verb-set! vinfo #:attested 'root) root) @@ -354,16 +369,15 @@ AND c.tense=\"~A\" AND c.flect = f.ident ORDER by fold" (or (verb-get vinfo #:accmap) t))) (or (verb-get vinfo #:accmap) (conj-info #:accmap conj) "000000")))) -(define (apply-flect conj vinfo verb) +(define (apply-flect conj vinfo verb root) ; (format #t "VINFO ~A~%" vinfo) - (let ((root (verb-get vinfo #:root)) - (suffix (get-suffix conj vinfo)) + (let ((suffix (get-suffix conj vinfo)) (accmap (string->list (get-accmap conj vinfo))) (augment "")) ; (format #t "ROOT ~A, ACCMAP ~S, SUFFIX: ~A~%" root accmap suffix) (cond ((> (length accmap) 6) (set! accmap (list-head accmap 6)) @@ -549,19 +563,24 @@ AND i.tense=\"~A\" AND i.ident=f.ident" (complement-verb-info vinfo verb (if (null? (cdr thema)) voice (car (cdr thema))) (car thema)))) ; (format #t "VINFO ~A~%" vinfo) - (cons - (cons - (append (apply-flect conj vinfo verb) - (list (verb-get vinfo #:conj) - (verb-get vinfo #:attested))) - (conj-info #:fold conj)) - prev))))) + + (fold + (lambda (stem prev) + (cons + (cons + (append (apply-flect conj vinfo verb stem) + (list (verb-get vinfo #:conj) + (verb-get vinfo #:attested))) + (conj-info #:fold conj)) + prev)) + prev + (verb-get vinfo #:root)))))) '() conj-list)))))))) (define-public (conjugator verb voice mood tense) (conjugate verb voice mood tense)) diff --git a/src/ellinika/sql.scm b/src/ellinika/sql.scm index 5867d28..f281847 100644 --- a/src/ellinika/sql.scm +++ b/src/ellinika/sql.scm @@ -41,13 +41,13 @@ (define (->string arg) (cond ((string? arg) arg) ((elstr? arg) (elstr->string arg)) ((number? arg) (number->string arg)) - ((bool? arg) (if arg "true" "false")) + ((boolean? arg) (if arg "true" "false")) (else (error "Unhandled argument type: ~S" arg)))) ;; Format specifiers: ;; ~A - escaped string |