Changeset 389de9a for app/src/compiledic
- Timestamp:
- 03/20/08 12:08:21 (17 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/src/compiledic/compiledic
r20b4e44 r389de9a 11 11 use File::Basename; 12 12 use File::Temp; 13 use File::Copy; 13 14 use Getopt::Long; 14 15 … … 51 52 `lexmakelab $symfilenoext`; 52 53 53 # Analiza pliku s³ownika 54 # Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane. 55 $tmp_root = tempdir( CLEANUP => 1 ); 54 56 55 print "preparing file...........................................";56 57 57 `sed -r "s/([[:punct:]])/\[\\1\]/g" < $file > temp1`; 58 # Analiza pliku slownika 58 59 59 `cp temp1 temp2`; 60 print "preparing file...........................................\n"; 61 print "... 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`; 60 64 61 65 print "OK\n"; 62 66 63 #dzielimy plik na wiele cz ê¶ci, uruchamiamy lexcomplex dla ka¿dej64 #cz ê¶ci osobno, nastêpnie ³±czymy to za pomoc±programu fsmunion67 #dzielimy plik na wiele czesci, uruchamiamy lexcomplex dla kazdej 68 #czesci osobno, nastepnie laczymy to za pomoca programu fsmunion 65 69 66 #print "Dziel ê s³ownik na mniejsze czê¶ci...";70 #print "Dziele slownik na mniejsze czesci..."; 67 71 68 open(IN, "./temp2");72 open(IN, $file_sed); 69 73 70 74 $lineCount = 0; 71 75 $fileCount = 0; 72 76 73 `mkdir LemTEMP`; 74 75 open(FILE, ">LemTEMP/slo_0"); 77 open(FILE, ">$tmp_root/slo_$fileCount"); 76 78 77 79 while (<IN>) { … … 82 84 83 85 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); 86 88 } 87 89 … … 107 109 $files++; 108 110 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`; 112 112 113 113 } … … 120 120 print "OK\n"; 121 121 122 `rm LemTEMP/slo_*`;122 unlink <$tmp_root/slo_*>; 123 123 124 124 print "building final automaton"; … … 130 130 $dots=0; 131 131 132 `cp LemTEMP/slownik_0.fsm slownik1.fsm`;132 copy("$tmp_root/slownik_0.fsm", "$tmp_root/slownik1.fsm"); 133 133 134 134 for ($i=1; $i<=$filecount; $i++) { … … 141 141 $files++; 142 142 143 $command = "fsmunion LemTEMP/slownik_".$i." slownik1.fsm > slownik2.fsm";143 `fsmunion $tmp_root/slownik_$i slownik1.fsm > $tmp_file/slownik2.fsm`; 144 144 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"; 148 146 } 149 147 … … 154 152 } 155 153 156 `fsmunion LemTEMP/* >slownik1.fsm`;154 `fsmunion $tmp_root/* > $tmp_root/slownik1.fsm`; 157 155 158 156 print "OK\n"; … … 160 158 print "removing epsilon-transitions............................."; 161 159 162 `fsmrmepsilon slownik1.fsm >slownik2.fsm`;160 `fsmrmepsilon $tmp_root/slownik1.fsm > $tmp_root/slownik2.fsm`; 163 161 164 `rm slownik1.fsm`;162 unlink ("$tmp_root/slownik1.fsm"); 165 163 166 164 print "OK\n"; … … 168 166 print "determinizing automaton.................................."; 169 167 170 `fsmdeterminize slownik2.fsm >slownik1.fsm`;168 `fsmdeterminize $tmp_root/slownik2.fsm > $tmp_root/slownik1.fsm`; 171 169 172 `rm slownik2.fsm`;170 unlink ("$tmp_root/slownik2.fsm"); 173 171 174 172 print "OK\n"; … … 176 174 print "minimizing automaton....................................."; 177 175 178 `fsmminimize slownik1.fsm >slownik.fsm`;176 `fsmminimize $tmp_root/slownik1.fsm > $tmp_root/slownik.fsm`; 179 177 180 178 #`rm slownik1.fsm`; … … 184 182 print "converting fsm format to bin............................."; 185 183 186 `fsmprint -i $labfile slownik.fsm >slownik.txt`;184 `fsmprint -i $labfile $tmp_root/slownik.fsm > $tmp_root/slownik.txt`; 187 185 188 `fsm2aut slownik.txt >slownik.aut`;186 `fsm2aut $tmp_root/slownik.txt > $tmp_root/slownik.aut`; 189 187 190 `aut2fsa < slownik.aut > $filenameprefix.bin`;188 `aut2fsa < $tmp_root/slownik.aut > $filenameprefix.bin`; 191 189 192 190 print "OK\n"; … … 194 192 print "removing temporary files................................."; 195 193 196 `rm LemTEMP/*`; 197 `rmdir LemTEMP`; 198 `rm temp2`; 199 `rm slownik.fsm`; 200 `rm slownik.txt`; 201 `rm slownik.aut`; 202 `rm labels.*`; 194 unlink <$tmp_root/*>; 195 unlink ($tmp_root); 203 196 204 197 print "OK\n";
Note: See TracChangeset
for help on using the changeset viewer.