diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-18 17:21:37 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-18 17:21:37 +0300 |
commit | 978e459eb3f79853adf0dea0a8118f259e5cfa6e (patch) | |
tree | efb2049ff2f8e4ef952987e97cbf5179f3fe7bf6 /src/cgi-bin/conj.scm4 | |
parent | 8981940c41b9107a8bb387433cd0c7a6408bf03e (diff) | |
download | ellinika-978e459eb3f79853adf0dea0a8118f259e5cfa6e.tar.gz ellinika-978e459eb3f79853adf0dea0a8118f259e5cfa6e.tar.bz2 |
Improve conj.
* data/dbverb.struct: Use utf8_bin collation for the `verb' column in
all tables.
* data/irregular-verbs.xml: Update.
* po/POTFILES.in: Add conj.scm4.
* po/pl.po: Update.
* src/cgi-bin/conj.scm4: Try to fix some common input errors.
Look up the verb in the dictionary. If there are no tones in
the input word, look it up in the dictionary using the "soundslike"
method.
* style.css: Add h2.verb class.
Diffstat (limited to 'src/cgi-bin/conj.scm4')
-rw-r--r-- | src/cgi-bin/conj.scm4 | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/src/cgi-bin/conj.scm4 b/src/cgi-bin/conj.scm4 index 42b8405..7f7d347 100644 --- a/src/cgi-bin/conj.scm4 +++ b/src/cgi-bin/conj.scm4 @@ -23,6 +23,7 @@ (ice-9 rdelim) (ice-9 optargs) (xmltools dict) + (ellinika config) (ellinika elmorph) (ellinika tenses) (ellinika conjugator) @@ -64,7 +65,7 @@ ifelse(IFACE,[CGI],(cgi:init)) (if value (begin (display " value=\"") - (display (cgi-protect-quotes (ellinika:translate-input value))) + (display (cgi-protect-quotes value)) (display "\"")))) (display " /> </td> @@ -232,6 +233,24 @@ ifelse(IFACE,[CGI],(cgi:init)) (define (show-conjugation verb) (catch #t (lambda () + (let ((descr (ellinika:sql-query + "SELECT articles.meaning\ + FROM dict,articles\ + WHERE dict.word=~Q AND dict.ident=articles.ident\ + AND articles.lang=~Q AND (dict.pos & 1048576) = 1048576\ + ORDER BY articles.subindex\ + LIMIT 1" + verb + (language-code target-language)))) + (cond + ((and descr (not (null? descr))) + (format #t "<h2 class=\"verb\">~A - ~A</h2>" + verb (caar descr))) + (else + (format #t "<h2 class=\"verb\">~A - (~A)</h2>" + verb + (_ "δεν βρέθηκε στο λέξικο"))))) + (for-each (lambda (voice) (show-conjugation:voice voice)) @@ -244,7 +263,7 @@ ifelse(IFACE,[CGI],(cgi:init)) (subkey fmtstr fmtargs) (case subkey ((conjugator-error-input) - (error-message "Invalid input")) + (error-message (_ "Μη έγκυρη είσοδος"))) (else (error-message "CONJUGATOR ERROR: ~A ~A" subkey (apply format #f fmtstr fmtargs)))))) @@ -265,10 +284,69 @@ ifelse(IFACE,[CGI],(cgi:init)) (show-conjugation:voice voice)) (conjugate-all verb))) +(define (search-failure key) + (display "<h2>") + (format #t (_"Συγγνώμη, η λέξη \"~A\" δεν βρέθηκε στο λέξικο.") key) + (display "</h2>")) + +(define (display-cross-reference word) + (display "<a href=\"") + (display (make-cgi-name cgi-script-name "key" (dict:encode-string word))) + (display "\">") + (display word) + (display "</a>")) + +(define (show-best-matches key) + (let ((result (ellinika:sql-query + "SELECT DISTINCT word\ + FROM dict\ + WHERE sound LIKE ~Q\ + AND (pos & 1048576) = 1048576 ORDER BY 1" + (ellinika:sounds-like key)))) + (cond + ((null? result) + (search-failure key)) + (else + (format #t + "<div class=\"error\"><p>~A</p></div>" + (_ "Στην λέξη εισαγωγής δεν υπάρχει τόνος. Μήπος θέλατε να κλίσετε ένα απ'αυτά τα ρήματα:")) + (display "<table width=\"100%\" class=\"noframe\">") + (let* ((result-length (length result)) + (lim (1+ (quotient result-length match-list-columns)))) + (do ((i 0 (1+ i))) + ((= i lim) #f) + (display "<tr>") + (do ((j i (+ j lim))) + ((>= j result-length) #f) + (display "<td>") + (display-cross-reference (car (list-ref result j))) + (display "</td>")) + (display "</tr>"))) + (display "</table>"))))) + + (define (do-conj) (let ((keyval (cgi:value "key"))) (if (and keyval (not (string-null? keyval))) - (show-conjugation (ellinika:translate-input keyval))))) + (let ((input (ellinika:translate-input + (let ((keyval keyval)) + (cond + ((string-suffix? "o'" keyval) + (string-set! keyval + (- (string-length keyval) 2) #\v)) + ((string-suffix? "o" keyval) + (string-set! keyval + (- (string-length keyval) 1) #\v))) + keyval)))) + (cond + ((not (elstr-suffix? input "ω" "ώ" "ομαι" "αμαι")) + (format #t + "<div class=\"error\"><p>~A</p></div>" + (_ "Αυτή η λέξη δεν είναι ρήμα στο πρώτο ενικό πρόσωπο της οριστικής του ενεστώτα."))) + ((= (elstr-accented-syllable input) 0) + (show-best-matches input)) + (else + (show-conjugation input))))))) (define (print-footnote id sign text) (format #t "<p><a name=\"~A\">~A</a> ~A</p>~%" |