Skip to content

A script that rewrites an RFC text file written in English so that it does not break in the middle as a single sentence by removing headers and footers for page formatting and superfluous line breaks.

Notifications You must be signed in to change notification settings

adneskuo/rfctxt2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rfctxt2

概要

英語で書かれたRFCのテキストファイルから、ページ整形のためのヘッダ・フッタや余計な改行を取り除いて、1文として途中改行しないように書き換えるスクリプト。

注意:当然だが、図や表などうまく変換できないものは多々あるので変換結果は必ず修正が必要となる。あくまでちょっと手間が減る、という程度

使い方

第1引数に入力ファイル、第2に引数に出力ファイルを指定する。 出力ファイルを指定しない場合は標準出力に出力される。

$ python rfctxt2.py rfcxxxx.txt [rfcxxxx-formatted.txt]

説明

RFCのテキストは「テキスト文書」として見やすいように適当な場所に改ページやヘッダ・フッタ・改行が入っているため、そのまま翻訳サイトに放り込むとうまく翻訳できない。 このスクリプトは自動翻訳させるために余計なものを削除する。

行を連結するかどうかの基本的な条件は以下の通り。

  • 空行の前後は連結しない
  • 1行の長さが60文字以下の場合は次の行と連結しない
  • 行末がピリオドの場合は次の行と連結しない
  • 行頭が箇条書きと判断される場合は前の行と連結しない
    • o などの箇条書きマークで始まる場合
    • 数字とピリオドからなる箇条書き番号で始まる場合

About

A script that rewrites an RFC text file written in English so that it does not break in the middle as a single sentence by removing headers and footers for page formatting and superfluous line breaks.

Resources

Stars

Watchers

Forks

Languages