Improve dictionary generation time
modules/nani/result/jibiki.scm
281 | 281 | ('exemples #f)))) | |
282 | 282 | ||
283 | 283 | (define (create-parser frq) | |
284 | + | (define results '()) | |
284 | 285 | (ssax:make-parser | |
285 | 286 | NEW-LEVEL-SEED | |
286 | 287 | (lambda (elem-gi attributes namespaces expected-content seed) | |
… | |||
288 | 289 | ||
289 | 290 | FINISH-ELEMENT | |
290 | 291 | (lambda (elem-gi attributes namespaces parent-seed seed) | |
291 | - | (if (equal? elem-gi 'volume) | |
292 | - | (filter (lambda (a) a) seed) | |
293 | - | (let* ((seed (reverse seed)) | |
294 | - | (element (sxml->element seed elem-gi frq))) | |
295 | - | (cons element parent-seed)))) | |
292 | + | (cond | |
293 | + | ((equal? elem-gi 'volume) | |
294 | + | results) | |
295 | + | ((equal? elem-gi 'article) | |
296 | + | (set! results (cons seed results)) | |
297 | + | #f) | |
298 | + | (else | |
299 | + | (let* ((seed (reverse seed)) | |
300 | + | (element (sxml->element seed elem-gi frq))) | |
301 | + | (cons element parent-seed))))) | |
296 | 302 | ||
297 | 303 | CHAR-DATA-HANDLER | |
298 | 304 | (lambda (string1 string2 seed) |
modules/nani/result/jmdict.scm
408 | 408 | ('entry (sxml->result lst frq)))) | |
409 | 409 | ||
410 | 410 | (define (create-parser frq) | |
411 | + | (define results '()) | |
411 | 412 | (ssax:make-parser | |
412 | 413 | NEW-LEVEL-SEED | |
413 | 414 | (lambda (elem-gi attributes namespaces expected-content seed) | |
… | |||
421 | 422 | ||
422 | 423 | FINISH-ELEMENT | |
423 | 424 | (lambda (elem-gi attributes namespaces parent-seed seed) | |
424 | - | (if (equal? elem-gi 'JMdict) | |
425 | - | seed | |
426 | - | (let* ((seed (reverse seed)) | |
427 | - | (element (sxml->element seed elem-gi frq))) | |
428 | - | (cons element parent-seed)))) | |
425 | + | (cond | |
426 | + | ((equal? elem-gi 'JMdict) | |
427 | + | results) | |
428 | + | ((equal? elem-gi 'entry) | |
429 | + | (set! results (cons seed results)) | |
430 | + | #f) | |
431 | + | (else | |
432 | + | (let* ((seed (reverse seed)) | |
433 | + | (element (sxml->element seed elem-gi frq))) | |
434 | + | (cons element parent-seed))))) | |
429 | 435 | ||
430 | 436 | CHAR-DATA-HANDLER | |
431 | 437 | (lambda (string1 string2 seed) |
modules/nani/result/result.scm
199 | 199 | (when (not (result? result)) (throw 'not-result result)) | |
200 | 200 | (+ ((list-size (huffman-string-size kanji-huffman-code)) (result-kanjis result)) | |
201 | 201 | ((list-size (reading-size reading-huffman-code)) (result-readings result)) | |
202 | - | ((list-size (meaning-size meaning-huffman-code)) (result-meanings result))))) | |
202 | + | ((list-size (meaning-size meaning-huffman-code)) (result-meanings result)) | |
203 | + | (char-size (result-score result))))) | |
203 | 204 | ||
204 | 205 | ;; creating tries | |
205 | 206 | (define (make-key key) | |
… | |||
317 | 318 | (trie-node-size reading-trie)) | |
318 | 319 | (format #t "Number of nodes in meanings: ~a~%" | |
319 | 320 | (trie-node-size meaning-trie)) | |
321 | + | (format #t "First trie is at ~a~%" pos-kanji) | |
320 | 322 | ((serialize-list (serialize-result kanji-huffman-code reading-huffman-code | |
321 | 323 | meaning-huffman-code) | |
322 | 324 | #:size? #f) | |
… | |||
385 | 387 | (cond | |
386 | 388 | ((> (result-score a) (result-score b)) #t) | |
387 | 389 | ((= (result-score a) (result-score b)) | |
388 | - | (string>? (get-string a) (get-string b))))))) | |
390 | + | (string<? (get-string a) (get-string b))) | |
391 | + | ((< (result-score a) (result-score b)) #f))))) |
modules/nani/result/wadoku.scm
450 | 450 | ('gramGrp (gram->info lst))))) | |
451 | 451 | ||
452 | 452 | (define (create-parser frq) | |
453 | + | (define results '()) | |
453 | 454 | (ssax:make-parser | |
454 | 455 | NEW-LEVEL-SEED | |
455 | 456 | (lambda (elem-gi attributes namespaces expected-content seed) | |
… | |||
457 | 458 | ||
458 | 459 | FINISH-ELEMENT | |
459 | 460 | (lambda (elem-gi attributes namespaces parent-seed seed) | |
460 | - | (if (equal? elem-gi 'entries) | |
461 | - | seed | |
462 | - | (let* ((seed (reverse seed)) | |
463 | - | (element (sxml->element seed elem-gi frq))) | |
464 | - | (cons element parent-seed)))) | |
461 | + | (cond | |
462 | + | ((equal? elem-gi 'entries) | |
463 | + | results) | |
464 | + | ((equal? elem-gi 'entry) | |
465 | + | (set! results (cons seed results)) | |
466 | + | #f) | |
467 | + | (else | |
468 | + | (let* ((seed (reverse seed)) | |
469 | + | (element (sxml->element seed elem-gi frq))) | |
470 | + | (cons element parent-seed))))) | |
465 | 471 | ||
466 | 472 | CHAR-DATA-HANDLER | |
467 | 473 | (lambda (string1 string2 seed) |