辞書編集ツール

戻る

# edit1.pl 07.07.20,22 use strict; my(%t,$n,$n1,@fld); open(FH,"d001.txt") or die "Can't open the file d001.txt\n"; while(<FH>){ @fld = split; next until $fld[1]; $t{e1} = $fld[0]; for $n ( 1 .. ($#fld-1) ) { $t{e1} = $t{e1} . ' ' . $fld[$n]; } $t{c1} = $fld[$#fld]; if ( $t{eclist}{$t{e1}} ) { # 同じ言葉の対策 print "Line=$.\n"; exit; } $t{eclist}{$t{e1}} = $t{c1}; } close(FH); @{ $t{eckeys} } = sort { lc($a) cmp lc($b) } keys %{ $t{eclist} }; open(OUT,">d002add.txt"); for $n ( 0 .. $#{ $t{eckeys} } ) { $t{e1} = $t{eckeys}[$n]; $t{c1} = $t{eclist}{$t{e1}}; $t{h1} = substr($t{e1},0,1); $t{h1} = uc($t{h1}); print OUT $t{h1},'==>'; print OUT $t{e1},'==>'; print OUT $t{c1},"\n"; } close(OUT); print "The output file is d002add.txt\n"; ------------------------------------------------------------------------------------ # edit2.pl 07.07.22,24 # Ordering use strict; my(%t,$n,@fld,@name); # Read orginal data open(FH,"d002org.txt") or die "Can't open the file d002org.txt\n"; while(<FH>){ chomp; @fld = split(/==>/); next until $fld[1]; $t{eclist}{$fld[1]} = $fld[2]; if ( $fld[2] =~ /^\w/) { print $.,"====>"; print $_,"\n"; # exit; } } close(FH); # Read add data $t{NO1}=0; open(OUT,">d002com.txt"); open(FH,"d002add.txt") or die "Can't open the file d002add.txt\n"; while(<FH>){ chomp; @fld = split(/==>/); next until $fld[1]; if ( $t{eclist}{$fld[1]} ) { $t{c1} = $t{eclist}{$fld[1]}; $t{h1} = substr($fld[1],0,1); $t{h1} = uc($t{h1}); print OUT 'ORG==>'; print OUT $t{h1},'==>'; print OUT $fld[1],'==>'; print OUT $t{c1},"\n"; print OUT 'NEW==>'; print OUT $_,"\n"; $t{NO1}++; printf ("Repeated!%3d\n",$t{NO1}); } else { $t{eclist}{$fld[1]} = $fld[2]; } } close(FH); close(OUT); # Output to a file open(OUT,">d002.txt"); for $n ( sort { lc($a) cmp lc($b) } keys %{ $t{eclist} } ) { $t{c1} = $t{eclist}{$n}; $t{h1} = substr($n,0,1); $t{h1} = uc($t{h1}); print OUT $t{h1},'==>'; print OUT $n,'==>'; print OUT $t{c1},"\n"; } close(OUT); print "The input files are d002add.txt and d002org.txt, output to d002.txt.\n"; __END__ ------------------------------------------------------------------------------------ # edit3.pl 07.07.20,22 # Output to a html file use strict; use HTML::Template; my(%t,$n,@fld,@name); my $template = HTML::Template->new(filename => 'dic0.htm'); my @loop = (); # Read raw data $t{NO1}=0; open(FH,"d002.txt") or die "Can't open the file d002.txt\n"; while(<FH>){ chomp; @fld = split(/==>/); next until $fld[1]; $t{NO1}++; push(@{ $t{NO} }, $t{NO1}); push(@{ $t{E1} }, $fld[1]); push(@{ $t{C1} }, $fld[2]); } close(FH); for $n ( 0 .. $#{ $t{NO} } ) { my %row = ( # N1 => $t{NO}[$n], C1 => $t{E1}[$n], E1 => $t{C1}[$n] ); push(@loop, \%row); } # Output to a html file $template->param(amount => $t{NO1}); $template->param(dic_loop => \@loop); open(OUT,">dic1.htm"); print OUT $template->output; close(OUT); ------------------------------------------------------------------------------------ # edit4.pl 07.08.24 # Output to a html file use strict; use HTML::Template; my(%t,$n,$n1,@fld,@name); # Read raw data $t{NO1}=0; open(FH,"d002.txt") or die "Can't open the file d002.txt\n"; open(OUT,">d002org.txt"); while(<FH>){ print OUT $_; chomp; @fld = split(/==>/); next until $fld[1]; $t{NO1}++; push(@{ $t{NO}{$fld[0]} }, $t{NO1}); push(@{ $t{E1}{$fld[0]} }, $fld[1]); push(@{ $t{C1}{$fld[0]} }, $fld[2]); } close(FH); close(OUT); for $n ( "A" .. "Z" ) { $t{htmfile} = lc($n) . '.htm'; my $template = HTML::Template->new(filename => './dic/index.html'); my @loop = (); $t{N1} = 0; for $n1 ( 0 .. $#{ $t{NO}{$n} } ) { $t{N1}++; my %row = ( C1 => $t{E1}{$n}[$n1], E1 => $t{C1}{$n}[$n1] ); push(@loop, \%row); } # Output to a html file $template->param(amount => $t{NO1}); $template->param(name => $n); $template->param(amount1 => $t{N1}); $template->param(dic_loop => \@loop); open(OUT,">./dic/$t{htmfile}"); print OUT $template->output; close(OUT); print "It was written to $t{htmfile}\n"; } exit; ------------------------------------------------------------------------------------ ############################ # c1.pl # 07.08.28 use strict; my(%t,@fld,$n); open(IN,"d01.txt") or die "Can't open the file d01.txt.\n"; while(<IN>){ @fld = split; $t{c1} = ''; $t{e1} = ''; if ( $fld[0] =~ /\d/ ) { $t{c1} = $fld[1]; for $n ( 2 .. $#fld ) { if ( $fld[$n] =~ /^\w/ ) { if ( $t{e1} ) { $t{e1} = $t{e1} . ' ' . lc($fld[$n]); } else { $t{e1} = lc($fld[$n]); } } else { $t{c1} = $t{c1} . ',' . $fld[$n]; } } $t{n1} = substr($t{e1},0,1); $t{n1} = uc($t{n1}); $t{eclist}{$t{e1}} = $t{c1}; $t{nlist}{$t{e1}} = $t{n1}; } } close(IN); for $n ( sort keys %{ $t{eclist} } ) { $t{c1} = $t{eclist}{$n}; $t{n1} = $t{nlist}{$n}; print "$t{n1}==>"; print "$n==>"; print "$t{c1}\n"; } ------------------------------------------------------------------------------------ # get1.pl use strict; my(%t,$n); open(IN,"dic01.txt") or die "Can't open the file dic01.txt.\n"; while(<IN>){ next if $. == 1; chomp; if ( !/^\s/ ) { push(@{ $t{clist} },$_); } else { next if length($_) == 1; s/^\s//; push(@{ $t{elist} },$_); } } close(IN); open(OUT,">dic02.txt"); for $n ( 0 .. $#{ $t{clist} } ) { $t{e1} = $t{elist}[$n]; $t{c1} = $t{clist}[$n]; $t{H1} = substr($t{e1},0,1); $t{H1} = uc($t{H1}); print OUT "$t{H1}==>$t{e1}==>$t{c1}\n"; } close(OUT); ------------------------------------------------------------------------------------ # combine.pl 07.12.02 use strict; my(%t,$n,$n1,@fld); # 辞書1のデータ open(FH,"je_org.txt") or die "Can't open the file je_org.txt\n"; while(<FH>){ chop; @fld = split(/==>/); next until $fld[1]; $t{jlist}{$fld[1]} = $fld[2]; $t{jA}{$fld[1]} = $fld[0]; } close(FH); # 辞書2のデータ open(FH,"d002org.txt") or die "Can't open the file d002org.txt\n"; while(<FH>){ chop; @fld = split(/==>/); next until $fld[1]; if ( $t{jlist}{$fld[1]} ) { $t{clist}{$fld[1]} = $fld[2] . ';' . $t{jlist}{$fld[1]}; $t{cA}{$fld[1]} = $fld[0]; delete $t{jlist}{$fld[1]}; } else { $t{clist}{$fld[1]} = $fld[2]; $t{cA}{$fld[1]} = $fld[0]; } } close(FH); @{ $t{jlist_keys} } = keys %{ $t{jlist} }; @{ $t{clist_keys} } = keys %{ $t{clist} }; @{ $t{jclist} } = (@{ $t{jlist_keys} },@{ $t{clist_keys} }); print "jlist_keys=$#{ $t{jlist_keys} },clist_keys=$#{ $t{clist_keys} }\n"; print "jclist=$#{ $t{jclist} }\n"; @{ $t{jclist2} } = sort { lc($a) cmp lc($b) } @{ $t{jclist} }; open(OUT,">tmpout.txt"); for $n ( 0 .. $#{ $t{jclist2} } ) { $t{jc1} = $t{jclist2}[$n]; if ( $t{jlist}{$t{jc1}} ) { print OUT "$t{jA}{$t{jc1}}==>$t{jc1}==>$t{jlist}{$t{jc1}}\n"; } elsif ( $t{clist}{$t{jc1}} ) { print OUT "$t{cA}{$t{jc1}}==>$t{jc1}==>$t{clist}{$t{jc1}}\n"; } else { print "NO,$t{jc1}\n"; print "ERROR!\n"; exit; } } close(OUT); print "The output file is tmpout.txt\n"; __END__; ------------------------------------------------------------------------------------ # make_htm.pl 07.12.02 # Output to a html file use strict; use HTML::Template; my(%t,$n,$n1,@fld,@name); # Read raw data $t{NO1}=0; open(FH,"ecj_org.txt") or die "Can't open the file ecj_org.txt\n"; while(<FH>){ chomp; @fld = split(/==>/); next until $fld[1]; $t{NO1}++; push(@{ $t{NO}{$fld[0]} }, $t{NO1}); push(@{ $t{E1}{$fld[0]} }, $fld[1]); push(@{ $t{C1}{$fld[0]} }, $fld[2]); } close(FH); close(OUT); @{ $t{list} } = ('A'..'Z','OTHERS'); for $n ( 0 .. $#{ $t{list} } ) { $t{name} = $t{list}[$n]; $t{htmfile} = lc($t{name}) . '.htm'; my $template = HTML::Template->new(filename => '../dic/index.html'); my @loop = (); $t{N1} = 0; for $n1 ( 0 .. $#{ $t{NO}{$t{name}} } ) { $t{N1}++; my %row = ( C1 => $t{E1}{$t{name}}[$n1], E1 => $t{C1}{$t{name}}[$n1] ); push(@loop, \%row); } # Output to a html file $template->param(amount => $t{NO1}); $template->param(name => $t{name}); $template->param(amount1 => $t{N1}); $template->param(dic_loop => \@loop); open(OUT,">../dic/$t{htmfile}"); print OUT $template->output; close(OUT); print "It was written to $t{htmfile}\n"; } exit;

戻る