[Prime-cvs] CVS update: suikyo/ruby/src

Back to archive index

Hiroyuki Komatsu komat****@users*****
2004年 12月 13日 (月) 18:06:02 JST


Index: suikyo/ruby/src/suikyo.rb
diff -u suikyo/ruby/src/suikyo.rb:1.15 suikyo/ruby/src/suikyo.rb:1.16
--- suikyo/ruby/src/suikyo.rb:1.15	Sun Dec  5 18:56:47 2004
+++ suikyo/ruby/src/suikyo.rb	Mon Dec 13 18:06:02 2004
@@ -1,5 +1,5 @@
 # suikyo.rb: Romaji-Hiragana conversion library for Ruby
-# $Id: suikyo.rb,v 1.15 2004/12/05 09:56:47 komatsu Exp $
+# $Id: suikyo.rb,v 1.16 2004/12/13 09:06:02 komatsu Exp $
 #
 # Copyright (C) 2002 - 2004 Hiroyuki Komatsu <komat****@taiya*****>
 #     All rights reserved.
@@ -67,7 +67,7 @@
 
       while table and chars.length > 0 do
         head = chars[0]
-        tmp_node = table.word(head)
+        tmp_node = table.get_word(head)
         table = (tmp_node and tmp_node.subtable)
         if tmp_node or pending == "" then
           pending += head unless head == " "
@@ -125,8 +125,9 @@
     results = []
     table.allresults_uniq.each {|result, cont|
       if cont then
-	if****@table*****(cont).subtable then
-	  @table.word(cont).subtable.allresults_uniq.each {|subresult, subcont|
+        subtable =****@table*****_word(cont).subtable()
+	if subtable then
+	  subtable.allresults_uniq.each {|subresult, subcont|
 	    results.push(result + subresult)
 	  }
 	else
@@ -205,8 +206,17 @@
     end
   end
 
-  def word (char)
-    return @word[char]
+  def get_word (chars)
+    word  = nil
+    words = allword()
+    chars.split(//).each { | char |
+      word = words[char]
+      if word.nil? or word.subtable.nil? then
+        break
+      end
+      words = word.subtable.allword
+    }
+    return word
   end
 
   def allword
@@ -285,12 +295,20 @@
 end
 
 class SuikyoTable2 < SuikyoTable
-  def word (char)
-    if @word[char] then
-      return @word[char]
-    else
-      return @word[char.swapcase]
-    end
+  def get_word (chars)
+    word  = nil
+    words = allword()
+    chars.split(//).each { | char |
+      word = words[char]
+      if word.nil? then
+        word = words[char.swapcase]
+      end
+      if word.nil? or word.subtable.nil? then
+        break
+      end
+      words = word.subtable.allword
+    }
+    return word
   end
 end
 
Index: suikyo/ruby/src/suikyo-composer.rb
diff -u suikyo/ruby/src/suikyo-composer.rb:1.6 suikyo/ruby/src/suikyo-composer.rb:1.7
--- suikyo/ruby/src/suikyo-composer.rb:1.6	Sat Dec 11 17:00:25 2004
+++ suikyo/ruby/src/suikyo-composer.rb	Mon Dec 13 18:06:02 2004
@@ -1,6 +1,6 @@
 # suikyo-composer.rb: Preedition composer using Suikyo.
 # This library is for input methods such as PRIME.
-# $Id: suikyo-composer.rb,v 1.6 2004/12/11 08:00:25 komatsu Exp $
+# $Id: suikyo-composer.rb,v 1.7 2004/12/13 09:06:02 komatsu Exp $
 #
 # Copyright (C) 2004 Hiroyuki Komatsu <komat****@taiya*****>
 #     All rights reserved.
@@ -864,7 +864,7 @@
 
       while table and cont_chars.length > 0 do
         head = cont_chars[0]
-        tmp_node = table.word(head)
+        tmp_node = table.get_word(head)
         table = (tmp_node and tmp_node.subtable)
         if tmp_node or chunk.pending == [] then
           chunk.pending += head.split(//) unless head == " "
@@ -875,7 +875,7 @@
 
       while table and chars.length > 0 do
         head = chars[0]
-        tmp_node = table.word(head)
+        tmp_node = table.get_word(head)
         table = (tmp_node and tmp_node.subtable)
 
         if tmp_node or chunk.pending == [] then


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