-#-----------------------------------------------------------------------------\r
-use utf8;\r
-binmode STDOUT, ":utf8";\r
-require 'chiseperl.pl';\r
-use Encode;\r
-\r
-$rate = 0.75;\r
-$x = -10;\r
-$y = 14;\r
-%char = ();\r
-%link = ();\r
-%family = ();\r
-%object = ();\r
-@list= ();\r
-#$file = "map";\r
-$file= @ARGV[1];\r
-$txt = "txt";\r
-$png = "png";\r
-$svg = "svg";\r
-#$graphviz = '"C:\Program Files\ATT\Graphviz\bin\dot.exe"';\r
-$graphviz = '/usr/local/bin/dot';\r
-$html = "html";\r
-$fontGB = "SimSun";\r
-$fontJP = "'MS 明朝'";\r
-$fontUCS = "'MS 明朝', SimSun, 'SimSun (Founder Extended)'";\r
-$fontBIG5 = "MingLiU";\r
-$fontKS = "BatangChe";\r
-\r
-#-----------------------------------------------------------------------------\r
-&init_chise;\r
-\r
-foreach(@chise_feature){\r
- if($_ !~ m/sources/){\r
- push(@list, $_);\r
- }\r
-}\r
-\r
-&process(eval('0x'.$ARGV[0]));\r
-\r
-#-----------------------------------------------------------------------------\r
-\r
-# create txt\r
-open FH, ">:utf8", "$file.$txt";\r
-print FH "digraph g{\r\n";\r
-print FH "\trankdir = \"LR\";\r\n";\r
-$be_child = ",".join(",", values(%family)).",";\r
-foreach(sort(keys %family)){\r
- if($be_child =~ m/,$_,/){\r
- next;\r
- }\r
- &ireko($_,1);\r
-}\r
-foreach(sort(keys %char)){\r
- printf FH "\t\"%X\" [ label = \"$char{$_}\", shape = \"record\" ];\r\n", $_;\r
- #printf FH "\t\"%X\" [ label = \"$char{$_}\", shape = \"record\", fontname = \"simhei.ttf\" ];\r\n", $_;\r
-}\r
-foreach(sort(keys %link)){\r
- @temp = split(/-/, $_);\r
- printf FH "\t\"%X\" -> \"%X\" [ label = \"$link{$_}\" ];\r\n", $temp[0], $temp[1];\r
-}\r
-print FH "}\r\n";\r
-close FH;\r
-\r
-#create png\r
-$dummy = `$graphviz -Tpng -o$file.$png $file.$txt`;\r
-\r
-#create svg\r
-$dummy = `$graphviz -Tsvg -o$file.$svg $file.$txt`;\r
-\r
-#create html\r
-open FH, "<:utf8", "$file.$svg";\r
-open FH2, ">:utf8", "$file.$html";\r
-print FH2 <<EOT;\r
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">\r
-<head>\r
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
-</head>\r
-<body>\r
-<img src="$file.$png" usemap="#object" border="0">\r
-EOT\r
-foreach(<FH>){\r
- if(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=cns11643\&\#45\;([1-9])\:([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";\r
- print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/CNS$3/$4.gif\">\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jef\&\#45\;china3\:([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- $target = $3;\r
- $target =~ tr/A-F/a-f/;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";\r
- print FH2 "<img src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/$target.gif\" width=\"40\" height=\"40\">\r\n";\r
- print FH2 "</div>";\r
- #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){\r
- # $left = int($1 / $rate) + $x;\r
- # $top = int($2 / $rate) + $y;\r
- # print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";\r
- # $ku = int(eval('0x'.$3) / 0x100) - 0x20;\r
- # $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20;\r
- # print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/GB0/$ku-$ten.gif\">\r\n";\r
- # print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontGB; font-size: 40px;\">";\r
- $char = $3;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'gb2312-raw', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\@19(78|83|90|97)\:([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";\r
- $ku = int(eval('0x'.$4) / 0x100) - 0x20;\r
- $ten = sprintf "%02d", eval('0x'.$4) % 0x100 - 0x20;\r
- print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/JIS-$3/$ku-$ten.gif\">\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0212\:([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";\r
- $ku = int(eval('0x'.$3) / 0x100) - 0x20;\r
- $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20;\r
- print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/JIS-SP/$ku-$ten.gif\">\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=zinbun\&\#45;oracle\:([0-9A-F]{1,4})/){\r
- $left = int($1 / $rate) + $x - 20;\r
- $top = int($2 / $rate) + $y;\r
- my $number = sprintf "%04d", eval('0x'.$3);\r
- print FH2 "<img style=\"position: absolute; top: $top; left: $left;\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/ZOB-1968/$number.png\" width=\"80\" height=\"80\">";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ucs\:([0-9A-F]{4,6})/){\r
- $left = int($1 / $rate) + $x - 20;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontUCS; font-size: 40px;\">";\r
- print FH2 "[".pack('U',eval('0x'.$3))."]\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\:([0-9A-F]{4,6})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontBIG5; font-size: 40px;\">";\r
- $char = $3;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'big5', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=hanziku\&\#45\;([0-9]{1,2})\:([0-9A-F]{4})/){\r
- # $left = int($1 / $rate) + $x;\r
- # $top = int($2 / $rate) + $y;\r
- # #$number = sprintf "%02d", $3;\r
- # $number = $3;\r
- # $numberk = $3;\r
- # $numberk =~ tr/12345678/一二三四五六七八/;\r
- # #print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: 'hzk${number}u'; font-size: 40px;\">";\r
- # print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: '細明體外字集$numberk'; font-size: 40px;\">";\r
- # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=hanziku-$number"), eval('0x'.$4)));\r
- # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=big5"), eval('0x'.$4)));\r
- # $char = $4;\r
- # $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- # Encode::from_to($char, 'big5', 'utf-8');\r
- # utf8::decode($char);\r
- # print FH2 "$char\r\n";\r
- # print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\&\#45\;cdp\:([0-9A-F]{4,6})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: EUDC; font-size: 40px;\">";\r
- printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar('=big5-pua'), eval('0x'.$3)));\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\:([0-9A-F]{4,6})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontJP; font-size: 40px;\">";\r
- $char = $3;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'jis0208-raw', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ks\&\#45\;x1001\:([0-9A-F]{4,6})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontKS; font-size: 40px;\">";\r
- $char = $3;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'ksc5601-raw', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;([0-9]{1,2}):([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- $number = sprintf("%02d", $3);\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: GT2000-$number; font-size: 40px;\">";\r
- $char = $4;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'jis0208-raw', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;(k[12]):([0-9A-F]{4})/){\r
- $left = int($1 / $rate) + $x;\r
- $top = int($2 / $rate) + $y;\r
- print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: GT2000-$3; font-size: 40px;\">";\r
- $char = $4;\r
- $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;\r
- Encode::from_to($char, 'jis0208-raw', 'utf-8');\r
- utf8::decode($char);\r
- print FH2 "$char\r\n";\r
- print FH2 "</div>";\r
- }\r
-}\r
-\r
-print FH2 "<map name=\"object\">\n";\r
-seek FH, 0, 0;\r
-$i = 0;\r
-foreach(<FH>){\r
- if($i == 1){\r
- m/points=\"[0-9]+,[0-9]+ ([0-9]+),([0-9]+) [0-9]+,[0-9]+ ([0-9]+),([0-9]+) /;\r
- print FH2 "<area href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=%26u-$target%3B\" shape=\"rect\" coords=\"".int($3 / $rate).", ".int($4 / $rate).", ".int($1 / $rate).", ".int($2 / $rate)."\">\n";\r
- $i = 0;\r
- }\r
- elsif(m/^<g id=\"node[0-9]+\" class=\"node\"><title>(2{0,1}[0-9A-F]{4})<\/title>\n$/){\r
- $target = $1;\r
- $i = 1;\r
- }\r
-}\r
-print FH2 "</map>\n";\r
-close FH;\r
-\r
-print FH2 <<EOT;\r
-</body>\r
-</html>\r
-EOT\r
-close FH2;\r
-\r
-&close_chise;\r
-\r
-#-----------------------------------------------------------------------------\r
-sub process{\r
- my ($buffer, @buffer, $feature);\r
- if(exists($char{$_[0]})){\r
- return;\r
- }\r
- \r
- #S-exporession\r
- if($_[0] =~ m/^\(\(/){\r
- $char{$_[0]} .= "$_[0]\\n";\r
- next;\r
- }\r
- \r
- #ccs-feature\r
- foreach(@list){\r
- if((substr($_,0,1) eq '=' && substr($_,1,1) ne '>') || $_ eq "morohashi-daikanwa"){\r
- $buffer = get_feature_value($_, $_[0]);\r
- if($buffer ne ""){\r
- if($_ eq "=daikanwa" || $_ eq "=gt" || $_ eq "=gt-k"){\r
- $char{$_[0]} .= sprintf("$_:%05d\\n", $buffer);\r
- #} elsif($_ =~ m/^\=(gt-pj-[0-9]{1,2}|gt-pj-k[12]|big5|big5-cdp|jis-x0208|ks-x1001|ucs|cns11643-[1-9]|gb2312|jis-x0208\@1978|jis-x0208\@1983|jis-x0208\@1990|jis-x0208\@1997|jis-x0212|hanziku-[1-8]|jef-china3)$/){\r
- } elsif($_ =~ m/^\=(gt-pj-[0-9]{1,2}|gt-pj-k[12]|big5|big5-cdp|jis-x0208|ks-x1001|ucs|cns11643-[1-9]|gb2312|jis-x0208\@1978|jis-x0208\@1983|jis-x0208\@1990|jis-x0208\@1997|jis-x0212|jef-china3)$/){\r
- $char{$_[0]} .= sprintf("$_:%X\\n \\n \\n", $buffer);\r
- } elsif($_ =~ m/^\=(zinbun-oracle)$/){\r
- $char{$_[0]} .= sprintf("$_:%X\\n \\n \\n \\n \\n", $buffer);\r
- } elsif($_ eq "morohashi-daikanwa"){\r
- $char{$_[0]} .= "$_:$buffer\\n";\r
- } else {\r
- $char{$_[0]} .= sprintf("$_:%X\\n", $buffer);\r
- }\r
- }\r
- }\r
- }\r
- #goto-feature\r
- foreach(@list){\r
- if(substr($_,0,2) eq '->'){\r
- $buffer = get_feature_value($_, $_[0]);\r
- if($buffer ne ""){\r
- $feature = $_;\r
- @buffer = &parse($buffer);\r
- if(scalar(@buffer) == 0){\r
- next;\r
- }\r
- foreach(@buffer){\r
- if($feature eq "->subsumptive" || $feature eq "->denotational"){\r
- $family{$_[0]} .= "$_,";\r
- &process($_);\r
- } else {\r
- $feature =~ s/->//;\r
- $link{$_[0]."-".$_} .= $feature."\\n";\r
- &process($_);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- #comefrom-feature\r
- foreach(@list){\r
- if(substr($_,0,2) eq '<-'){\r
- $buffer = get_feature_value($_, $_[0]);\r
- if($buffer ne ""){\r
- $feature = $_;\r
- @buffer = &parse($buffer);\r
- if(scalar(@buffer) == 0){\r
- next;\r
- }\r
- foreach(@buffer){\r
- #$link{$_."-".$_[0]} .= $feature."\\n";\r
- &process($_);\r
- }\r
- }\r
- }\r
- }\r
- #nearlyequal-feature\r
- foreach(@list){\r
- if(substr($_,0,2) eq '=>'){\r
- $buffer = get_feature_value($_, $_[0]);\r
- if($buffer ne ""){\r
- $feature = $_;\r
- @buffer = &parse($buffer);\r
- if(scalar(@buffer) == 0){\r
- next;\r
- }\r
- foreach(@buffer){\r
- $link{$_."-".$_[0]} .= $feature."\\n";\r
- &process($_);\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-sub parse{\r
- my $target = $_[0];\r
- my (@temp, @temp2);\r
- utf8::decode($target);\r
- if(substr($target,0,1) eq '('){\r
- if(substr($target,0,2) eq '(('){ # feature is S-expression\r
- push(@temp2, substr($target,1,length($substr)-1));\r
- } else {\r
- @temp = split(/ /, substr($target, 1, length($target) - 2));\r
- foreach(@temp){\r
- push(@temp2, unpack('U*', substr($_, 1)));\r
- }\r
- }\r
- return @temp2;\r
- } else{\r
- }\r
-}\r
-\r
-sub ireko{\r
- my @temp = split(/,/, $family{$_[0]});\r
- printf FH "\t"x$_[1]."subgraph cluster%X\ {\n", $_[0];\r
- if($_[1] == 1){\r
- printf FH "\t\t\"%X\" [ color = white ];\n", $_[0];\r
- } else { \r
- printf FH "\t"x($_[1] + 1)."style = filled; color = gray%d;\n", 100 - ($_[1] - 1) * 20;\r
- printf FH "\t"x($_[1] + 1)."\"%X\" [ color = gray%d ];\n", $_[0], 100 - ($_[1] - 1) * 20;\r
- }\r
- foreach(@temp){\r
- if(exists($family{$_})){\r
- &ireko($_, $_[1]+1);\r
- } else{\r
- printf FH "\t"x($_[1] + 1)."\"%X\";\n", $_;\r
- }\r
- }\r
- print FH "\t"x$_[1]."}\n";\r
-}\r
-#-----------------------------------------------------------------------------\r
+#-----------------------------------------------------------------------------
+use utf8;
+binmode STDOUT, ":utf8";
+require 'chiseperl.pl';
+use Encode;
+
+$rate = 0.75;
+$x = -10;
+$y = 14;
+%char = ();
+%link = ();
+%family = ();
+%object = ();
+@list= ();
+#$file = "map";
+$file= @ARGV[1];
+$txt = "txt";
+$png = "png";
+$svg = "svg";
+#$graphviz = '"C:\Program Files\ATT\Graphviz\bin\dot.exe"';
+$graphviz = '/usr/bin/dot';
+$html = "html";
+$fontGB = "serif, SimSun, 'AR_PL_ShanHeiSun_Uni', 'AR_PL_SungtiL_GB', '文鼎PL简报宋', STSong";
+$fontJP = "'MS 明朝', 'IPAMincho', 'Sazanami Mincho', 'ヒラギノ明朝 Pro W3', HiraMinPro-W3";
+$fontUCS = "'MS 明朝', 'IPAMincho', 'Sazanami Mincho', SimSun, 'SimSun (Founder Extended)', 'AR_PL_ShanHeiSun_Uni', 'AR_PL_Mingti2L_Big5', 'AR_PL_SungtiL_GB', '文鼎PL简报宋', '文鼎PL細上海宋', UnBatang, 'Baekmuk Batang', '은 신문', 'ヒラギノ明朝 Pro W3', STSong, 'LiSong Pro', AppleMyungjo";
+$fontBIG5 = "MingLiU, 'AR_PL_Mingti2L_Big5', '文鼎PL細上海宋', 'LiSong Pro'";
+$fontKS = "BatangChe, UnBatang, 'Baekmuk Batang', '은 신문', AppleMyungjo";
+
+#-----------------------------------------------------------------------------
+&init_chise;
+
+foreach(@chise_feature){
+ if($_ !~ m/sources/){
+ push(@list, $_);
+ }
+}
+
+&process(eval('0x'.$ARGV[0]));
+
+#-----------------------------------------------------------------------------
+
+# create txt
+open FH, ">:utf8", "$file.$txt";
+print FH "digraph g{\r\n";
+print FH "\trankdir = \"LR\";\r\n";
+$be_child = ",".join(",", values(%family)).",";
+foreach(sort(keys %family)){
+ if($be_child =~ m/,$_,/){
+ next;
+ }
+ &ireko($_,1);
+}
+foreach(sort(keys %char)){
+ printf FH "\t\"%X\" [ label = \"$char{$_}\", shape = \"record\" ];\r\n", $_;
+ #printf FH "\t\"%X\" [ label = \"$char{$_}\", shape = \"record\", fontname = \"simhei.ttf\" ];\r\n", $_;
+}
+foreach(sort(keys %link)){
+ @temp = split(/-/, $_);
+ printf FH "\t\"%X\" -> \"%X\" [ label = \"$link{$_}\" ];\r\n", $temp[0], $temp[1];
+}
+print FH "}\r\n";
+close FH;
+
+#create png
+$dummy = `$graphviz -Tpng -o$file.$png $file.$txt`;
+
+#create svg
+$dummy = `$graphviz -Tsvg -o$file.$svg $file.$txt`;
+
+#<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+
+#create html
+open FH, "<:utf8", "$file.$svg";
+open FH2, ">:utf8", "$file.$html";
+print FH2 <<EOT;
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+<img src="$file.$png" usemap="#object" border="0">
+EOT
+foreach(<FH>){
+ if(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=cns11643\&\#45\;([1-9])\:([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";
+ print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/CNS$3/$4.gif\">\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jef\&\#45\;china3\:([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ $target = $3;
+ $target =~ tr/A-F/a-f/;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";
+ print FH2 "<img src=\"http://kanji.zinbun.kyoto-u.ac.jp/db/CHINA3/Gaiji/$target.gif\" width=\"40\" height=\"40\">\r\n";
+ print FH2 "</div>";
+ #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){
+ # $left = int($1 / $rate) + $x;
+ # $top = int($2 / $rate) + $y;
+ # print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";
+ # $ku = int(eval('0x'.$3) / 0x100) - 0x20;
+ # $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20;
+ # print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/GB0/$ku-$ten.gif\">\r\n";
+ # print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontGB; font-size: 40px;\">";
+ $char = $3;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'gb2312-raw', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\@19(78|83|90|97)\:([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";
+ $ku = int(eval('0x'.$4) / 0x100) - 0x20;
+ $ten = sprintf "%02d", eval('0x'.$4) % 0x100 - 0x20;
+ print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/JIS-$3/$ku-$ten.gif\">\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0212\:([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left;\">";
+ $ku = int(eval('0x'.$3) / 0x100) - 0x20;
+ $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20;
+ print FH2 "<img src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/JIS-SP/$ku-$ten.gif\">\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=zinbun\&\#45;oracle\:([0-9A-F]{1,4})/){
+ $left = int($1 / $rate) + $x - 20;
+ $top = int($2 / $rate) + $y;
+ my $number = sprintf "%04d", eval('0x'.$3);
+ print FH2 "<img style=\"position: absolute; top: $top; left: $left;\" src=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/glyphs/ZOB-1968/$number.png\" width=\"80\" height=\"80\">";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ucs\:([0-9A-F]{4,6})/){
+ $left = int($1 / $rate) + $x - 20;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontUCS; font-size: 40px;\">";
+ print FH2 "[".pack('U',eval('0x'.$3))."]\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\:([0-9A-F]{4,6})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontBIG5; font-size: 40px;\">";
+ $char = $3;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'big5', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=hanziku\&\#45\;([0-9]{1,2})\:([0-9A-F]{4})/){
+ # $left = int($1 / $rate) + $x;
+ # $top = int($2 / $rate) + $y;
+ # #$number = sprintf "%02d", $3;
+ # $number = $3;
+ # $numberk = $3;
+ # $numberk =~ tr/12345678/一二三四五六七八/;
+ # #print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: 'hzk${number}u'; font-size: 40px;\">";
+ # print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: '細明體外字集$numberk'; font-size: 40px;\">";
+ # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=hanziku-$number"), eval('0x'.$4)));
+ # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=big5"), eval('0x'.$4)));
+ # $char = $4;
+ # $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ # Encode::from_to($char, 'big5', 'utf-8');
+ # utf8::decode($char);
+ # print FH2 "$char\r\n";
+ # print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\&\#45\;cdp\:([0-9A-F]{4,6})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: EUDC; font-size: 40px;\">";
+ printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar('=big5-pua'), eval('0x'.$3)));
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\:([0-9A-F]{4,6})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontJP; font-size: 40px;\">";
+ $char = $3;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'jis0208-raw', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ks\&\#45\;x1001\:([0-9A-F]{4,6})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: $fontKS; font-size: 40px;\">";
+ $char = $3;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'ksc5601-raw', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;([0-9]{1,2}):([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ $number = sprintf("%02d", $3);
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: GT2000-$number; font-size: 40px;\">";
+ $char = $4;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'jis0208-raw', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;(k[12]):([0-9A-F]{4})/){
+ $left = int($1 / $rate) + $x;
+ $top = int($2 / $rate) + $y;
+ print FH2 "<div style=\"position: absolute; top: $top; left: $left; font-family: GT2000-$3; font-size: 40px;\">";
+ $char = $4;
+ $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg;
+ Encode::from_to($char, 'jis0208-raw', 'utf-8');
+ utf8::decode($char);
+ print FH2 "$char\r\n";
+ print FH2 "</div>";
+ }
+}
+
+print FH2 "<map name=\"object\">\n";
+seek FH, 0, 0;
+$i = 0;
+foreach(<FH>){
+ if($i == 1){
+ m/points=\"[0-9]+,[0-9]+ ([0-9]+),([0-9]+) [0-9]+,[0-9]+ ([0-9]+),([0-9]+) /;
+ print FH2 "<area href=\"http://mousai.kanji.zinbun.kyoto-u.ac.jp/char-desc?char=%26u-$target%3B\" shape=\"rect\" coords=\"".int($3 / $rate).", ".int($4 / $rate).", ".int($1 / $rate).", ".int($2 / $rate)."\">\n";
+ $i = 0;
+ }
+ elsif(m/^<g id=\"node[0-9]+\" class=\"node\"><title>(2{0,1}[0-9A-F]{4})<\/title>\n$/){
+ $target = $1;
+ $i = 1;
+ }
+}
+print FH2 "</map>\n";
+close FH;
+
+print FH2 <<EOT;
+</body>
+</html>
+EOT
+close FH2;
+
+&close_chise;
+
+#-----------------------------------------------------------------------------
+sub process{
+ my ($buffer, @buffer, $feature);
+ if(exists($char{$_[0]})){
+ return;
+ }
+
+ #S-exporession
+ if($_[0] =~ m/^\(\(/){
+ $char{$_[0]} .= "$_[0]\\n";
+ next;
+ }
+
+ #ccs-feature
+ foreach(@list){
+ if((substr($_,0,1) eq '=' && substr($_,1,1) ne '>') || $_ eq "morohashi-daikanwa"){
+ $buffer = get_feature_value($_, $_[0]);
+ if($buffer ne ""){
+ if($_ eq "=daikanwa" || $_ eq "=gt" || $_ eq "=gt-k"){
+ $char{$_[0]} .= sprintf("$_:%05d\\n", $buffer);
+ #} elsif($_ =~ m/^\=(gt-pj-[0-9]{1,2}|gt-pj-k[12]|big5|big5-cdp|jis-x0208|ks-x1001|ucs|cns11643-[1-9]|gb2312|jis-x0208\@1978|jis-x0208\@1983|jis-x0208\@1990|jis-x0208\@1997|jis-x0212|hanziku-[1-8]|jef-china3)$/){
+ } elsif($_ =~ m/^\=(gt-pj-[0-9]{1,2}|gt-pj-k[12]|big5|big5-cdp|jis-x0208|ks-x1001|ucs|cns11643-[1-9]|gb2312|jis-x0208\@1978|jis-x0208\@1983|jis-x0208\@1990|jis-x0208\@1997|jis-x0212|jef-china3)$/){
+ $char{$_[0]} .= sprintf("$_:%X\\n \\n \\n", $buffer);
+ } elsif($_ =~ m/^\=(zinbun-oracle)$/){
+ $char{$_[0]} .= sprintf("$_:%X\\n \\n \\n \\n \\n", $buffer);
+ } elsif($_ eq "morohashi-daikanwa"){
+ $char{$_[0]} .= "$_:$buffer\\n";
+ } else {
+ $char{$_[0]} .= sprintf("$_:%X\\n", $buffer);
+ }
+ }
+ }
+ }
+ #goto-feature
+ foreach(@list){
+ if(substr($_,0,2) eq '->'){
+ $buffer = get_feature_value($_, $_[0]);
+ if($buffer ne ""){
+ $feature = $_;
+ @buffer = &parse($buffer);
+ if(scalar(@buffer) == 0){
+ next;
+ }
+ foreach(@buffer){
+ if($feature eq "->subsumptive" || $feature eq "->denotational"){
+ $family{$_[0]} .= "$_,";
+ &process($_);
+ } else {
+ $feature =~ s/->//;
+ $link{$_[0]."-".$_} .= $feature."\\n";
+ &process($_);
+ }
+ }
+ }
+ }
+ }
+ #comefrom-feature
+ foreach(@list){
+ if(substr($_,0,2) eq '<-'){
+ $buffer = get_feature_value($_, $_[0]);
+ if($buffer ne ""){
+ $feature = $_;
+ @buffer = &parse($buffer);
+ if(scalar(@buffer) == 0){
+ next;
+ }
+ foreach(@buffer){
+ #$link{$_."-".$_[0]} .= $feature."\\n";
+ &process($_);
+ }
+ }
+ }
+ }
+ #nearlyequal-feature
+ foreach(@list){
+ if(substr($_,0,2) eq '=>'){
+ $buffer = get_feature_value($_, $_[0]);
+ if($buffer ne ""){
+ $feature = $_;
+ @buffer = &parse($buffer);
+ if(scalar(@buffer) == 0){
+ next;
+ }
+ foreach(@buffer){
+ $link{$_."-".$_[0]} .= $feature."\\n";
+ &process($_);
+ }
+ }
+ }
+ }
+}
+
+sub parse{
+ my $target = $_[0];
+ my (@temp, @temp2);
+ utf8::decode($target);
+ if(substr($target,0,1) eq '('){
+ if(substr($target,0,2) eq '(('){ # feature is S-expression
+ push(@temp2, substr($target,1,length($substr)-1));
+ } else {
+ @temp = split(/ /, substr($target, 1, length($target) - 2));
+ foreach(@temp){
+ push(@temp2, unpack('U*', substr($_, 1)));
+ }
+ }
+ return @temp2;
+ } else{
+ }
+}
+
+sub ireko{
+ my @temp = split(/,/, $family{$_[0]});
+ printf FH "\t"x$_[1]."subgraph cluster%X\ {\n", $_[0];
+ if($_[1] == 1){
+ printf FH "\t\t\"%X\" [ color = white ];\n", $_[0];
+ } else {
+ printf FH "\t"x($_[1] + 1)."style = filled; color = gray%d;\n", 100 - ($_[1] - 1) * 20;
+ printf FH "\t"x($_[1] + 1)."\"%X\" [ color = gray%d ];\n", $_[0], 100 - ($_[1] - 1) * 20;
+ }
+ foreach(@temp){
+ if(exists($family{$_})){
+ &ireko($_, $_[1]+1);
+ } else{
+ printf FH "\t"x($_[1] + 1)."\"%X\";\n", $_;
+ }
+ }
+ print FH "\t"x$_[1]."}\n";
+}
+#-----------------------------------------------------------------------------