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:
parent
389de9abcb
commit
c8e8fa8b58
@ -13,47 +13,98 @@ use File::Temp;
|
||||
use File::Copy;
|
||||
use Getopt::Long;
|
||||
|
||||
my $systemconfigfile='';
|
||||
|
||||
my $linesPerFile = 20000;
|
||||
|
||||
|
||||
my $systemconfigfile='/usr/local/etc/utt/compiledic.conf';
|
||||
my $userconfigfile=home()."/.utt/compiledic.conf";
|
||||
|
||||
Getopt::Long::Configure('no_ignore_case_always');
|
||||
|
||||
$symfile='~/.utt/pl/pl_PL.iso-8859-2.sym';
|
||||
$symfilenoext = $symfile;
|
||||
$symfilenoext =~ s/\.sym$//;
|
||||
$labfile = $symfilenoext . '.lab';
|
||||
$sclfile = $symfilenoext . '.scl';
|
||||
#my $symfile='~/.utt/pl/pl_PL.iso-8859-2.sym';
|
||||
my $symbols=0;
|
||||
my $help=0;
|
||||
|
||||
|
||||
|
||||
#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) {
|
||||
print "usage: ", basename($0), " dictionary_file\n";
|
||||
exit;
|
||||
}
|
||||
-f $symbols or die("Symbol file not found.");
|
||||
|
||||
my $file = shift; # @ARGV;
|
||||
my $filenameprefix;
|
||||
@ARGV < 1 or die("Source dictionary not given.");
|
||||
|
||||
if ($file =~ /(.*)\.dic/)
|
||||
{
|
||||
$filenameprefix = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "The input file must have .dic extension.";
|
||||
exit(1);
|
||||
}
|
||||
my $file = shift;
|
||||
|
||||
# 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.
|
||||
$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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user