Changeset 389de9a for app


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
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • app/TODO

    r20b4e44 r389de9a  
    88* mar nie obsluguje plikow konfiguracyjnych [JW] 
    99 
    10 * compiledic - plik tymczasowe [PK] 
     10* DONE compiledic - plik tymczasowe [PK] 
    1111 
    1212* ser i grp - parametr tags (zeby bral wskazany program tag2re) [TO] 
    1313 
    14 * lista zaleznosci dla komend system w perlu [PK] 
     14* DONE lista zaleznosci dla komend system w perlu [PK] 
    1515 
    1616* polaczyc sen'y [TO] 
    1717 
    18 * poprawic utt_make_conf (wykrywanie slownikow) [PK] 
     18* DONE poprawic utt_make_conf (wykrywanie slownikow) [PK] 
    1919 
    2020* generowanie i sprawdzanie zaleznosci dla tarballa [PK] 
  • app/dist/common/utt_make_config.pl

    rd593c5e r389de9a  
    1212 
    1313prepareUttUsrHome($usr_home); 
     14conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 
     15 
    1416conf_cor(catfile($usr_home, 'cor.conf'), $sys_home); 
    1517conf_grp(catfile($usr_home, 'grp.conf'), $sys_home); 
     
    1719conf_lem(catfile($usr_home, 'lem.conf'), $sys_home); 
    1820conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); 
    19 conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 
    2021 
    2122print "UTT user configuration created in $usr_home\n"; 
     
    2728    my $dir = shift; 
    2829 
    29         if(-d $dir) { 
    30                 print "Old configuration will be deleted!\n"; 
    31                 my $cnt = unlink <$dir/*>; 
    32                 print "$cnt files deleted.\n"; 
     30    print "Preparing user configuration.\n"; 
     31 
     32    if(-d $dir) { 
     33        print "Old configuration detected. "; 
     34        my $cnt = unlink <$dir/*>; 
     35        print "($cnt files deleted)\n"; 
     36    } 
     37    else { 
     38        print "Creating directory $dir\n"; 
     39        if(1 != mkdir $dir) { 
     40            die "Unable to create UTT user configuration!\n"; 
    3341        } 
    34         else { 
    35                 print "Creating directory $dir\n"; 
    36                 if(1 != mkdir $dir) { 
    37                   die "Unable to create UTT user configuration!\n"; 
    38                 } 
    39         } 
     42    } 
    4043} 
    4144 
     
    114117        my $utt_file = shift; 
    115118        my $utthome = shift; 
     119 
     120        my $lang = getUserLanguage(abs_path(catdir($utthome, "share/utt"))); 
     121 
    116122  open(FILE, ">$utt_file"); 
    117123 
    118124  print FILE makeConfigHeader(); 
    119   print FILE "# user locale\n"; 
    120   print FILE "language=", findLocale(), "\n"; 
     125  print FILE "# user locale (dictionary)\n"; 
     126  print FILE "language=", $lang, "\n"; 
    121127 
    122128  close FILE; 
     129} 
     130 
     131sub getUserLanguage() { 
     132    my $dict_dir = shift; 
     133 
     134    print "Setup dictionaries.\n"; 
     135     
     136    opendir(DIR, $dict_dir) || die "Install dictionary first!\n"; 
     137    @files = grep(/[^\.{1,2}]/ && -d "$dict_dir/$_", readdir(DIR)); 
     138    closedir DIR; 
     139    my $cnt = scalar @files; 
     140    print "$cnt dictionary(ies) found.\n"; 
     141    if(0 == $cnt) { 
     142        die("Install dictionary first!\n"); 
     143    } 
     144 
     145    foreach my $file (@files) { 
     146        print "Do you select dictionary $file [yes/no]? "; 
     147        my $ans = <STDIN>; 
     148        if($ans =~ /y(es)?/i) { 
     149            return $file; 
     150        } 
     151    } 
     152    die "No dictionary selected - setup failed!\n"; 
    123153} 
    124154 
  • 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.