Revision: 6820
Author: deton.kih
Date: Mon Nov 22 20:52:41 2010
Log: * Add input prediction in bushu conversion.
* NEWS
- Add news.
* scm/tutcode-custom.scm
- (tutcode-use-bushu-prediction?): New custom.
* scm/tutcode.scm
- (tutcode-context-rec-spec): Add variables for bushu prediction.
- (tutcode-commit-by-label-key-for-prediction):
Change parameter completion? to mode to support bushu prediction.
- (tutcode-proc-state-on):
Follow change of tutcode-commit-by-label-key-for-prediction.
- (tutcode-proc-state-yomi): Ditto.
- (tutcode-proc-state-bushu): Change for bushu prediction.
- (tutcode-begin-bushu-conversion, tutcode-bushu-commit):
Extract from tutcode-proc-state-bushu to use from
tutcode-do-commit-prediction-for-bushu.
- (tutcode-get-candidate-handler): Change for bushu prediction.
- (tutcode-lib-set-bushu-prediction,
tutcode-guide-set-candidates-for-bushu,
tutcode-do-commit-prediction-for-bushu,
tutcode-check-bushu-prediction,
tutcode-bushu-prediction-show-page,
tutcode-change-bushu-prediction-page,
tutcode-bushu-predict): New function.
http://code.google.com/p/uim/source/detail?r=6820
Modified:
/trunk/NEWS
/trunk/scm/tutcode-custom.scm
/trunk/scm/tutcode.scm
=======================================
--- /trunk/NEWS Thu Nov 18 13:57:19 2010
+++ /trunk/NEWS Mon Nov 22 20:52:41 2010
@@ -4,6 +4,7 @@
- uim-tutcode
* Completion
* Input prediction in mazegaki conversion
+ * Input prediction in bushu conversion
* Kanji combination guide on completion and input prediction
* Add function to redisplay last auto help
* Show kanji on auto help
=======================================
--- /trunk/scm/tutcode-custom.scm Fri Nov 5 20:11:05 2010
+++ /trunk/scm/tutcode-custom.scm Mon Nov 22 20:52:41 2010
@@ -212,6 +212,12 @@
(N_ "Enable Kanji combination guide")
(N_ "long description will be here."))
+(define-custom 'tutcode-use-bushu-prediction? #f
+ '(tutcode tutcode-prediction)
+ '(boolean)
+ (N_ "Enable input prediction for bushu conversion")
+ (N_ "long description will be here."))
+
;; activity dependency
(custom-add-hook 'tutcode-candidate-op-count
'custom-activity-hooks
=======================================
--- /trunk/scm/tutcode.scm Fri Nov 19 04:32:36 2010
+++ /trunk/scm/tutcode.scm Mon Nov 22 20:52:41 2010
@@ -510,6 +510,7 @@
;;; 'tutcode-predicting-off Êä´°/ͽ¬ÆþÎϤθõÊäÁªÂòÃæ¤Ç¤Ê¤¤
;;; 'tutcode-predicting-completion Êä´°¸õÊäÁªÂòÃæ
;;; 'tutcode-predicting-prediction ¸ò¤¼½ñ¤ÊÑ´¹»þ¤Îͽ¬ÆþÎϸõÊäÁªÂòÃæ
+ ;;; 'tutcode-predicting-bushu Éô¼ó¹çÀ®ÊÑ´¹»þ¤Îͽ¬ÆþÎϸõÊäÁªÂòÃæ
(predicting 'tutcode-predicting-off)
;;; Êä´°/ͽ¬ÆþÎÏÍÑ¥³¥ó¥Æ¥¥¹¥È
(prediction-ctx ())
@@ -531,6 +532,10 @@
(prediction-page-limit
(+ tutcode-nr-candidate-max-for-prediction
tutcode-nr-candidate-max-for-guide))
+ ;;; Éô¼ó¹çÀ®ÊÑ´¹¤Îͽ¬¸õÊä
+ (prediction-bushu ())
+ ;;; Éô¼ó¹çÀ®ÊÑ´¹¤Îͽ¬¸õÊä¤Î¸½ºß¤Îɽ¼¨¥Ú¡¼¥¸¤ÎºÇ½é¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹ÈÖ¹æ
+ (prediction-bushu-page-start 0)
;;; ½Ï¸ì¥¬¥¤¥É¡£Êä´°/ͽ¬ÆþÎÏ»þ¤Îɽ¼¨ÍÑ¡£
;;; ͽ¬¤µ¤ì¤ë¼¡¤ÎÆþÎÏ´Á»ú¤ÎÂè1ÂǸ°¤ÈÆþÎÏ´Á»ú¤ÎÂбþ¤Î¥ê¥¹¥È¡£
;;; Îã: (("," "ÀÐ") ("u" "²°" "ÃÓ"))
@@ -595,6 +600,43 @@
(tutcode-context-set-prediction-appendix! pc filtered-appendix)
(tutcode-context-set-prediction-nr! pc (length filtered-cands))
word))
+
+;;; Éô¼ó¹çÀ®ÊÑ´¹»þ¤Îͽ¬ÆþÎϸõÊä¤òÀßÄê
+;;; @param start-index ³«»ÏÈÖ¹æ
+(define (tutcode-lib-set-bushu-prediction pc start-index)
+ ;; ³«»ÏÈֹ椫¤é»Ï¤Þ¤ë1¥Ú¡¼¥¸¤Ö¤ó¤Î¸õÊä¤À¤±¤ò¼è¤ê½Ð¤·¤Æ»ÈÍÑ¡£
+ ;; Á´¤Æ»ÈÍѤ¹¤ë¤È¡¢½Ï¸ì¥¬¥¤¥É¤Î¥é¥Ù¥ëʸ»úÎó¤¬Ä¹¤¯¤Ê¤Ã¤Æ²£Éý¤¬¹¤¬¤ê¤¹¤®¡¢
+ ;; ¥¦¥£¥ó¥É¥¦¤Ë¼ý¤Þ¤é¤Ê¤¯¤Ê¤ë¾ì¹ç¤¬¤¢¤ë¤Î¤Ç(¸õÊä¿ô200°Ê¾å¤Î¾ì¹ç¤Ê¤É)¡£
+ ;; (½Ï¸ì¥¬¥¤¥É¤ò¡¢É½¼¨Ãæ¤Î¸õÊä¤À¤±¤«¤éºî¤ëÊýË¡¤â¤¢¤ë¤¬¡¢
+ ;; ¤½¤Î¾ì¹ç¡¢½Ï¸ì¥¬¥¤¥É¤Î¿ô¤¬¡¢¥Ú¡¼¥¸¤´¤È¤ËÊѤï¤Ã¤Æ¤·¤Þ¤¦¤¿¤á¡¢
+ ;; ¸½¾õ¤Î¸õÊ䥦¥£¥ó¥É¥¦(¥Ú¡¼¥¸¤´¤È¤Îɽ¼¨¸õÊä¿ô¤¬ÊѤï¤é¤Ê¤¤¤³¤È¤òÁÛÄê)
+ ;; ¤Ç¤Îɽ¼¨¤ËÌäÂ꤬ȯÀ¸)
+ (let* ((ret (tutcode-context-prediction-bushu pc))
+ (all-len (length ret))
+ (start
+ (cond
+ ((>= start-index all-len)
+ (tutcode-context-prediction-bushu-page-start pc))
+ ((< start-index 0)
+ 0)
+ (else
+ start-index)))
+ (end (+ start tutcode-nr-candidate-max-for-prediction))
+ (cnt
+ (if (< end all-len)
+ tutcode-nr-candidate-max-for-prediction
+ (- all-len start)))
+ (page-word/cand (take (drop ret start) cnt))
+ (page-word (map (lambda (elem) (car elem)) page-word/cand))
+ (page-cands (map (lambda (elem) (cadr elem)) page-word/cand))
+ (len (length page-cands))
+ (appendix (make-list len "")))
+ (tutcode-context-set-prediction-bushu-page-start! pc start)
+ (tutcode-context-set-prediction-word! pc page-word)
+ (tutcode-context-set-prediction-candidates! pc page-cands)
+ (tutcode-context-set-prediction-appendix! pc appendix)
+ (tutcode-context-set-prediction-nr! pc len)))
+
(define (tutcode-lib-get-nr-predictions pc)
(tutcode-context-prediction-nr pc))
(define (tutcode-lib-get-nth-word pc nth)
@@ -685,6 +727,25 @@
(tutcode-context-set-guide! pc label-cands-alist)
(tutcode-context-set-guide-chars! pc filtered-cand-stroke)))
+;;; ½Ï¸ì¥¬¥¤¥Éɽ¼¨ÍѸõÊä¥ê¥¹¥È¤òÉô¼ó¹çÀ®Í½Â¬ÆþÎϸõÊ䤫¤éºîÀ®¤¹¤ë
+;;; @param str Éô¼ó¹çÀ®Í½Â¬ÆþÎϸõÊä¤Î¸¡º÷»þ¤Ë»ÈÍѤ·¤¿´Á»ú=ÆþÎϺѴÁ»ú
+(define (tutcode-guide-set-candidates-for-bushu pc)
+ (let* ((word (tutcode-context-prediction-word pc))
+ (cand-stroke
+ (map
+ (lambda (elem)
+ (list (list (tutcode-reverse-find-seq elem)) (list elem)))
+ word))
+ (filtered-cand-stroke
+ (filter
+ (lambda (elem)
+ (pair? (caar elem))) ; ¥³¡¼¥Éɽ¤Ë̵¤¤³°»ú¤Ï½ü¤¯
+ cand-stroke))
+ (label-cands-alist
+ (tutcode-guide-update-alist () filtered-cand-stroke)))
+ (tutcode-context-set-guide! pc label-cands-alist)
+ (tutcode-context-set-guide-chars! pc filtered-cand-stroke)))
+
;;; ½Ï¸ì¥¬¥¤¥É¤Îɽ¼¨¤Ë»È¤¦alist¤ò¹¹¿·¤¹¤ë¡£
;;; alist¤Ï°Ê²¼¤Î¤è¤¦¤Ë¥é¥Ù¥ëʸ»ú¤È´Á»ú¤Î¥ê¥¹¥È¡£
;;; Îã: (("," "ÀÐ") ("u" "²°" "ÃÓ"))
@@ -1002,7 +1063,9 @@
(tutcode-prepare-commit-string-for-kigou-mode pc))))))
;;; Êä´°/ͽ¬ÆþÎϸõÊäɽ¼¨»þ¤Ë¡¢»ØÄꤵ¤ì¤¿¥é¥Ù¥ëʸ»ú¤ËÂбþ¤¹¤ë¸õÊä¤ò³ÎÄꤹ¤ë
-(define (tutcode-commit-by-label-key-for-prediction pc ch completion?)
+;;; @param ch ÆþÎϤµ¤ì¤¿¥é¥Ù¥ëʸ»ú
+;;; @param mode tutcode-context-predicting¤ÎÃÍ
+(define (tutcode-commit-by-label-key-for-prediction pc ch mode)
(let*
((nth (tutcode-context-prediction-index pc))
(page-limit (tutcode-context-prediction-page-limit pc))
@@ -1028,7 +1091,10 @@
(if (>= i 0)
(begin
(tutcode-context-set-prediction-index! pc i)
- (tutcode-do-commit-prediction pc completion?)))))
+ (if (eq? mode 'tutcode-predicting-bushu)
+ (tutcode-do-commit-prediction-for-bushu pc)
+ (tutcode-do-commit-prediction pc
+ (eq? mode 'tutcode-predicting-completion)))))))
(define (tutcode-get-prediction-string pc)
(tutcode-lib-get-nth-prediction
@@ -1041,6 +1107,8 @@
(tutcode-context-prediction-index pc)
completion?))
+;;; Êä´°/ͽ¬ÆþÎϸõÊä¤ò³ÎÄꤹ¤ë
+;;; @param completion? Êä´°¤«¤É¤¦¤«
(define (tutcode-do-commit-prediction pc completion?)
(let ((str (tutcode-get-prediction-string pc)))
(tutcode-learn-prediction-string pc completion?)
@@ -1049,6 +1117,12 @@
(tutcode-flush pc)
(tutcode-check-auto-help-window-begin pc (string-to-list str) ())))
+;;; Éô¼ó¹çÀ®ÊÑ´¹»þ¤Îͽ¬ÆþÎϸõÊä¤ò³ÎÄꤹ¤ë
+(define (tutcode-do-commit-prediction-for-bushu pc)
+ (let ((str (tutcode-get-prediction-string pc)))
+ (tutcode-reset-candidate-window pc)
+ (tutcode-bushu-commit pc str)))
+
;;; ¸ò¤¼½ñ¤ÊÑ´¹¼½ñ¤«¤é¡¢¸½ºßÁªÂò¤µ¤ì¤Æ¤¤¤ë¸õÊä¤òºï½ü¤¹¤ë¡£
(define (tutcode-purge-candidate pc)
(let ((res (skk-lib-purge-candidate
@@ -1698,6 +1772,48 @@
(im-activate-candidate-selector pc nr-all
page-limit))))))
(tutcode-reset-candidate-window pc)))))
+;;; Éô¼ó¹çÀ®ÊÑ´¹Ãæ¤Ëͽ¬ÆþÎϸõÊä¤ò¸¡º÷¤·¤Æ¸õÊ䥦¥£¥ó¥É¥¦¤Ëɽ¼¨¤¹¤ë
+;;; @param char ÆþÎϤµ¤ì¤¿Éô¼ó1
+(define (tutcode-check-bushu-prediction pc char)
+ (if (eq? (tutcode-context-predicting pc) 'tutcode-predicting-off)
+ (let* ((res (tutcode-bushu-predict char tutcode-bushudic))
+ (alt (assoc char tutcode-bushudic-altchar))
+ (altres
+ (if alt
+ (tutcode-bushu-predict (cadr alt) tutcode-bushudic)
+ ()))
+ (resall (append res altres)))
+ (tutcode-context-set-prediction-bushu! pc resall)
+ (tutcode-bushu-prediction-show-page pc 0))))
+
+;;;
Éô¼ó¹çÀ®ÊÑ´¹¤Îͽ¬ÆþÎϸõÊä¤Î¤¦¤Á¡¢»ØÄꤵ¤ì¤¿Èֹ椫¤é»Ï¤Þ¤ë¸õÊä¤òɽ¼¨¤¹¤ë¡£
+;;; @param start-index ³«»ÏÈÖ¹æ
+(define (tutcode-bushu-prediction-show-page pc start-index)
+ (tutcode-lib-set-bushu-prediction pc start-index)
+ (let ((nr (tutcode-lib-get-nr-predictions pc)))
+ (if (and nr (> nr 0))
+ (let*
+ ((nr-guide
+ (if tutcode-use-kanji-combination-guide?
+ (begin
+ (tutcode-guide-set-candidates-for-bushu pc)
+ (length (tutcode-context-guide pc)))
+ 0))
+ (res (tutcode-prediction-calc-window-param nr nr-guide))
+ (nr-all (list-ref res 0)) ; Á´¸õÊä¿ô(ͽ¬¸õÊä+½Ï¸ì¥¬¥¤¥É)
+ (page-limit (list-ref res 1)) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬+½Ï¸ì)
+ (nr-in-page (list-ref res 2))) ; ¥Ú¡¼¥¸Æâ¸õÊä¿ô(ͽ¬¸õÊä¤Î¤ß)
+ (if (> page-limit 0)
+ (begin
+ (tutcode-context-set-prediction-nr-in-page! pc nr-in-page)
+ (tutcode-context-set-prediction-page-limit! pc page-limit)
+ (tutcode-context-set-prediction-nr-all! pc nr-all)
+ (tutcode-context-set-prediction-index! pc 0)
+ (tutcode-context-set-candidate-window! pc
+ 'tutcode-candidate-window-predicting)
+ (tutcode-context-set-predicting! pc 'tutcode-predicting-bushu)
+ (im-activate-candidate-selector pc nr-all page-limit)))))))
+
;;; Êä´°¸õÊä¤È½Ï¸ì¥¬¥¤¥Éɽ¼¨¤Î¤¿¤á¤ÎcandwinÍѥѥé¥á¡¼¥¿¤ò·×»»¤¹¤ë
;;; @param nr Êä´°¸õÊä¿ô
;;; @param nr-guide ½Ï¸ì¥¬¥¤¥É¸õÊä¿ô
@@ -1851,7 +1967,7 @@
;; Êä´°¸õÊäÍÑ¥é¥Ù¥ë¥¡¼?
((and completing? (tutcode-heading-label-char-for-prediction?
key))
(tutcode-commit-by-label-key-for-prediction pc
- (charcode->string key) #t))
+ (charcode->string key) 'tutcode-predicting-completion))
;; Àµ¤·¤¯¤Ê¤¤¥¡¼¥·¡¼¥±¥ó¥¹¤ÏÁ´¤Æ¼Î¤Æ¤ë(tc2¤Ë¹ç¤ï¤»¤¿Æ°ºî)¡£
;; (rk-push-key!¤¹¤ë¤È¡¢ÅÓÃæ¤Þ¤Ç¤Î¥·¡¼¥±¥ó¥¹¤Ï¼Î¤Æ¤é¤ì¤ë¤¬¡¢
;; ´Ö°ã¤Ã¤¿¥¡¼¤Ï»Ä¤Ã¤Æ¤·¤Þ¤¦¤Î¤Ç¡¢rk-push-key!¤Ï»È¤¨¤Ê¤¤)
@@ -2031,7 +2147,7 @@
;; ͽ¬ÆþÎϸõÊäÍÑ¥é¥Ù¥ë¥¡¼?
((and predicting? (tutcode-heading-label-char-for-prediction?
key))
(tutcode-commit-by-label-key-for-prediction pc
- (charcode->string key) #f))
+ (charcode->string key) 'tutcode-predicting-prediction))
((not (rk-expect-key? rkc (charcode->string key)))
(if (> (length (rk-context-seq rkc)) 0)
(rk-flush rkc)
@@ -2070,9 +2186,12 @@
;;; @param key ÆþÎϤµ¤ì¤¿¥¡¼
;;; @param key-state ¥³¥ó¥È¥í¡¼¥ë¥¡¼Åù¤Î¾õÂÖ
(define (tutcode-proc-state-bushu c key key-state)
- (let* ((pc (tutcode-find-descendant-context c))
- (rkc (tutcode-context-rk-context pc))
- (res #f))
+ (let*
+ ((pc (tutcode-find-descendant-context c))
+ (rkc (tutcode-context-rk-context pc))
+ (res #f)
+ (predicting?
+ (eq? (tutcode-context-predicting pc) 'tutcode-predicting-bushu)))
(tutcode-reset-candidate-window pc)
(cond
((tutcode-off-key? key key-state)
@@ -2118,6 +2237,10 @@
(tutcode-flush pc)))
((tutcode-stroke-help-toggle-key? key key-state)
(tutcode-toggle-stroke-help pc))
+ ((and predicting? (tutcode-next-page-key? key key-state))
+ (tutcode-change-bushu-prediction-page pc #t))
+ ((and predicting? (tutcode-prev-page-key? key key-state))
+ (tutcode-change-bushu-prediction-page pc #f))
((or
(symbol? key)
(and
@@ -2125,6 +2248,10 @@
(not (shift-key-mask key-state))))
(tutcode-flush pc)
(tutcode-proc-state-on pc key key-state))
+ ;; ͽ¬ÆþÎϸõÊäÍÑ¥é¥Ù¥ë¥¡¼?
+ ((and predicting? (tutcode-heading-label-char-for-prediction? key))
+ (tutcode-commit-by-label-key-for-prediction pc
+ (charcode->string key) 'tutcode-predicting-bushu))
((not (rk-expect-key? rkc (charcode->string key)))
(if (> (length (rk-context-seq rkc)) 0)
(rk-flush rkc)
@@ -2143,32 +2270,39 @@
(tutcode-append-string pc "¢¥")
(set! res #f)))))
(if res
- (let loop ((prevchar (car (tutcode-context-head pc)))
- (char res))
- (if (string=? prevchar "¢¥")
- (tutcode-append-string pc char)
- ;;
ľÁ°¤Îʸ»ú¤¬Éô¼ó¹çÀ®¥Þ¡¼¥«¤Ç¤Ê¤¤¢ª2ʸ»úÌܤ¬ÆþÎϤµ¤ì¤¿¢ªÊÑ´¹³«»Ï
- (begin
- (set! char
- (tutcode-bushu-convert prevchar char))
- (if (string? char)
- ;; ¹çÀ®À®¸ù
- (begin
- ;; 1ÈÖÌܤÎÉô¼ó¤È¢¥¤ò¾Ã¤¹
- (tutcode-context-set-head! pc (cddr (tutcode-context-head
pc)))
- (if (null? (tutcode-context-head pc))
- ;; ÊÑ´¹ÂÔ¤Á¤ÎÉô¼ó¤¬»Ä¤Ã¤Æ¤Ê¤±¤ì¤Ð¡¢³ÎÄꤷ¤Æ½ªÎ»
- (begin
- (tutcode-commit pc char)
- (tutcode-flush pc)
- (tutcode-check-auto-help-window-begin pc (list char)
()))
- ;; Éô¼ó¤¬¤Þ¤À»Ä¤Ã¤Æ¤ì¤Ð¡¢ºÆ³Îǧ¡£
- ;; (¹çÀ®¤·¤¿Ê¸»ú¤¬2ʸ»úÌܤʤé¤Ð¡¢Ï¢Â³¤·¤ÆÉô¼ó¹çÀ®ÊÑ´¹)
- (loop
- (car (tutcode-context-head pc))
- char)))
- ;; ¹çÀ®¼ºÇÔ»þ¤ÏÆþÎϤ·Ä¾¤·¤òÂÔ¤Ä
- )))))))
+ (tutcode-begin-bushu-conversion pc res))))
+
+;;; Éô¼ó¹çÀ®ÊÑ´¹³«»Ï
+;;; @param char ¿·¤¿¤ËÆþÎϤµ¤ì¤¿Ê¸»ú(2ÈÖÌܤÎÉô¼ó)
+(define (tutcode-begin-bushu-conversion pc char)
+ (let ((prevchar (car (tutcode-context-head pc))))
+ (if (string=? prevchar "¢¥")
+ (begin
+ (tutcode-append-string pc char)
+ (if tutcode-use-bushu-prediction?
+ (tutcode-check-bushu-prediction pc char)))
+ ;; ľÁ°¤Îʸ»ú¤¬Éô¼ó¹çÀ®¥Þ¡¼¥«¤Ç¤Ê¤¤¢ª2ʸ»úÌܤ¬ÆþÎϤµ¤ì¤¿¢ªÊÑ´¹³«»Ï
+ (let ((convchar (tutcode-bushu-convert prevchar char)))
+ (if (string? convchar)
+ ;; ¹çÀ®À®¸ù
+ (tutcode-bushu-commit pc convchar)
+ ;; ¹çÀ®¼ºÇÔ»þ¤ÏÆþÎϤ·Ä¾¤·¤òÂÔ¤Ä
+ )))))
+
+;;; Éô¼ó¹çÀ®ÊÑ´¹¤ÇÊÑ´¹¤·¤¿Ê¸»ú¤ò³ÎÄꤹ¤ë
+;;; @param convchar ÊÑ´¹¸å¤Îʸ»ú
+(define (tutcode-bushu-commit pc convchar)
+ ;; 1ÈÖÌܤÎÉô¼ó¤È¢¥¤ò¾Ã¤¹
+ (tutcode-context-set-head! pc (cddr (tutcode-context-head pc)))
+ (if (null? (tutcode-context-head pc))
+ ;; ÊÑ´¹ÂÔ¤Á¤ÎÉô¼ó¤¬»Ä¤Ã¤Æ¤Ê¤±¤ì¤Ð¡¢³ÎÄꤷ¤Æ½ªÎ»
+ (begin
+ (tutcode-commit pc convchar)
+ (tutcode-flush pc)
+ (tutcode-check-auto-help-window-begin pc (list convchar) ()))
+ ;; Éô¼ó¤¬¤Þ¤À»Ä¤Ã¤Æ¤ì¤Ð¡¢ºÆ³Îǧ¡£
+ ;; (¹çÀ®¤·¤¿Ê¸»ú¤¬2ʸ»úÌܤʤé¤Ð¡¢Ï¢Â³¤·¤ÆÉô¼ó¹çÀ®ÊÑ´¹)
+ (tutcode-begin-bushu-conversion pc convchar)))
;;; ¿·¤·¤¤¸õÊä¤òÁªÂò¤¹¤ë
;;; @param pc ¥³¥ó¥Æ¥¥¹¥È¥ê¥¹¥È
@@ -2211,6 +2345,16 @@
(tutcode-context-set-prediction-index! pc compensated-n)
(im-select-candidate pc compensated-n)))
+;;; ¼¡/Á°¥Ú¡¼¥¸¤ÎÉô¼ó¹çÀ®ÊÑ´¹¤Îͽ¬ÆþÎϸõÊä¤òɽ¼¨¤¹¤ë
+;;; @param next? #t:¼¡¥Ú¡¼¥¸, #f:Á°¥Ú¡¼¥¸
+(define (tutcode-change-bushu-prediction-page pc next?)
+ (let* ((idx (tutcode-context-prediction-bushu-page-start pc))
+ (n (+ idx
+ (if next?
+ tutcode-nr-candidate-max-for-prediction
+ (- tutcode-nr-candidate-max-for-prediction)))))
+ (tutcode-bushu-prediction-show-page pc n)))
+
;;; ¸õÊ䥦¥£¥ó¥É¥¦¤òÊĤ¸¤ë
(define (tutcode-reset-candidate-window pc)
(if (not (eq? (tutcode-context-candidate-window pc)
@@ -2590,6 +2734,52 @@
(c-composed? (string=? composed c)))
ret))
+;;; Éô¼ó¹çÀ®ÊÑ´¹»þ¤Îͽ¬ÆþÎϸõÊä¤ò¸¡º÷
+;;; @param str Éô¼ó1
+;;; @param bushudic Éô¼ó¹çÀ®¥ê¥¹¥È
+;;; @return (<Éô¼ó2> <¹çÀ®Ê¸»ú>)¤Î¥ê¥¹¥È
+(define (tutcode-bushu-predict str bushudic)
+ (let*
+ ((rules (rk-lib-find-partial-seqs (list str) bushudic))
+ (words1 (map (lambda (elem) (cadaar elem)) rules))
+ (more-cands
+ (filter
+ (lambda (elem)
+ (let
+ ;; (((Éô¼ó1 Éô¼ó2))(¹çÀ®Ê¸»ú))
+ ((bushu1 (caaar elem))
+ (bushu2 (cadaar elem))
+ (gosei (caadr elem)))
+ (or
+ ;; str¤¬1ʸ»úÌܤξì¹ç¤Ïrk-lib-find-partial-seqs¤Ç¸¡º÷ºÑ
+ ;(string=? str bushu1) ; (((str Éô¼ó2))(¹çÀ®Ê¸»ú))
+ (and (string=? str bushu2) ; (((Éô¼ó1 str))(¹çÀ®Ê¸»ú))
+ ;; ´û¤Ë¾å¤Ç½Ð¸½ºÑ¤Î¾ì¹ç¤Ï½ü³°¡£
+ ;; Îã: ((("Ìç" "ºÍ"))("ÊÄ"))¤Ç"ºÍ"¤¬½Ð¸½ºÑ¤Î¾ì¹ç¡¢
+ ;; ((("ºÍ" "Ìç"))("Ùß"))¤Î"ºÍ"¤Ï½ü³°¡£
+ (not (member bushu1 words1)))
+ (string=? str gosei)))) ; (((Éô¼ó1 Éô¼ó2))(str))
+ ;; XXX:¤³¤Î¾ì¹ç¡¢str¤Èbushu1¤Çbushu2¤¬¹çÀ®¤Ç¤¤ë¤³¤È¤ò
+ ;; ³Îǧ¤¹¤Ù¤¤À¤¬¡¢tutcode-bushu-convert¤ÏÃÙ¤¤¤Î¤Ç¾Êά¡£
+ bushudic))
+ (res (append rules more-cands))
+ (word/cand
+ (map
+ (lambda (elem)
+ (let
+ ((bushu1 (caaar elem))
+ (bushu2 (cadaar elem))
+ (gosei (caadr elem)))
+ (cond
+ ((string=? str bushu1) ; (((str Éô¼ó2))(¹çÀ®Ê¸»ú))
+ (list bushu2 gosei))
+ ((string=? str bushu2) ; (((Éô¼ó1 str))(¹çÀ®Ê¸»ú))
+ (list bushu1 gosei))
+ ((string=? str gosei) ; (((Éô¼ó1 Éô¼ó2))(str))
+ (list bushu1 bushu2)))))
+ res)))
+ word/cand))
+
;;; tutcode-rule¤òµÕ°ú¤¤·¤Æ¡¢ÊÑ´¹¸å¤Îʸ»ú¤«¤é¡¢ÆþÎÏ¥¡¼Îó¤ò¼èÆÀ¤¹¤ë¡£
;;; Îã: (tutcode-reverse-find-seq "¤¢") => ("r" "k")
;;; @param c ÊÑ´¹¸å¤Îʸ»ú
@@ -2738,10 +2928,16 @@
(p-idx (+ idx-in-page (* pages nr-in-page)))
(i (remainder p-idx nr-predictions))
(cand (tutcode-lib-get-nth-prediction tc i))
+ (cand-guide
+ (if (eq? (tutcode-context-predicting tc)
+ 'tutcode-predicting-bushu)
+ (string-append
+ cand "(" (tutcode-lib-get-nth-word tc i) ")")
+ cand))
(n (remainder p-idx
(length
tutcode-heading-label-char-list-for-prediction)))
(label (nth n
tutcode-heading-label-char-list-for-prediction)))
- (list cand label ""))
+ (list cand-guide label ""))
;; ½Ï¸ì¥¬¥¤¥É
(let*
((guide (tutcode-context-guide tc))
@@ -2801,11 +2997,13 @@
((nr-predictions (tutcode-lib-get-nr-predictions pc))
(pages (quotient idx page-limit))
(p-idx (+ idx-in-page (* pages nr-in-page)))
- (i (remainder p-idx nr-predictions)))
+ (i (remainder p-idx nr-predictions))
+ (mode (tutcode-context-predicting pc)))
(tutcode-context-set-prediction-index! pc i)
- (tutcode-do-commit-prediction pc
- (eq? (tutcode-context-predicting pc)
- 'tutcode-predicting-completion))
+ (if (eq? mode 'tutcode-predicting-bushu)
+ (tutcode-do-commit-prediction-for-bushu pc)
+ (tutcode-do-commit-prediction pc
+ (eq? mode 'tutcode-predicting-completion)))
(tutcode-update-preedit pc))))))))
(tutcode-configure-widgets)