aboutsummaryrefslogtreecommitdiff
path: root/cgi-bin/dict.cgi.in
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/dict.cgi.in')
-rw-r--r--cgi-bin/dict.cgi.in60
1 files changed, 39 insertions, 21 deletions
diff --git a/cgi-bin/dict.cgi.in b/cgi-bin/dict.cgi.in
index ca5984c..a327be7 100644
--- a/cgi-bin/dict.cgi.in
+++ b/cgi-bin/dict.cgi.in
@@ -108,22 +108,39 @@
(cons "?" arglist))))))
;; Τα μέρη του λογου
-(define part-of-speech
- (list (cons "κανένα μέρος του λόγου" #f)
- (cons "ρήμα" "(dict.pos=\"μετ.\" OR dict.pos=\"αμετ.\" OR dict.pos=\"μετ.,αμετ.\" OR dict.pos=\"απρόσ.\")")
- (cons "μεταβατικό" "dict.pos=\"μετ.\"")
- (cons "αμετάβατο" "dict.pos=\"αμετ.\"")
- (cons "άρθρο" "dict.pos=\"άρθρο\"")
- (cons "αριθμός" "dict.pos=\"αριθ.\"")
- (cons "επίθετο" "dict.pos=\"επίθ.\"")
- (cons "επίρρημα" "dict.pos=\"επίρρ.\"")
- (cons "επιφώνημα" "dict.pos=\"επιφ.\"")
- (cons "μετοχή" "dict.pos=\"μετοχή\"")
- (cons "μόριο" "dict.pos=\"μόριο\"")
- (cons "πρόθεση" "dict.pos=\"πρόθ.\"")
- (cons "σύνδεσμος" "dict.pos=\"σύνδ.\"")
- (cons "ουσιαστικό" "(dict.pos=\"ο\" OR dict.pos=\"η\" OR dict.pos=\"το\")")))
+(define part-of-speech '())
+(define (hbase num)
+ (do ((i 0 (1+ i))
+ (n num (ash n -1)))
+ ((= n 0) (ash 1 (- i 1)))))
+
+(define (load-pos)
+ (let ((conn (sql-connect
+ sql-iface sql-host sql-port sql-database
+ sql-username sql-password)))
+ (cond
+ (conn
+ (let ((plist (sql-query
+ conn
+ "SELECT name,id FROM pos WHERE canonical='Y' order by id")))
+ (set! part-of-speech
+ (cons
+ (cons "κανένα μέρος του λόγου" #f)
+ (map
+ (lambda (x)
+ (let* ((value (string->number (car (cdr x))))
+ (mask (hbase value)))
+ (cons (car x)
+ (number->string
+ (if (= value mask)
+ value
+ (logand
+ value
+ (lognot mask)))))))
+ plist)))
+ (sql-connect-close conn))))))
+
;; Protect occurences of " in a string.
;; Usual backslash escapes do not work in INPUT widgets, so I
;; change all quotation marks to "
@@ -151,6 +168,7 @@
(define (main-form)
+ (load-pos)
(display "<FORM ACTION=\"")
(display (make-cgi-name))
(display "\" METHOD=POST>
@@ -673,7 +691,7 @@
(cond
((> (string->number theme) 0)
(string-append
- "SELECT dict.word FROM dict,topic_tab WHERE "
+ "SELECT DISTINCT dict.word FROM dict,topic_tab WHERE "
(cond
((not (string-null? key))
(string-append "dict.sound LIKE \""
@@ -687,19 +705,19 @@
(if (> (string->number pos) 0)
(let ((pos-entry
(list-ref part-of-speech (string->number pos))))
- (string-append "AND "
+ (string-append "AND dict.pos & "
(cdr pos-entry)))
"")
" order by word"))
(else
(string-append
- "SELECT word FROM dict WHERE sound like \""
+ "SELECT DISTINCT word FROM dict WHERE sound like \""
(greek-to-transcription key)
"%\" "
(if (> (string->number pos) 0)
(let ((pos-entry (list-ref part-of-speech
(string->number pos))))
- (string-append "AND "
+ (string-append "AND dict.pos &"
(cdr pos-entry)))
"")
" ORDER BY WORD"))))))
@@ -746,9 +764,9 @@
(result (sql-query
conn
(string-append
- "SELECT dict.word,dict.ident,dict.pos,dict.forms,articles.subindex,articles.meaning from dict,articles where dict.word=\""
+ "SELECT dict.word,dict.ident,pos.abbr,dict.forms,articles.subindex,articles.meaning FROM dict,articles,pos WHERE dict.word=\""
key
- "\" and dict.ident=articles.ident order by dict.ident, articles.subindex"))))
+ "\" and dict.ident=articles.ident and dict.pos=pos.id and pos.canonical='Y' order by dict.ident, articles.subindex"))))
(cond
((null? result)

Return to:

Send suggestions and report system problems to the System administrator.