summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2011-06-18 14:21:37 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-06-18 14:21:37 (GMT)
commit978e459eb3f79853adf0dea0a8118f259e5cfa6e (patch) (side-by-side diff)
treeefb2049ff2f8e4ef952987e97cbf5179f3fe7bf6 /src
parent8981940c41b9107a8bb387433cd0c7a6408bf03e (diff)
downloadellinika-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') (more/less context) (ignore whitespace changes)
-rw-r--r--src/cgi-bin/conj.scm484
-rw-r--r--src/ellinika/conjugator.scm1
-rw-r--r--src/ellinika/tests/conj/uelv.scm1
3 files changed, 82 insertions, 4 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>&nbsp;&nbsp;~A</p>~%"
diff --git a/src/ellinika/conjugator.scm b/src/ellinika/conjugator.scm
index 069d641..8b689a4 100644
--- a/src/ellinika/conjugator.scm
+++ b/src/ellinika/conjugator.scm
@@ -538,7 +538,6 @@ AND i.tense=\"~A\" AND i.ident=f.ident"
(else
(list-head conj 6))))
-
(define-public (conjugation:class conj)
(cond
((not conj)
diff --git a/src/ellinika/tests/conj/uelv.scm b/src/ellinika/tests/conj/uelv.scm
index 9c031eb..1ac1f0c 100644
--- a/src/ellinika/tests/conj/uelv.scm
+++ b/src/ellinika/tests/conj/uelv.scm
@@ -1,3 +1,4 @@
(use-modules ((ellinika test-conjugation)))
(test-conjugation:verb "θέλω")
+;(test-conjugation:tense "θέλω" "act" "ind" "Παρατατικός") \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.