英語多読を日記に書くときの支援スクリプト
英語多読の本を読んだら、上みたいに日記に書いて記録を残しています。で、語数とかISBNとかをSSS英語学習法/多読+シャドウイングで調べているのですが、いい加減面倒なので、SSS英語学習法の検索結果をはてなダイアリーのフォーマットに変換する支援スクリプトを書いてみました。自動化の余地は多分にありますが、2週間に1回くらいしか実行しないので、これくらいにしておきます。
#!/usr/bin/env ruby # -*- compile-command: "ruby -rubygems -Ks a.rb" -*- data = DATA.readlines # require 'pp'; pp data raise 'title not found.' unless data[0] =~ /\t(.+)登録者/ title = $1 title.gsub!(/ /, ' ') title.strip! raise 'number of words not found.' unless data[1] =~ /●総語数:([\d,]+)/ nwords = $1 raise 'isbn not found' unless data[1] =~ /●ISBN:\s(\d+)/ isbn = $1 contents = data[3] puts "*[読書][英語] #{title}(#{nwords}語)" puts "ISBN:#{isbn}:detail" print contents __END__ 2. Portrait of a Lady, The 登録者:[ ] 更新者:[ ] ●お薦め度(平均): 3.0 ●レビュー数: 0 ●YL(平均):3.2 ●総語数:8,200 ●ISBN: 9780582417830(058241783X) ●シリーズ: Penguin Readers ●ジャンル: F/古典 19世紀のイギリスの上流社会にアメリカから来たIsabelは… ⇒__END__以下に検索結果を貼り付けてスクリプトを実行します。