compiledic - obsluga plikow konfiguracyjnych, nieprzetestowane

M    app/src/compiledic/compiledic


git-svn-id: svn://atos.wmid.amu.edu.pl/utt@15 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
obrebski 2008-03-26 13:16:40 +00:00
parent 389de9abcb
commit c8e8fa8b58

View File

@ -13,47 +13,98 @@ use File::Temp;
use File::Copy; use File::Copy;
use Getopt::Long; use Getopt::Long;
my $systemconfigfile='';
my $linesPerFile = 20000;
my $systemconfigfile='/usr/local/etc/utt/compiledic.conf';
my $userconfigfile=home()."/.utt/compiledic.conf"; my $userconfigfile=home()."/.utt/compiledic.conf";
Getopt::Long::Configure('no_ignore_case_always'); Getopt::Long::Configure('no_ignore_case_always');
$symfile='~/.utt/pl/pl_PL.iso-8859-2.sym'; #my $symfile='~/.utt/pl/pl_PL.iso-8859-2.sym';
$symfilenoext = $symfile; my $symbols=0;
$symfilenoext =~ s/\.sym$//; my $help=0;
$labfile = $symfilenoext . '.lab';
$sclfile = $symfilenoext . '.scl';
#read configuration files###########################
my $file;
foreach $file ($systemconfigfile, $userconfigfile){
if(open(CONFIG, $file)){
while (<CONFIG>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
next unless length;
my ($name, $value) = split(/\s*=\s*/, $_, 2);
if($name eq "symbols"){
$symbols=$value;
}
elsif(($name eq "help")or($name eq "h")){
$help=1;
}
}
close CONFIG;
}
}
#########################################################
GetOptions("symbols=s" => \$symbols,
"help|h" => \$help);
if($help)
{
print <<'END'
Usage: compiledic [OPTIONS] dictionaryfile
Options:
--help -h Help.
--symbols=FILE Symbol file.
END
;
exit 0;
}
################################################## ##################################################
$linesPerFile = 20000;
if (@ARGV < 1) { -f $symbols or die("Symbol file not found.");
print "usage: ", basename($0), " dictionary_file\n";
exit;
}
my $file = shift; # @ARGV; @ARGV < 1 or die("Source dictionary not given.");
my $filenameprefix;
if ($file =~ /(.*)\.dic/) my $file = shift;
{
$filenameprefix = $1;
}
else
{
print "The input file must have .dic extension.";
exit(1);
}
# Przygotowanie etykiet -f $file or die("Source dictionary not found.");
#`makeLabels.pl > labels.sym`; $file =~ /(.*)\.dic/ or die("The input file must have .dic extension.");
`lexmakelab $symfilenoext`; my $filenameprefix = $1;
##################################################
# Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane. # Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane.
$tmp_root = tempdir( CLEANUP => 1 ); $tmp_root = tempdir( CLEANUP => 1 );
print "TMPROOT: $tmp_root\n";
(undef, my $symfile) = File::Temp::tempfile( DIR => $tmp_root, SUFFIX => ".sym" );
my $symfilenoext=$symfile;
$symfilenoext =~ s/\.sym$//;
my $labfile = $symfilenoext . '.lab';
my $sclfile = $symfilenoext . '.scl';
copy($symbols, $symfile);
# Przygotowanie etykiet
`lexmakelab $symfilenoext`;
# Analiza pliku slownika # Analiza pliku slownika