Changeset c8e8fa8 for app/src


Ignore:
Timestamp:
03/26/08 14:16:40 (16 years ago)
Author:
obrebski <obrebski@…>
Branches:
master, help
Children:
e1942be
Parents:
389de9a
git-author:
obrebski <obrebski@…> (03/26/08 14:16:40)
git-committer:
obrebski <obrebski@…> (03/26/08 14:16:40)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/src/compiledic/compiledic

    r389de9a rc8e8fa8  
    1414use Getopt::Long; 
    1515 
    16 my $systemconfigfile=''; 
     16 
     17my $linesPerFile = 20000; 
     18 
     19 
     20my $systemconfigfile='/usr/local/etc/utt/compiledic.conf'; 
    1721my $userconfigfile=home()."/.utt/compiledic.conf"; 
    1822 
    1923Getopt::Long::Configure('no_ignore_case_always'); 
    2024 
    21 $symfile='~/.utt/pl/pl_PL.iso-8859-2.sym'; 
    22 $symfilenoext = $symfile; 
    23 $symfilenoext =~ s/\.sym$//; 
    24 $labfile = $symfilenoext . '.lab'; 
    25 $sclfile = $symfilenoext . '.scl'; 
     25#my $symfile='~/.utt/pl/pl_PL.iso-8859-2.sym'; 
     26my $symbols=0; 
     27my $help=0; 
     28 
     29 
     30 
     31#read configuration files########################### 
     32my $file; 
     33foreach $file ($systemconfigfile, $userconfigfile){ 
     34  if(open(CONFIG, $file)){ 
     35        while (<CONFIG>) { 
     36                chomp;                   
     37                s/#.*//;                 
     38                s/^\s+//;                
     39                s/\s+$//;                
     40                next unless length;      
     41                my ($name, $value) = split(/\s*=\s*/, $_, 2); 
     42                if($name eq "symbols"){ 
     43                        $symbols=$value; 
     44                } 
     45                elsif(($name eq "help")or($name eq "h")){ 
     46                        $help=1; 
     47                } 
     48         
     49        }  
     50        close CONFIG; 
     51  } 
     52} 
     53######################################################### 
     54 
     55 
     56GetOptions("symbols=s" => \$symbols, 
     57           "help|h" => \$help); 
     58 
     59if($help) 
     60{ 
     61    print <<'END' 
     62Usage: compiledic [OPTIONS] dictionaryfile 
     63 
     64Options: 
     65   --help -h                      Help. 
     66   --symbols=FILE                 Symbol file. 
     67END 
     68; 
     69    exit 0; 
     70} 
     71 
     72 
    2673 
    2774################################################## 
    28 $linesPerFile = 20000; 
    29  
    30 if (@ARGV < 1) { 
    31     print "usage: ", basename($0), " dictionary_file\n"; 
    32     exit; 
    33 } 
    34  
    35 my $file = shift; # @ARGV; 
    36 my $filenameprefix; 
    37  
    38 if ($file =~ /(.*)\.dic/) 
    39 { 
    40     $filenameprefix = $1; 
    41 } 
    42 else 
    43 { 
    44     print "The input file must have .dic extension."; 
    45     exit(1); 
    46 } 
    47  
    48 # Przygotowanie etykiet 
    49  
    50 #`makeLabels.pl > labels.sym`; 
    51  
    52 `lexmakelab $symfilenoext`; 
     75 
     76-f $symbols or die("Symbol file not found."); 
     77 
     78@ARGV < 1   or die("Source dictionary not given."); 
     79 
     80my $file = shift; 
     81 
     82-f $file or die("Source dictionary not found."); 
     83 
     84$file =~ /(.*)\.dic/ or die("The input file must have .dic extension."); 
     85 
     86my $filenameprefix = $1; 
     87 
     88################################################## 
    5389 
    5490# Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane. 
    5591$tmp_root = tempdir( CLEANUP => 1 ); 
     92 
     93print "TMPROOT: $tmp_root\n"; 
     94 
     95 
     96(undef, my $symfile) = File::Temp::tempfile( DIR => $tmp_root, SUFFIX => ".sym" ); 
     97my $symfilenoext=$symfile; 
     98$symfilenoext =~ s/\.sym$//; 
     99my $labfile = $symfilenoext . '.lab'; 
     100my $sclfile = $symfilenoext . '.scl'; 
     101 
     102copy($symbols, $symfile); 
     103 
     104# Przygotowanie etykiet 
     105 
     106`lexmakelab $symfilenoext`; 
    56107 
    57108 
Note: See TracChangeset for help on using the changeset viewer.