Revision: 6151
Author: iratqq
Date: Fri Feb  5 00:25:31 2010
Log: * scm/yahoo-jp-custom.scm (yahoo-jp-prediction-type):
  - Add custom value.
* scm/yahoo-jp.scm (yahoo-jp-lib-set-prediction-src-string):
  (yahoo-jp-lib-commit-nth-prediction, yahoo-jp-context-new):
  - Add local prediction.
  (yahoo-jp-lib-get-nth-word, yahoo-jp-lib-get-nth-appendix):
  - New function.

http://code.google.com/p/uim/source/detail?r=6151

Modified:
 /trunk/scm/yahoo-jp-custom.scm
 /trunk/scm/yahoo-jp.scm

=======================================
--- /trunk/scm/yahoo-jp-custom.scm      Wed Nov  4 20:15:46 2009
+++ /trunk/scm/yahoo-jp-custom.scm      Fri Feb  5 00:25:31 2010
@@ -359,6 +359,14 @@
   (N_ "Enable input prediction")
   (N_ "long description will be here."))

+(define-custom 'yahoo-jp-prediction-type 'www
+  '(yahoo-jp-advanced yahoo-jp-prediction)
+  (list 'choice
+        (list 'www (N_ "Yahoo! Server") (N_ "Yahoo! Server"))
+        (list 'uim (N_ "uim")  (N_ "uim")))
+  (N_ "Prediction type")
+  (N_ "long description will be here."))
+
 (define-custom 'yahoo-jp-select-prediction-by-numeral-key? #f
   '(yahoo-jp-advanced yahoo-jp-prediction)
   '(boolean)
=======================================
--- /trunk/scm/yahoo-jp.scm     Wed Nov  4 20:15:46 2009
+++ /trunk/scm/yahoo-jp.scm     Fri Feb  5 00:25:31 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 "yahoo-jp-custom.scm")
 (require-custom "yahoo-jp-key-custom.scm")
@@ -55,7 +56,9 @@
     (list 'yomi-seg    '())
     (list 'candidates  '())
     (list 'seg-cnts '())
+    (list 'prediction-word '())
     (list 'prediction-candidates '())
+    (list 'prediction-appendix '())
     (list 'prediction-nr '()))))
(define-record 'yahoo-jp-internal-context yahoo-jp-internal-context-rec-spec) (define yahoo-jp-internal-context-new-internal yahoo-jp-internal-context-new)
@@ -241,19 +244,47 @@
 (define (yahoo-jp-lib-reset-conversion yc)
   #f)
 (define (yahoo-jp-lib-set-prediction-src-string yc str)
-  (let ((yx-ctx (yahoo-jp-context-yx-ctx yc))
-       (cands (yahoo-jp-predict yc str "")))
-    (yahoo-jp-internal-context-set-prediction-candidates! yx-ctx cands)
-    (yahoo-jp-internal-context-set-prediction-nr! yx-ctx (length cands)))
+  (cond ((eq? yahoo-jp-prediction-type 'www)
+         (let ((yx-ctx (yahoo-jp-context-yx-ctx yc))
+               (cands (yahoo-jp-predict yc str "")))
+ (yahoo-jp-internal-context-set-prediction-candidates! yx-ctx cands) + (yahoo-jp-internal-context-set-prediction-nr! yx-ctx (length cands))))
+        ((eq? yahoo-jp-prediction-type 'uim)
+         (let* ((ret (predict-meta-search
+                      (yahoo-jp-context-prediction-ctx yc)
+                      str))
+                (yx-ctx (yahoo-jp-context-yx-ctx yc))
+                (word     (predict-meta-word? ret))
+                (cands    (predict-meta-candidates? ret))
+                (appendix (predict-meta-appendix? ret)))
+           (yahoo-jp-internal-context-set-prediction-word! yx-ctx word)
+ (yahoo-jp-internal-context-set-prediction-candidates! yx-ctx cands) + (yahoo-jp-internal-context-set-prediction-appendix! yx-ctx appendix) + (yahoo-jp-internal-context-set-prediction-nr! yx-ctx (length cands)))))
   #f)
 (define (yahoo-jp-lib-get-nr-predictions yc)
   (let ((yx-ctx (yahoo-jp-context-yx-ctx yc)))
     (yahoo-jp-internal-context-prediction-nr yx-ctx)))
+(define (yahoo-jp-lib-get-nth-word yc nth)
+  (let* ((yx-ctx (yahoo-jp-context-yx-ctx sc))
+         (word (yahoo-jp-internal-context-prediction-word yx-ctx)))
+    (list-ref word nth)))
 (define (yahoo-jp-lib-get-nth-prediction yc nth)
   (let* ((yx-ctx (yahoo-jp-context-yx-ctx yc))
          (cands (yahoo-jp-internal-context-prediction-candidates yx-ctx)))
     (list-ref cands nth)))
+(define (yahoo-jp-lib-get-nth-appendix yc nth)
+  (let* ((yx-ctx (yahoo-jp-context-yx-ctx yc))
+         (appendix (yahoo-jp-internal-context-prediction-appendix yx-ctx)))
+    (list-ref appendix nth)))
 (define (yahoo-jp-lib-commit-nth-prediction yc nth)
+  (if (eq? yahoo-jp-prediction-type 'uim)
+      (let ((yx-ctx (yahoo-jp-context-yx-ctx yc)))
+        (predict-meta-commit
+         (yahoo-jp-context-prediction-ctx yc)
+         (yahoo-jp-lib-get-nth-word yc nth)
+         (yahoo-jp-lib-get-nth-prediction yc nth)
+         (yahoo-jp-lib-get-nth-appendix yc nth))))
   #f)

 (define yahoo-jp-init-lib-ok? #f)
@@ -491,6 +522,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   '())
@@ -517,6 +549,11 @@
     (if using-kana-table?
         (yahoo-jp-context-set-input-rule! yc yahoo-jp-input-rule-kana)
         (yahoo-jp-context-set-input-rule! yc yahoo-jp-input-rule-roma))
+    (if (eq? yahoo-jp-prediction-type 'uim)
+        (begin
+ (yahoo-jp-context-set-prediction-ctx! yc (predict-make-meta-search)) + (predict-meta-open (yahoo-jp-context-prediction-ctx yc) "yahoo-jp") + (predict-meta-set-external-charset! (yahoo-jp-context-prediction-ctx yc) "EUC-JP")))
     yc))

 (define (yahoo-jp-commit-raw yc)

Reply via email to