--- lib/prime-japanese.rb	28 Jan 2004 08:46:50 -0000	1.1.2.11
+++ lib/prime-japanese.rb	28 Jan 2004 17:42:05 -0000
@@ -323,16 +323,18 @@
   def PrimeTypeConv::convert(string)
     suikyo = PrimeTypeConv::initialize_suikyo()
     (conversion, pending, node) = suikyo.convert_internal(string)
-    if conversion =~ /[a-zA-Z]/ then
-      return [string]
-    elsif string =~ /^[0-9+-][0-9,.+-]*/ then
-      numeral = $&
-      string = string[numeral.length..-1]
-      (conversion, pending, node) = suikyo.convert_internal(string)
-      return [numeral + conversion, pending]
-    else
-      return [conversion, pending]
-    end
+
+    if PRIME_ENV['typing_method'] == 'romaji' then
+      if conversion =~ /[a-zA-Z]/ then
+        return [string]
+      elsif string =~ /^[0-9+-][0-9,.+-]*/ then
+        numeral = $&
+        string = string[numeral.length..-1]
+        (conversion, pending, node) = suikyo.convert_internal(string)
+        return [numeral + conversion, pending]
+      end
+    end      
+    return [conversion, pending]
   end
 
   def PrimeTypeConv::expand(string)
@@ -341,6 +343,11 @@
     return expansion + [string]
   end
 
+  def PrimeTypeConv::destroy_cache()
+    filename_cache = File::join2(PRIME_USER_DIR, "suikyo.rbo")
+    File::delete(filename_cache)
+  end
+
   def PrimeTypeConv::initialize_suikyo(force = false)
     if @@suikyo and force == false then
       return @@suikyo
@@ -355,9 +362,8 @@
     else
       threshold_time = Time.new()
     end
-    filename_cache =
-    cache_file = File::join2(PRIME_USER_DIR, "suikyo.rbo")
-    suikyo = Marshal::init_file(cache_file, threshold_time) {
+    filename_cache = File::join2(PRIME_USER_DIR, "suikyo.rbo")
+    suikyo = Marshal::init_file(filename_cache, threshold_time) {
       suikyo = Suikyo.new
       tables = (PRIME_ENV['suikyo_tables'] or
                   PRIME_TYPING_TABLE[typing_method] or
--- src/prime.src	28 Jan 2004 08:34:57 -0000	1.1.2.3
+++ src/prime.src	28 Jan 2004 17:42:05 -0000
@@ -168,12 +168,13 @@
 def show_usage
   puts "\
 Usage: #{command_name} <options>
-  -u, --unix-socket=PATH  run as Unix socket server with socket PATH
-  -s, --tcp-server=PORT   run as TCP server with port PORT
-  -v, --version           show the version and exit
-  -h, --help              show this help and exit
-      --no-save           do not save learning records
-  -d, --debug             run under debug mode
+  -u, --unix-socket=PATH      run as Unix socket server with socket PATH
+  -s, --tcp-server=PORT       run as TCP server with port PORT
+  -v, --version               show the version and exit
+  -h, --help                  show this help and exit
+      --no-save               do not save learning records
+      --typing-method=METHOD  run with the specified typing method.
+  -d, --debug                 run under debug mode
 
 HomePage: http://taiyaki.org/prime/ (in Japanese)
 "
@@ -191,6 +192,7 @@
 		     ['--version','-v',		GetoptLong::NO_ARGUMENT],
 		     ['--unix-socket',	'-u',	GetoptLong::REQUIRED_ARGUMENT],
 		     ['--tcp-server',	'-s',	GetoptLong::REQUIRED_ARGUMENT],
+		     ['--typing-method',        GetoptLong::REQUIRED_ARGUMENT],
 		     ['--no-save',              GetoptLong::NO_ARGUMENT],
 		     ['--debug', '-d',		GetoptLong::NO_ARGUMENT])
 
@@ -217,22 +219,40 @@
   return options
 end
 
-def main ()
-  options = parse_options()
+def init ()
+  @options = parse_options()
+
+  if @options['typing-method'] then
+    PrimeTypeConv::destroy_cache()
+    PRIME_ENV['typing_method'] = @options['typing-method']
+  end
 
   @prime = Prime.new()
 
-  if options['unix-socket']
-    socket_path = options['unix-socket']
+  if @options['typing-method'] then
+    PrimeTypeConv::destroy_cache()
+  end
+end
+
+def main ()
+  unless $PRIME_NO_SAVE then
+    Thread.new do
+      system('prime-userdict-update --auto --quiet')
+      @prime.refresh()
+    end
+  end
+
+  if @options['unix-socket']
+    socket_path = @options['unix-socket']
     server = UnixSocketServer.new(@prime, socket_path)
-  elsif options['tcp-server']
-    tcp_port = options['tcp-server']
+  elsif @options['tcp-server']
+    tcp_port = @options['tcp-server']
     server = TaiyakiTCPServer.new(@prime, tcp_port)
   else
     server = StdioServer.new(@prime)
   end
 
-  if options['debug'] or ENV['PRIME_DEBUG'] then
+  if @options['debug'] or ENV['PRIME_DEBUG'] then
     Dir::ensure(PRIME_USER_DIR + "/logs")
     logfile = PRIME_USER_DIR + "/logs/debug_" +
               Time::new.strftime("%Y%m%d%H%M") + "_" + $$.to_s + ".log"
@@ -240,17 +260,14 @@
   end
 
   server.accept()
+
+  @prime.close()
 end
 
+init()
+
 trap ("HUP") {
   @prime.refresh()
 }
-unless $PRIME_NO_SAVE then
-  Thread.new do
-    system('prime-userdict-update --auto --quiet')
-    @prime.refresh()
-  end
-end
-main()
-@prime.close()
 
+main()
