summaryrefslogtreecommitdiffabout
path: root/src/ellinika
authorSergey Poznyakoff <gray@gnu.org.ua>2011-06-15 07:05:10 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-06-15 07:24:46 (GMT)
commitbb9dd8a54a96307aad7bf976f1736d20c70d43e3 (patch) (side-by-side diff)
treedf632e2c76facc932c4c34978eba4b9ae4cb0354 /src/ellinika
parenta27881a1c5bd7d8f8f42cd6526adf80815acfe63 (diff)
downloadellinika-bb9dd8a54a96307aad7bf976f1736d20c70d43e3.tar.gz
ellinika-bb9dd8a54a96307aad7bf976f1736d20c70d43e3.tar.bz2
Implement web conjugator.
* src/cgi-bin/.gitignore: Update. * src/cgi-bin/Makefile.am: Build conj,cgi * src/cgi-bin/conj.scm4: New file. * src/cgi-bin/dict.scm4 (protect): Move to cgi.scm, function cgi-protect-quotes. All uses updated. * src/ellinika/cgi.scm4 (cgi-protect-quotes): New function. * src/ellinika/Makefile.am (guile_DATA): Add conjugator.scm * src/ellinika/conjugator.scm: Minor fixes. * src/ellinika/sql.scm (->string): Fix typo. * src/ellinika/tenses.scm (ellinika-conjugation-term-transtab): New var. (ellinika-conjugation-term): New function. * src/ellinika/test-conjugation.scm: Use ellinika-conjugation-term instead of (term). * xml/lingua.conf.in (install-conj): New macro. * xml/pl/ellinika.xml (GUILE): Call install-conj. * xml/pl/rhmata.xml: Define conjugator template page.
Diffstat (limited to 'src/ellinika') (more/less context) (ignore whitespace changes)
-rw-r--r--src/ellinika/Makefile.am3
-rw-r--r--src/ellinika/cgi.scm415
-rw-r--r--src/ellinika/conjugator.scm36
-rw-r--r--src/ellinika/sql.scm2
-rw-r--r--src/ellinika/tenses.scm13
-rw-r--r--src/ellinika/test-conjugation.scm14
6 files changed, 51 insertions, 32 deletions
diff --git a/src/ellinika/Makefile.am b/src/ellinika/Makefile.am
index 581a537..01534c0 100644
--- a/src/ellinika/Makefile.am
+++ b/src/ellinika/Makefile.am
@@ -23,7 +23,8 @@ guile_DATA=\
dico.scm\
elmorph.scm\
tenses.scm\
- sql.scm
+ sql.scm\
+ conjugator.scm
cgi.m4: Makefile
echo 'divert(-1)' > $@
diff --git a/src/ellinika/cgi.scm4 b/src/ellinika/cgi.scm4
index c7fbdb6..8cbfeca 100644
--- a/src/ellinika/cgi.scm4
+++ b/src/ellinika/cgi.scm4
@@ -165,4 +165,19 @@ THUNK.
(if x
(set! target-language x))))
+;; Protect occurences of " in a string.
+;; Usual backslash escapes do not work in INPUT widgets, so I
+;; change all quotation marks to &#34;
+;; Possibly not the better solution, though...
+(define-public (cgi-protect-quotes string)
+ (list->string
+ (apply append
+ (map
+ (lambda (x)
+ (if (eq? x #\")
+ (list #\& #\# #\3 #\4 #\;)
+ (list x)))
+ (string->list string)))))
+
+
;;; End of cgi.scmi
diff --git a/src/ellinika/conjugator.scm b/src/ellinika/conjugator.scm
index 0079d12..41575c2 100644
--- a/src/ellinika/conjugator.scm
+++ b/src/ellinika/conjugator.scm
@@ -77,23 +77,23 @@
(define (create-basic-verb-info verb proplist . rest)
; (format #t "PROPLIST ~A~%" proplist)
- (let ((class (if (null? rest)
- ""
- (string-append
- " AND conj=\"" (utf8-escape (car rest)) "\""))))
- (let ((vdb (ellinika:sql-query
- "SELECT conj FROM verbclass WHERE verb=\"~A\"~A"
- verb class)))
- (cond
- ((and vdb (not (null? vdb)))
- (list (caar vdb) verb proplist '(class)))
- ((elstr-suffix? verb "άω")
- (create-basic-verb-info (elstr-append
- (elstr-trim verb -2) "ώ") "B1"))
- ((null? rest)
- (list (guess-verb-class verb) verb proplist '()))
- (else
- (list (car rest) verb '() '()))))))
+ (let ((vdb (if (null? rest)
+ (ellinika:sql-query
+ "SELECT conj FROM verbclass WHERE verb=\"~A\""
+ verb)
+ (ellinika:sql-query
+ "SELECT conj FROM verbclass WHERE verb=\"~A\" AND conj=~Q"
+ verb (car rest)))))
+ (cond
+ ((and vdb (not (null? vdb)))
+ (list (caar vdb) verb proplist '(class)))
+ ((elstr-suffix? verb "άω")
+ (create-basic-verb-info (elstr-append
+ (elstr-trim verb -2) "ώ") proplist "B1"))
+ ((null? rest)
+ (list (guess-verb-class verb) verb proplist '()))
+ (else
+ (list (car rest) verb '() '())))))
(define (load-verb-info verb voice mood tense)
; (format #t "LOAD ~A~%" verb)
@@ -181,7 +181,7 @@ WHERE verb=\"~A\" AND voice=\"~A\" AND thema=\"~A\""
(error "cannot handle ~A~%" verb))))
(define (complement-verb-info vinfo verb voice thema)
-; (format #t "COMPLEMENT ~A~%" thema)
+; (format #t "COMPLEMENT ~A~%" vinfo)
(let ((elverb (string->elstr verb))
(result (let ((tmpres (lookup-verb-info verb voice thema)))
(if (and (null? tmpres) (string=? thema "sub"))
diff --git a/src/ellinika/sql.scm b/src/ellinika/sql.scm
index f49ddf1..5867d28 100644
--- a/src/ellinika/sql.scm
+++ b/src/ellinika/sql.scm
@@ -42,7 +42,7 @@
(define (->string arg)
(cond
((string? arg) arg)
- ((elstr? arg) (elstr->string? arg))
+ ((elstr? arg) (elstr->string arg))
((number? arg) (number->string arg))
((bool? arg) (if arg "true" "false"))
(else
diff --git a/src/ellinika/tenses.scm b/src/ellinika/tenses.scm
index f830870..137cfff 100644
--- a/src/ellinika/tenses.scm
+++ b/src/ellinika/tenses.scm
@@ -35,4 +35,15 @@
(list "Ενεστώτας"
"Αόριστος"
"Παρακείμενος"))))
- \ No newline at end of file
+
+(define-public ellinika-conjugation-term-transtab
+ '(("act" . "Ενεργητηκή φωνή")
+ ("pas" . "Μεσοπαθητική φωνή")
+ ("ind" . "Οριστική")
+ ("sub" . "Υποτακτική")
+ ("imp" . "Προστακτική")))
+
+(define-public (ellinika-conjugation-term x)
+ (or (assoc-ref ellinika-conjugation-term-transtab x) x))
+
+
diff --git a/src/ellinika/test-conjugation.scm b/src/ellinika/test-conjugation.scm
index 055138b..1504553 100644
--- a/src/ellinika/test-conjugation.scm
+++ b/src/ellinika/test-conjugation.scm
@@ -27,20 +27,12 @@
(ellinika-cgi-init dict-template-file-name)
(ellinika:sql-connect ellinika-sql-connection)
-(define transtab
- '(("act" . "Ενεργητηκή φωνή")
- ("pas" . "Μεσοπαθητική φωνή")
- ("ind" . "Οριστική")
- ("sub" . "Υποτακτική")
- ("imp" . "Προστακτική")))
-
-(define (term x)
- (or (assoc-ref transtab x) x))
-
(define-public (test-conjugation:tense verb voice mood tense)
(for-each
(lambda (result)
- (format #t "~A ~A/~A/~A: " verb (term voice) (term mood) tense)
+ (format #t "~A ~A/~A/~A: " verb
+ (ellinika-conjugation-term voice)
+ (ellinika-conjugation-term mood) tense)
(let ((conj (conjugation:table result)))
(cond
((empty-conjugation? conj)

Return to:

Send suggestions and report system problems to the System administrator.