Changeset 704
- Timestamp:
- 10/25/07 16:12:27 (6 years ago)
- Files:
-
- 1 modified
-
lang/ruby/syobodic/proc1.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/syobodic/proc1.rb
r702 r704 1 1 require 'net/http' 2 2 require 'kconv' 3 $KCODE = "UTF-8" 3 require 'jcode' 4 $KCODE = "UTF8" 4 5 5 6 $SYOBO_SERVER = "cal.syoboi.jp" 6 7 8 class Splitter 9 def initialize(t,k) 10 @text = t 11 @kana = k 12 end 13 end 14 7 15 class SyoboTitle 16 attr_reader :title 17 attr_reader :kana 18 8 19 def read_from_line(ln) 20 ln.chomp! 21 ln.gsub!(/^[ *],/,"") 22 23 ln.gsub!(/^([0-9]+),/, "") 24 raise "cannot read tid" if !($&) 25 @tid = $1.to_i 26 27 ln.gsub!(/^\"([^\"]+)\",/, "") 28 raise "cannot read title" if !($&) 29 @title = $1 30 31 ln.gsub!(/^\"([^\"]+)\",/, "") 32 raise "cannot read kana" if !($&) 33 @kana = $1 34 35 ln.gsub!(/^\"([^\"]+)\"/, "") 36 @abbr = $1 37 38 @abbr = nil if @abbr == "" 39 9 40 end 10 41 … … 18 49 raise "cannot found h1" if !($&) 19 50 @title = $1 51 @title.gsub!("&","&") 20 52 21 53 rbody =~ /<th>よみ<\/th><td>([^<]+)<\/td>/ … … 33 65 def print 34 66 mark = @abbr ? "*" : " " 35 puts "#{mark},#{@tid},\"#{@title}\",\"#{@kana}\",\"#{@abbr}\"" .kconv(Kconv::SJIS, Kconv::UTF8)67 puts "#{mark},#{@tid},\"#{@title}\",\"#{@kana}\",\"#{@abbr}\"" 36 68 end 37 69 end … … 51 83 end 52 84 53 makeRawList(1200, 1250) 85 def splitWords(rawlist_fn) 86 list = [] 87 88 File.open(rawlist_fn) {|f| 89 f.each {|ln| 90 t = SyoboTitle.new 91 t.read_from_line(ln) 92 93 s = Splitter.new(t.title, t.kana) 94 } 95 } 96 end 97 98 # ----------------------------- 99 100 if ARGV.length == 1 101 splitWords(ARGV[0]) 102 else 103 makeRawList(1150, 1250) 104 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)