[Prime-cvs] CVS update: prime/lib

Back to archive index

Hiroyuki Komatsu komat****@users*****
2005年 6月 20日 (月) 02:28:15 JST


Index: prime/lib/composer.rb
diff -u prime/lib/composer.rb:1.9 prime/lib/composer.rb:1.10
--- prime/lib/composer.rb:1.9	Sun Mar 27 19:32:22 2005
+++ prime/lib/composer.rb	Mon Jun 20 02:28:15 2005
@@ -1,5 +1,5 @@
 # composer.rb: Module of composition for PrimeSession
-# $Id: composer.rb,v 1.9 2005/03/27 10:32:22 komatsu Exp $
+# $Id: composer.rb,v 1.10 2005/06/19 17:28:15 komatsu Exp $
 #
 # Copyright (C) 2005 Hiroyuki Komatsu <komat****@taiya*****>
 #     All rights reserved.
@@ -39,11 +39,52 @@
     @prime_context = context
   end
 
+  def hybrid_typing_check_validation_original ()
+    chunk = @head_chunk
+    (current_chunk, offset) = chunk_get_at(@position)
+    
+    flag_valid    = true
+    flag_original = true
+    original = ""
+
+    until chunk.chunk_next == @tail_chunk do 
+      chunk = chunk.chunk_next
+
+      ## If pending characters exist in the preediting chunks except the last
+      ## chunk, the flag for validation becomes false.
+      if (chunk.pending.length > 0 and
+            chunk.chunk_next != @tail_chunk and chunk != current_chunk) or \
+        (chunk.pending.length + chunk.conversion.length == 0) then 
+        flag_valid = false
+      end
+
+      ## If there're chunks whose original value is nil, the flag for original
+      ## input becomes false.
+      if chunk.original.nil? then
+        flag_original = false
+      else
+        original += chunk.original.join()
+      end
+    end
+
+    if flag_valid == false and flag_original == true then
+      return false
+    end
+
+    ## If the original string has capital characters in the middle of the
+    ## string, the validation will be false.
+    ## ex). "FreeWnn" => false, "PRIME" => false, "Anthy" => true
+    if original =~ /.+[A-Z]/ then
+      return false
+    end
+    return true
+  end
+
   ## This checks the validation of the preediting string.  If the preedition
   ## is valid, it returns true.  If invalid, false.
-  ## ex). "apple ($B$"$C(Bpl$B$((B)" => false, "ringo($B$j$s$4(B)" => true.
+  ## ex). "apple (あっplえ)" => false, "ringo(りんご)" => true.
   def hybrid_typing_check_validation ()
-    original_result = super
+    original_result = hybrid_typing_check_validation_original()
 
     if PRIME_ENV['hybrid_typing_use_dictionaries'] == false then
       return original_result
@@ -73,8 +114,10 @@
     words_list = @composer_prime_engines.command( :search, query )
     words = PrimeWordList::merge(words_list)
 
+    ## Return the origianl result, if there's no word whose prefix is
+    ## the preedition.
     if words.length == 0 then
-      return true
+      return original_result
     end
 
     max_score = words[0].score


Prime-cvs メーリングリストの案内
Back to archive index