3 # oki2cha.pl - 沖縄辞書のファイルを茶筌で使える形式のテキストに変換する
5 # $Id: oki2cha.pl,v 1.3 2003/04/25 06:15:56 void Exp $
7 # このスクリプトを使って、以下のように「okinawa.dic」を生成してください。
8 # $ cat ../*.dic | ./oki2cha.pl > okinawa.dic
9 # $ /usr/local/libexec/chasen/makeint okinawa.dic > okinawa.txt
10 # $ /usr/local/libexec/chasen/sortdic okinawa.txt > okinawa.int
11 # $ /usr/local/libexec/chasen/pattool -F okinawa
16 use lib $FindBin::Bin; # For search scripts/ODIC.pm
19 use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
29 'help|h' => \$help_only,
30 'skip-geta|g' => \$skip_geta
32 if (defined($help_only)) {
33 print STDERR "usage: $0 [--help|-h] [--skip-geta|-g]\n";
38 # JIS X 0208 に含まれていない文字を含む行を読み飛ばす
39 # 読み飛ばしにはコメントに「〓あり」マーカーが必要
40 next if (defined($skip_geta) && /〓あり/);
42 next if (/@@@/); # @@@のある行は読み飛ばす。
43 s/#.*$//; # `#'以降を取り去る
44 next if (/^\s*$/); # その結果空行になった行は読み飛ばす。
45 if (/(\S+)\s+(\S+)\s+(\S+)/) {
49 ODIC::check_phonate($phonate);
50 ODIC::check_word($word);
54 print STDERR "Error: $.: too few field number `$_'\n";
63 if ($class eq "普通名詞") {
64 print ODIC::to_eucjp("(品詞 (名詞 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
66 elsif ($class eq "サ変名詞") {
67 print ODIC::to_eucjp("(品詞 (名詞 サ変接続)) ((見出し語 ($word 2000)) (読み $phonate))\n");
69 elsif ($class eq "形動名詞") {
70 print ODIC::to_eucjp("(品詞 (名詞 形容動詞語幹)) ((見出し語 ($word 2000)) (読み $phonate))\n");
72 elsif ($class eq "姓") {
73 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 人名 姓)) ((見出し語 ($word 1000)) (読み $phonate))\n");
75 elsif ($class eq "名") {
76 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 人名 名)) ((見出し語 ($word 2000)) (読み $phonate))\n");
78 elsif ($class eq "その他の人名") {
79 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 人名 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
81 elsif ($class eq "単純地名") {
82 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 地域 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
84 elsif ($class eq "接尾語付き地名") {
85 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 地域 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
87 elsif ($class eq "組織名") {
88 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 組織)) ((見出し語 ($word 3000)) (読み $phonate))\n");
90 elsif ($class eq "その他固有名詞") {
91 print ODIC::to_eucjp("(品詞 (名詞 固有名詞 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
93 elsif ($class eq "副詞") {
94 print ODIC::to_eucjp("(品詞 (副詞 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
96 elsif ($class eq "接続詞") {
97 print ODIC::to_eucjp("(品詞 (接続詞)) ((見出し語 ($word 2000)) (読み $phonate))\n");
99 elsif ($class eq "感動詞") {
100 print ODIC::to_eucjp("(品詞 (感動詞)) ((見出し語 ($word 2000)) (読み $phonate))\n");
102 elsif ($class eq "形容詞") {
103 print ODIC::to_eucjp("(品詞 (形容詞 自立)) ((見出し語 ($word 2000)) (読み $phonate))\n");
105 elsif ($class eq "形容動詞") {
106 print ODIC::to_eucjp("(品詞 (名詞 形容動詞語幹)) ((見出し語 ($word 2000)) (読み $phonate))\n");
108 elsif ($class eq "接頭語") { # !!!
109 print ODIC::to_eucjp("(品詞 (接頭詞 名詞接続)) ((見出し語 ($word 2000)) (読み $phonate))\n");
111 elsif ($class eq "数字列接頭語") {
112 print ODIC::to_eucjp("(品詞 (接頭詞 数接続)) ((見出し語 ($word 2000)) (読み $phonate))\n");
114 elsif ($class eq "接尾語") {
115 print ODIC::to_eucjp("(品詞 (名詞 接尾 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
117 elsif ($class eq "人名接尾語") {
118 print ODIC::to_eucjp("(品詞 (名詞 接尾 人名)) ((見出し語 ($word 2000)) (読み $phonate))\n");
120 elsif ($class eq "地名接尾語") {
121 print ODIC::to_eucjp("(品詞 (名詞 接尾 地域)) ((見出し語 ($word 2000)) (読み $phonate))\n");
123 elsif ($class eq "組織名接尾語") {
124 print ODIC::to_eucjp("(品詞 (名詞 接尾 一般)) ((見出し語 ($word 2000)) (読み $phonate))\n");
126 elsif ($class eq "数字列接尾語") {
127 print ODIC::to_eucjp("(品詞 (名詞 接尾 助数詞)) ((見出し語 ($word 2000)) (読み $phonate))\n");
129 elsif ($class eq "成句") {
130 print ODIC::to_eucjp("(品詞 (名詞 引用文字列)) ((見出し語 ($word 2000)) (読み $phonate))\n");
132 elsif ($class eq "無品詞") {
133 print ODIC::to_eucjp("(品詞 (名詞 引用文字列)) ((見出し語 ($word 2000)) (読み $phonate))\n");
136 print STDERR "Error: $.: unknown class `$class': $phonate\t$word\n";
137 print ODIC::to_eucjp("$phonate,$word,$class\n");
150 ($sec, $min, $hour, $mday, $mon, $year) = localtime(time());
153 print ODIC::to_eucjp("(品詞 (名詞 引用文字列)) ((見出し語 ($year/$mon/$mday沖縄辞書の日付け 2000)) (読み おきなわじしょのひづけ))\n");