summaryrefslogtreecommitdiffabout
path: root/scm/dictrans.scm
authorSergey Poznyakoff <gray@gnu.org.ua>2006-03-17 20:00:42 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2006-03-17 20:00:42 (GMT)
commitd1880fada241c00b42f883c3a34e9becaaa64796 (patch) (side-by-side diff)
tree03a2bdf46ced05908734343238a1ac8aa7535f7e /scm/dictrans.scm
parent72a22b4e3a0d32c1e741e5c625eed8d142531ef5 (diff)
downloadellinika-d1880fada241c00b42f883c3a34e9becaaa64796.tar.gz
ellinika-d1880fada241c00b42f883c3a34e9becaaa64796.tar.bz2
(DICT): Mandatory attribute LANG.
(update-stat): Rewrite to match new table structure. (check-node,insert-node): Take destination language code as 3rd argument. All callers changed. git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@363 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'scm/dictrans.scm') (more/less context) (ignore whitespace changes)
-rw-r--r--scm/dictrans.scm52
1 files changed, 35 insertions, 17 deletions
diff --git a/scm/dictrans.scm b/scm/dictrans.scm
index 39791fd..115ea58 100644
--- a/scm/dictrans.scm
+++ b/scm/dictrans.scm
@@ -298,7 +298,7 @@
(begin
(write node)
(newline)))
- (set! node-list (cons current-node node-list)))
+ (set! node-list (cons node node-list)))
;;; Topic stack
(define topic-list '())
@@ -334,6 +334,10 @@
(xmltrans:start-tag
"DICT"
(tag attr)
+ (let ((lang (xmltrans:attr attr "LANG")))
+ (if (not lang)
+ (xmltrans:parse-error #f "Required attribute LANG not specified"))
+ (push-node lang))
#f)
(xmltrans:end-tag
@@ -686,13 +690,18 @@
(current-error-port)))))
(define (update-stat conn)
- (let ((count (query-number conn "SELECT count(*) from dict")))
- (run-query conn "DELETE from stat");
- (run-query conn
- (string-append
- "INSERT INTO stat (count,updated) VALUES("
- (number->string count)
- ",now())"))))
+ (run-query conn "DELETE FROM stat")
+ (for-each
+ (lambda (res)
+ (run-query conn
+ (string-append
+ "INSERT INTO stat (lang,count,updated) VALUES('"
+ (list-ref res 0) "',"
+ (list-ref res 1)
+ ",now())")))
+ (run-query
+ conn
+ "SELECT articles.lang,count(distinct dict.word) FROM dict,articles WHERE dict.ident=articles.ident GROUP BY 1")))
;;; Insert (or update) topics and topic categories
(define (insert-categories conn)
@@ -732,7 +741,7 @@
;;;
(define dict-index 0)
-(define (check-node conn node)
+(define (check-node conn node lang)
(call-with-current-continuation
(lambda (return)
(for-each
@@ -761,7 +770,7 @@
(node-get #:p-list node))
#t)))
-(define (insert-node conn node)
+(define (insert-node conn node lang)
(letrec ((insert-link (lambda (type value)
(run-query
conn
@@ -853,9 +862,10 @@
(run-query
conn
(format #f
- "INSERT INTO articles VALUES (~A, ~A, \"~A\")"
+ "INSERT INTO articles VALUES (~A, ~A, '~A', \"~A\")"
dict-index
article-index
+ lang
text))
(set! article-index (1+ article-index)))
(p-article-get #:article p-article)))))
@@ -991,12 +1001,20 @@ Informational options:
(get-dict-index conn)
(insert-categories conn)
-
- (for-each
- (lambda (node)
- (and (check-node conn node)
- (insert-node conn node)))
- (reverse node-list))
+
+ (let ((lang #f))
+ (for-each
+ (lambda (node)
+ (cond
+ ((string? node)
+ (set! lang node))
+ ((vector? node)
+ (and (check-node conn node lang)
+ (insert-node conn node lang)))
+ (else
+ (display "Unexpected node type!\n")
+ (exit 1))))
+ (reverse node-list)))
(pending-fixup conn)
(update-stat conn)

Return to:

Send suggestions and report system problems to the System administrator.