aboutsummaryrefslogtreecommitdiff
path: root/cgi-bin
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2004-06-19 17:16:12 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2004-06-19 17:16:12 +0000
commit0e8ee6746d944ca4e963c3db7d9fcc151817dd04 (patch)
tree30bc9062b9ca2fdfbd0e2ef170a15652f9678814 /cgi-bin
parent8584636b72b0151c01b03bf9ef66dcc15682cc4e (diff)
downloadellinika-0e8ee6746d944ca4e963c3db7d9fcc151817dd04.tar.gz
ellinika-0e8ee6746d944ca4e963c3db7d9fcc151817dd04.tar.bz2
Reflect changes to the database structure.
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@145 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'cgi-bin')
-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 &#34;
@@ -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.