From: imiyazaki Date: Fri, 14 Mar 2003 12:45:13 +0000 (+0000) Subject: add reverse map. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0845660ee3a837843b2e93bfb7977eb0a4f55fc1;p=chise%2Fperl.git add reverse map. --- diff --git a/Chise_utils/sample.PL b/Chise_utils/sample.PL index 27d5cf5..4ac5c89 100644 --- a/Chise_utils/sample.PL +++ b/Chise_utils/sample.PL @@ -3,7 +3,7 @@ use Getopt::Long; use strict; use vars qw($atr $value $char - $opt_map $opt_mapfrom $opt_mapto + $opt_map $opt_rev_map $opt_mapfrom $opt_mapto $opt_atr $opt_allatr $opt_showatr $opt_query $opt_help @@ -12,6 +12,7 @@ use Chise_utils ':all'; my $usage=< | --map | + -r | --mapfrom | --mapto | -q | @@ -33,6 +34,7 @@ EOF &GetOptions("mapto=s"=>\$opt_mapto, "mapfrom=s"=>\$opt_mapfrom, "m=s"=>\$opt_map, + "r=s"=>\$opt_rev_map, "a=s"=>\$opt_atr, "aa"=>\$opt_allatr, "show-attribute"=>\$opt_showatr, @@ -41,7 +43,7 @@ EOF "h",\$opt_help); if($opt_help - or !((($opt_map or $opt_mapfrom or $opt_mapto) and @ARGV==0) + or !((($opt_map or $opt_rev_map or $opt_mapfrom or $opt_mapto) and @ARGV==0) or($opt_showatr and @ARGV==0) or @ARGV==1 ) @@ -59,6 +61,7 @@ if($opt_mapfrom){ } if($opt_map){ + &get_db($opt_map); if(defined(%{$chardb{$opt_map}})){ foreach $char (sort keys %{$chardb{$opt_map}}){ if($chardb{$opt_map}->{$char}){ @@ -68,12 +71,23 @@ if($opt_map){ }else{ print STDERR "No map for $opt_map.\n"; } +}elsif($opt_rev_map){ + &get_reverse_db($opt_rev_map); + if(defined(%{$reverse_chardb{$opt_rev_map}})){ + foreach $char (sort keys %{$reverse_chardb{$opt_rev_map}}){ + if($reverse_chardb{$opt_rev_map}->{$char}){ + print $char,"\t",$reverse_chardb{$opt_rev_map}->{$char},"\n"; + } + } + }else{ + print STDERR "No map for $opt_rev_map.\n"; + } }elsif($opt_allatr){ $char=&de_er($char) if($char=~/\d/); print $char,"\n"; foreach $atr (sort keys %db){ - if($chardb{$atr}->{"?$char"}){ - print " ",$atr,":",$chardb{$atr}->{"?$char"},"\n"; + if($value=&get_char_attribute($char,$atr)){ + print " ",$atr,":",$value,"\n"; } } }elsif($opt_atr){ @@ -81,9 +95,14 @@ if($opt_map){ print $char,"\n"; print " ",$opt_atr,":",&get_char_attribute($char,$opt_atr),"\n"; }elsif($opt_showatr){ +# print "In DB\n"; foreach $atr (sort keys %db){ - print $atr,"\n"; + print " ",$atr,"\n"; } +# print "In reverse DB\n"; +# foreach $atr (sort keys %reverse_db){ +# print " ",$atr,"\n"; +# } }elsif($opt_query){ my $query=$char; print join "\n",&get_chars_for($query),"\n";