青山です。

On Tue, 14 Dec 1999 08:01:55 +0900,
Wakou Aoyama <wakou / fsinet.or.jp> wrote:

> ちなみに、ruby-man-jp/preface.html を変換したものを lynx -dump すると
> こんな感じです。 

しまった。変換後に文章が減っているような気がすると思ったら、本当に減っ
ていた。まあ、とりあえずという事で。他にもおかしな所があるかも。

#!/usr/local/bin/ruby

require "honyaku"
require "nkf"

mode = ARGV.shift.upcase
data = NKF::nkf('-e', STDIN.read).split(/(<[^>]*>)/)
host = Honyaku.new( ENV["USER"], mode )

i = -2
while i < data.size - 1
  i += 2
  next unless /\w/.match(data[i])
  if mode == "EJ"
    # 入力が英語の場合は段落内の改行をスペースに変換
    data[i].gsub!(/ *\n *(?!\n)?/, ' ')
  else
    # 入力が日本語の場合は段落内の改行を削除
    data[i].gsub!(/ *\n *(?!\n)?/, '')
  end
  paragraphs = host.trns_divide_sentence(data[i])
  data[i] = ''
  paragraphs.each do |paragraph|
    paragraph.each() do |sentence|
      data[i].concat host.translate_one(sentence)
    end
  end
end

print NKF::nkf('-j', data.join(''))
host.close


   [1]Next
   - [2]A table of contents
     _________________________________________________________________
   
                                 Introduction
                                       
   Ruby is interpreter language for simple object oriented
   programming.Ruby (it seems to be perl) has an abundant function for
   text processing and system management.In addition, it is easy to
   understand Ruby by simplicity and can easily expand it.
   
   If demand language for simple object orientation, and feel it if perl
   is ugly, and like a way of thinking of lisp, but feel it when is
   troubled with numerousness of that parenthesis || Ruby || right ||
   tightly.
   
   Features of Ruby || as follows.
   
   Interpreter
          Ruby doesn't need to compile it in order to execute a program
          with what is interpreter language.
          
   There isn't model in variable (a dynamic model account)
          Because variable of Ruby can store away data of any kind of
          model, I don't need to worry about variable type.One side, a
          check in compilation become weak.
略
     _________________________________________________________________
   
   [3]Next - [4]A table of contents
   
                                                     [5]Matz / netlab.co.jp


メールアドレスが大文字になってしまっていますね。これは手作業か、ある程
度パターンで保護しておくか。あ、1文の後のピリオドの後に空白を入れるよ
うにしなければ。べた付けになっている。これはスクリプトのミスだ。


-- 
青山 和光 Wakou Aoyama <wakou / fsinet.or.jp>