/usr/share/skktools/convert2skk/ctdicconv.rb is in skktools 1.3.3-2+b1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #!/usr/bin/ruby -Ke
# -*- coding: euc-jp -*-
require 'jcode' if RUBY_VERSION.to_f < 1.9
# ctdicconv.rb -- convert china_taiwan.csv to SKK-JISYO dictionary format.
#
# Copyright (C) 2002 NAKAJIMA Mikio <minakaji@osaka.email.ne.jp>
#
# Author: NAKAJIMA Mikio <minakaji@osaka.email.ne.jp>
# Created: Aug 2, 2002
# Last Modified: $Date: 2013/05/26 09:47:48 $
# Version: $Id: ctdicconv.rb,v 1.3 2013/05/26 09:47:48 skk-cvs Exp $
# This file is part of Daredevil SKK.
# Daredevil SKK is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either versions 2, or (at your option)
# any later version.
#
# Daredevil SKK is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Daredevil SKK, see the file COPYING. If not, write to the
# Free Software Foundation Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Commentary:
$ANNOTATION = true
##$ANNOTATION = false
# from ¡Ö¥ª¥Ö¥¸¥§¥¯¥È»Ø¸þ¥¹¥¯¥ê¥×¥È¸À¸ìruby¡×p121
def csv_split(source, delimiter = ',')
csv = []
data = ""
source.split(delimiter).each do |d|
if data.empty?
data = d
else
data += delimiter + d
end
if /^"/ =~ data
if /[^"]"$/ =~ data or '""' == data
csv << data.sub(/^"(.*)"$/, '\1').gsub(/""/, '"')
data = ''
end
else
csv << d
data = ''
end
end
raise "cannot decode CSV\n" unless data.empty?
csv
end
file = ARGV.shift
if not file
print "¥Õ¥¡¥¤¥ë¤ò»ØÄꤷ¤Æ²¼¤µ¤¤\n"
else
first = true
File.foreach(file) do |line|
if first
first = false
next
end
#Ãæ¹ñ¡¦ÂæÏÑ,¼ïÊÌ,±Ñ¸ì¸«½Ð¤·,´Á»ú,ÆüËܸìÆɤß,Ãæ¹ñ¸ìÆɤߡʥ«¥¿¥«¥Ê¡Ë,±Ñ¸ìɸµ2,´Á»úÊÌ̾,´Á»úÊÌ̾Æɤß,¾ÊÅÔ,¾ÊÅÔÆɤß,annotation
c_t,d,e_key,kanji,j_key,c_key,english,kanji_alias,kanji_alias_key,capital,capital_key,annotation= csv_split(line.chomp)
if (e_key && !e_key.empty? && kanji && !kanji.empty?)
e_key.strip!
kanji.strip!
# ±Ñ¸ì¸«½Ð¤· /´Á»ú/
if ($ANNOTATION && annotation && !annotation.empty?)
annotation.strip!
print e_key, " /", kanji, ";", annotation, "/\n"
else
print e_key, " /", kanji, "/\n"
end
# ÆüËܸ츫½Ð¤· /Capitalized ±Ñ¸ì/
if (j_key && !j_key.empty?)
j_key.strip!
if ($ANNOTATION && annotation && !annotation.empty?)
annotation.strip!
print j_key, " /", e_key.capitalize, ";", annotation, "/\n"
else
print j_key, " /", e_key.capitalize, "/\n"
end
end
end
if (j_key && !j_key.empty? && kanji && !kanji.empty?)
# ÆüËܸ츫½Ð¤· /´Á»ú/
if ($ANNOTATION && annotation && !annotation.empty?)
annotation.strip!
print j_key, " /", kanji, ";", annotation, "/\n"
else
print j_key, " /", kanji, "/\n"
end
end
if (c_key && !c_key.empty? && kanji && !kanji.empty?)
c_key.strip!
c_key.tr!("¥¡-¥ó", "¤¡-¤ó")
# Ãæ¹ñ¸ì¸«½Ð¤· /´Á»ú/
if ($ANNOTATION && annotation && !annotation.empty?)
print c_key, " /", kanji, ";", annotation, "/\n"
else
print c_key, " /", kanji, "/\n"
end
end
# ´Á»úÊÌ̾¸«½Ð¤· /´Á»úÊÌ̾/
if (kanji_alias && kanji_alias_key &&
!kanji_alias.empty? && !kanji_alias_key.empty?)
if ($ANNOTATION && annotation && !annotation.empty?)
print kanji_alias_key, " /", kanji_alias, ";", annotation, "/\n"
else
print kanji_alias_key, " /", kanji_alias, "/\n"
end
end
# ¾ÊÅÔ¸«½Ð¤· /¾ÊÅÔ/
#if (capital && capital_key &&
# !capital.empty? && !capital_key.empty?)
# print capital_key, " /", capital, "/\n"
#end
end
end
# end of ctdicconv.rb
|