LoginSignup
11
11

More than 5 years have passed since last update.

青空文庫のルビを消しUTF-8にする

Last updated at Posted at 2014-02-15

はじめに

大量の文章が置いてある青空文庫は色々と遊べて楽しいのですが、サイトから直接手に入るテキストはutf-8ではなくまた《》でルビが振ってあるためすこし使いづらいです。
なのでルビを消しutf-8に変化するスクリプトを作りました。

スクリプト

aozoraEncoder.sh
#!/bin/sh
nkf -w -Lu $1 > m.txt
cat m.txt | ruby -e 'puts ARGF.read.gsub(/|/, "").gsub(/《.+?》/,"").gsub(/[.+?]/,"")'
rm -f m.txt

作成後以下を実行してください。

chmod u+x aozoraEncoder.sh

使い方

aozoraEncoder.sh input.txt > output.txt
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11