Created
May 10, 2011 02:22
-
-
Save koko-u/963817 to your computer and use it in GitHub Desktop.
英辞郎のTXTファイルをStardictの扱えるTAB形式に変換
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# 英辞郎が提供する txt ファイルを Stardict が読める .tab 形式に変換する | |
# iconv の Shift_jis -> Utf-8 変換はうまくないみたいなので、nkf を使いましょう。 | |
# cat EIJI-129.TXT | nkf -w8Lu | ./mkstardicttab > eijirou.tab | |
# 最終的には stardict-tools の tabfile を使って | |
# /usr/lib/stardict-tools/tabfile eijirou.tab | |
# としてできたファイルを /usr/share/stardict/dic に置く | |
ARGF.each do |line| | |
attr = line[/ \{(.+?)\}/, 1] | |
key, content = line.gsub('■・', '\n・').gsub(/■/, '').sub(/ \{(.+?)\}/, '').split(' : ') | |
puts "#{key}\t#{"【#{attr}】" if attr}#{content}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment