Revision: 6150
Author: iratqq
Date: Thu Feb 4 23:31:26 2010
Log: * scm/social-ime-custom.scm (social-ime-prediction-type):
- Add custom value.
* scm/social-ime.scm (social-ime-lib-set-prediction-src-string):
(social-ime-lib-commit-nth-predictionm, social-ime-context-new):
- Add local prediction.
(social-ime-lib-get-nth-word, social-ime-lib-get-nth-appendix):
- New function.
http://code.google.com/p/uim/source/detail?r=6150
Modified:
/trunk/scm/social-ime-custom.scm
/trunk/scm/social-ime.scm
=======================================
--- /trunk/scm/social-ime-custom.scm Wed Nov 4 08:13:55 2009
+++ /trunk/scm/social-ime-custom.scm Thu Feb 4 23:31:26 2010
@@ -353,6 +353,14 @@
(N_ "Enable input prediction")
(N_ "long description will be here."))
+(define-custom 'social-ime-prediction-type 'www
+ '(social-ime-advanced social-ime-prediction)
+ (list 'choice
+ (list 'www (N_ "Social-IME Server") (N_ "Social-IME Server"))
+ (list 'uim (N_ "uim") (N_ "uim")))
+ (N_ "Prediction type")
+ (N_ "long description will be here."))
+
(define-custom 'social-ime-select-prediction-by-numeral-key? #f
'(social-ime-advanced social-ime-prediction)
'(boolean)
@@ -394,6 +402,11 @@
(lambda ()
social-ime-use-candidate-window?))
+(custom-add-hook 'social-ime-prediction-type
+ 'custom-activity-hooks
+ (lambda ()
+ social-ime-use-prediction?))
+
(custom-add-hook 'social-ime-select-prediction-by-numeral-key?
'custom-activity-hooks
(lambda ()
=======================================
--- /trunk/scm/social-ime.scm Wed Nov 4 08:13:55 2009
+++ /trunk/scm/social-ime.scm Thu Feb 4 23:31:26 2010
@@ -36,6 +36,7 @@
(require "japanese-kana.scm")
(require "japanese-azik.scm")
(require "http-client.scm")
+(require "generic-predict.scm")
(require-custom "generic-key-custom.scm")
(require-custom "social-ime-custom.scm")
(require-custom "social-ime-key-custom.scm")
@@ -55,7 +56,9 @@
(list 'str "")
(list 'candidates '())
(list 'seg-cnts '())
+ (list 'prediction-word '())
(list 'prediction-candidates '())
+ (list 'prediction-appendix '())
(list 'prediction-nr '()))))
(define-record 'social-ime-internal-context
social-ime-internal-context-rec-spec)
(define social-ime-internal-context-new-internal
social-ime-internal-context-new)
@@ -215,19 +218,47 @@
(define (social-ime-lib-reset-conversion sc)
#f)
(define (social-ime-lib-set-prediction-src-string sc str)
- (let ((sc-ctx (social-ime-context-sc-ctx sc))
- (cands (social-ime-predict sc str "")))
- (social-ime-internal-context-set-prediction-candidates! sc-ctx cands)
- (social-ime-internal-context-set-prediction-nr! sc-ctx (length cands)))
+ (cond ((eq? social-ime-prediction-type 'www)
+ (let ((sc-ctx (social-ime-context-sc-ctx sc))
+ (cands (social-ime-predict sc str "")))
+ (social-ime-internal-context-set-prediction-candidates! sc-ctx
cands)
+ (social-ime-internal-context-set-prediction-nr! sc-ctx (length
cands))))
+ ((eq? social-ime-prediction-type 'uim)
+ (let* ((ret (predict-meta-search
+ (social-ime-context-prediction-ctx sc)
+ str))
+ (sc-ctx (social-ime-context-sc-ctx sc))
+ (word (predict-meta-word? ret))
+ (cands (predict-meta-candidates? ret))
+ (appendix (predict-meta-appendix? ret)))
+ (social-ime-internal-context-set-prediction-word! sc-ctx word)
+ (social-ime-internal-context-set-prediction-candidates! sc-ctx
cands)
+ (social-ime-internal-context-set-prediction-appendix! sc-ctx
appendix)
+ (social-ime-internal-context-set-prediction-nr! sc-ctx (length
cands)))))
#f)
(define (social-ime-lib-get-nr-predictions sc)
(let ((sc-ctx (social-ime-context-sc-ctx sc)))
(social-ime-internal-context-prediction-nr sc-ctx)))
+(define (social-ime-lib-get-nth-word sc nth)
+ (let* ((sc-ctx (social-ime-context-sc-ctx sc))
+ (word (social-ime-internal-context-prediction-word sc-ctx)))
+ (list-ref word nth)))
(define (social-ime-lib-get-nth-prediction sc nth)
(let* ((sc-ctx (social-ime-context-sc-ctx sc))
(cands (social-ime-internal-context-prediction-candidates
sc-ctx)))
(list-ref cands nth)))
+(define (social-ime-lib-get-nth-appendix sc nth)
+ (let* ((sc-ctx (social-ime-context-sc-ctx sc))
+ (appendix (social-ime-internal-context-prediction-appendix
sc-ctx)))
+ (list-ref appendix nth)))
(define (social-ime-lib-commit-nth-prediction sc nth)
+ (if (eq? social-ime-prediction-type 'uim)
+ (let ((sc-ctx (social-ime-context-sc-ctx sc)))
+ (predict-meta-commit
+ (social-ime-context-prediction-ctx sc)
+ (social-ime-lib-get-nth-word sc nth)
+ (social-ime-lib-get-nth-prediction sc nth)
+ (social-ime-lib-get-nth-appendix sc nth))))
#f)
@@ -466,6 +497,7 @@
(list 'segments #f) ;; ustr of candidate indices
(list 'candidate-window #f)
(list 'candidate-op-count 0)
+ (list 'prediction-ctx #f)
(list 'prediction-window #f)
(list 'prediction-index #f)
(list 'prediction-cache '())
@@ -492,6 +524,11 @@
(if using-kana-table?
(social-ime-context-set-input-rule! sc social-ime-input-rule-kana)
(social-ime-context-set-input-rule! sc social-ime-input-rule-roma))
+ (if (eq? social-ime-prediction-type 'uim)
+ (begin
+ (social-ime-context-set-prediction-ctx! sc
(predict-make-meta-search))
+ (predict-meta-open (social-ime-context-prediction-ctx
sc) "social-ime")
+ (predict-meta-set-external-charset!
(social-ime-context-prediction-ctx sc) "EUC-JP")))
sc))
(define (social-ime-commit-raw sc)