Changeset 389de9a for app/src


Ignore:
Timestamp:
03/20/08 12:08:21 (16 years ago)
Author:
pawelk <pawelk@…>
Branches:
master, help
Children:
c8e8fa8
Parents:
20b4e44
git-author:
pawelk <pawelk@…> (03/20/08 12:08:21)
git-committer:
pawelk <pawelk@…> (03/20/08 12:08:21)
Message:

Program generujacy konfiguracje pyta sie o wybor slownika.
Dolozylem obsluge plikow tymczasowych w compiledict.
Zamienilem system na ` w perlu.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@14 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

Location:
app/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • app/src/compiledic/compiledic

    r20b4e44 r389de9a  
    1111use File::Basename; 
    1212use File::Temp; 
     13use File::Copy; 
    1314use Getopt::Long; 
    1415 
     
    5152`lexmakelab $symfilenoext`; 
    5253 
    53 # Analiza pliku s³ownika 
     54# Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane. 
     55$tmp_root = tempdir( CLEANUP => 1 ); 
    5456 
    55 print "preparing file..........................................."; 
    5657 
    57 `sed -r "s/([[:punct:]])/\[\\1\]/g" < $file > temp1`; 
     58# Analiza pliku slownika 
    5859 
    59 `cp temp1 temp2`; 
     60print "preparing file...........................................\n"; 
     61print "... sed section .....\n"; 
     62(undef, my $file_sed) = File::Temp::tempfile( DIR => $tmp_root, SUFFIX => ".sed" ); 
     63`sed -r "s/([[:punct:]])/\[\\1\]/g" < $file > $file_sed`; 
    6064 
    6165print "OK\n"; 
    6266 
    63 #dzielimy plik na wiele czê¶ci, uruchamiamy lexcomplex dla ka¿dej 
    64 #czê¶ci osobno, nastêpnie ³±czymy to za pomoc± programu fsmunion 
     67#dzielimy plik na wiele czesci, uruchamiamy lexcomplex dla kazdej 
     68#czesci osobno, nastepnie laczymy to za pomoca programu fsmunion 
    6569 
    66 #print "Dzielê s³ownik na mniejsze czê¶ci..."; 
     70#print "Dziele slownik na mniejsze czesci..."; 
    6771 
    68 open(IN, "./temp2"); 
     72open(IN, $file_sed); 
    6973 
    7074$lineCount = 0; 
    7175$fileCount = 0; 
    7276 
    73 `mkdir LemTEMP`; 
    74  
    75 open(FILE, ">LemTEMP/slo_0"); 
     77open(FILE, ">$tmp_root/slo_$fileCount"); 
    7678 
    7779while (<IN>) { 
     
    8284 
    8385        close(FILE); 
    84 #       print "Tworzê nowy plik tymczasowy: slo_".$fileCount."\n"; 
    85         open(FILE, ">LemTEMP/slo_".$fileCount); 
     86#       print "Tworze nowy plik tymczasowy: slo_".$fileCount."\n"; 
     87        open(FILE, ">$tmp_root/slo_".$fileCount); 
    8688    } 
    8789 
     
    107109    $files++; 
    108110 
    109     $command = "lexcomplex -l $labfile -S $sclfile < LemTEMP/slo_".$i." > LemTEMP/slownik_".$i.".fsm"; 
    110  
    111     `$command`; 
     111    `lexcomplex -l $labfile -S $sclfile < $tmp_root/slo_$i > $tmp_root/slownik_$i.fsm`; 
    112112 
    113113} 
     
    120120print "OK\n"; 
    121121 
    122 `rm LemTEMP/slo_*`; 
     122unlink <$tmp_root/slo_*>; 
    123123 
    124124print "building final automaton"; 
     
    130130$dots=0; 
    131131 
    132 `cp LemTEMP/slownik_0.fsm slownik1.fsm`; 
     132copy("$tmp_root/slownik_0.fsm", "$tmp_root/slownik1.fsm"); 
    133133 
    134134for ($i=1; $i<=$filecount; $i++) { 
     
    141141    $files++; 
    142142 
    143     $command = "fsmunion LemTEMP/slownik_".$i." slownik1.fsm > slownik2.fsm"; 
     143    `fsmunion $tmp_root/slownik_$i slownik1.fsm > $tmp_file/slownik2.fsm`; 
    144144 
    145     `$command`; 
    146  
    147     `mv slownik2.fsm slownik1.fsm`; 
     145    move("$tmp_root/slownik2.fsm", "$tmp_root/slownik1.fsm") || die "Unable to move $tmp_root/slownik2.fsm!\n"; 
    148146} 
    149147 
     
    154152} 
    155153 
    156 `fsmunion LemTEMP/* > slownik1.fsm`; 
     154`fsmunion $tmp_root/* > $tmp_root/slownik1.fsm`; 
    157155 
    158156print "OK\n"; 
     
    160158print "removing epsilon-transitions............................."; 
    161159 
    162 `fsmrmepsilon slownik1.fsm > slownik2.fsm`; 
     160`fsmrmepsilon $tmp_root/slownik1.fsm > $tmp_root/slownik2.fsm`; 
    163161 
    164 `rm slownik1.fsm`; 
     162unlink ("$tmp_root/slownik1.fsm"); 
    165163 
    166164print "OK\n"; 
     
    168166print "determinizing automaton.................................."; 
    169167 
    170 `fsmdeterminize slownik2.fsm > slownik1.fsm`; 
     168`fsmdeterminize $tmp_root/slownik2.fsm > $tmp_root/slownik1.fsm`; 
    171169 
    172 `rm slownik2.fsm`; 
     170unlink ("$tmp_root/slownik2.fsm"); 
    173171 
    174172print "OK\n"; 
     
    176174print "minimizing automaton....................................."; 
    177175 
    178 `fsmminimize slownik1.fsm > slownik.fsm`; 
     176`fsmminimize $tmp_root/slownik1.fsm > $tmp_root/slownik.fsm`; 
    179177 
    180178#`rm slownik1.fsm`; 
     
    184182print "converting fsm format to bin............................."; 
    185183 
    186 `fsmprint -i $labfile slownik.fsm > slownik.txt`; 
     184`fsmprint -i $labfile $tmp_root/slownik.fsm > $tmp_root/slownik.txt`; 
    187185 
    188 `fsm2aut slownik.txt > slownik.aut`; 
     186`fsm2aut $tmp_root/slownik.txt > $tmp_root/slownik.aut`; 
    189187 
    190 `aut2fsa < slownik.aut > $filenameprefix.bin`; 
     188`aut2fsa < $tmp_root/slownik.aut > $filenameprefix.bin`; 
    191189 
    192190print "OK\n"; 
     
    194192print "removing temporary files................................."; 
    195193 
    196 `rm LemTEMP/*`; 
    197 `rmdir LemTEMP`; 
    198 `rm temp2`; 
    199 `rm slownik.fsm`; 
    200 `rm slownik.txt`; 
    201 `rm slownik.aut`; 
    202 `rm labels.*`; 
     194unlink <$tmp_root/*>; 
     195unlink ($tmp_root); 
    203196 
    204197print "OK\n"; 
  • app/src/ser/ser

    r20b4e44 r389de9a  
    156156 
    157157 
    158 system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $tmpfile_l"; 
     158`m4 "--define=PATTERN=$flexpattern" "--define=DEFAULTACTION=$defaultaction" $flextemplate > $tmpfile_l`; 
    159159 
    160160if($flex) 
    161161{ 
    162         #system "cat $tmpfile_l"; 
    163162        if(open(FLEX, $tmpfile_l)) { 
    164163                while(<FLEX>) { 
     
    173172} 
    174173 
    175 system "flex -o$tmpfile_c $tmpfile_l"; 
    176 system "cc -O3 -o $tmpfile_x $tmpfile_c -lfl"; 
    177 system "$tmpfile_x"; 
     174`flex -o$tmpfile_c $tmpfile_l`; 
     175`cc -O3 -o $tmpfile_x $tmpfile_c -lfl`; 
     176`$tmpfile_x`; 
    178177 
    179 #system "rm -f $tmpfile_l $tmpfile_c $tmpfile_x"; 
    180178unlink $tmpfile_l; 
    181179unlink $tmpfile_c; 
    182180unlink $tmpfile_x; 
    183  
Note: See TracChangeset for help on using the changeset viewer.