Wprowadzilem globalne pliki konfiguracyjne. Dokonalem drobnych poprawek w strukturze.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@32 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
pawelk 2008-04-23 14:48:12 +00:00
parent cfed5c1643
commit a5fdde9613
13 changed files with 369 additions and 268 deletions

13
app/conf/compiledic.conf Normal file
View File

@ -0,0 +1,13 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
symbols = /usr/local/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8859-2.sym

View File

@ -1,7 +1,14 @@
# Plik konfiguracyjny dla komponentu cor. # ************************************************************
# * This file was created automatically during installation. *
# kazda linia ma postac: # * If you don't need do not change it. *
# nazwa_parametru [=] wartosc # * *
# * UAM Text Tools *
# PRZYKLAD: analizuj tylko slowa # * Adam Mickiewicz University, Poland *
# p = W # * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
dictionary-home = /usr/local/share/utt
process = W

14
app/conf/dgc.conf Normal file
View File

@ -0,0 +1,14 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
categories = /usr/local/lib/utt/cats.dgc
grammar = /usr/local/lib/utt/gram.dgc

13
app/conf/grp.conf Normal file
View File

@ -0,0 +1,13 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
macros = /usr/local/lib/utt/terms.m4

View File

@ -1,8 +1,12 @@
# Plik konfiguracyjny dla komponentu gue. # ************************************************************
# * This file was created automatically during installation. *
# kazda linia ma postac: # * If you don't need do not change it. *
# nazwa_parametru [=] wartosc # * *
# * UAM Text Tools *
# PRZYKLAD: analizuj tylko slowa # * Adam Mickiewicz University, Poland *
# p = W # * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#

15
app/conf/kor.conf Normal file
View File

@ -0,0 +1,15 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
dictionary-home = /usr/local/share/utt
weights = /usr/local/lib/utt/weights.kor
threshold = 1.0

View File

@ -1,7 +1,14 @@
# Plik konfiguracyjny dla komponentu lem. # ************************************************************
# * This file was created automatically during installation. *
# kazda linia ma postac: # * If you don't need do not change it. *
# nazwa_parametru [=] wartosc # * *
# * UAM Text Tools *
# PRZYKLAD: analizuj tylko slowa # * Adam Mickiewicz University, Poland *
# p = W # * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
dictionary-home = /usr/local/share/utt
process = W

14
app/conf/ser.conf Normal file
View File

@ -0,0 +1,14 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
macros = /usr/local/lib/utt/terms.m4
flex-template = /usr/local/lib/utt/ser.l.template

14
app/conf/utt.conf Normal file
View File

@ -0,0 +1,14 @@
# ************************************************************
# * This file was created automatically during installation. *
# * If you don't need do not change it. *
# * *
# * UAM Text Tools *
# * Adam Mickiewicz University, Poland *
# * http://utt.amu.edu.pl *
# ************************************************************
#
# All lines must looks like:
# parameter_name [=] value
#
# user locale (dictionary)
language = pl_PL.ISO-8859-2

View File

@ -1,236 +1,236 @@
#!/usr/bin/perl #!/usr/bin/perl
#c:\usr\perl\bin\perl.exe #c:\usr\perl\bin\perl.exe
use Cwd 'abs_path'; use Cwd 'abs_path';
use File::Basename; use File::Basename;
use File::HomeDir; use File::HomeDir;
use File::Spec::Functions; use File::Spec::Functions;
use POSIX; use POSIX;
my $sys_home = catdir(dirname(abs_path($0)), ".."); my $sys_home = catdir(dirname(abs_path($0)), "..");
my $usr_home = catdir(home(), '.utt'); my $usr_home = catdir(home(), '.utt');
prepareUttUsrHome($usr_home); prepareUttUsrHome($usr_home);
conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); conf_utt(catfile($usr_home, 'utt.conf'), $sys_home);
conf_cor(catfile($usr_home, 'cor.conf'), $sys_home); conf_compiledic(catfile($usr_home, 'compiledic.conf'), $sys_home);
conf_kor(catfile($usr_home, 'kor.conf'), $sys_home); conf_cor(catfile($usr_home, 'cor.conf'), $sys_home);
conf_compiledic(catfile($usr_home, 'compiledic.conf'), $sys_home); conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home);
conf_grp(catfile($usr_home, 'grp.conf'), $sys_home); conf_grp(catfile($usr_home, 'grp.conf'), $sys_home);
conf_gue(catfile($usr_home, 'gue.conf'), $sys_home); conf_gue(catfile($usr_home, 'gue.conf'), $sys_home);
conf_lem(catfile($usr_home, 'lem.conf'), $sys_home); conf_kor(catfile($usr_home, 'kor.conf'), $sys_home);
conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); conf_lem(catfile($usr_home, 'lem.conf'), $sys_home);
conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home); conf_ser(catfile($usr_home, 'ser.conf'), $sys_home);
print "UTT user configuration created in $usr_home\n"; print "UTT user configuration created in $usr_home\n";
#Kasuje stare configi i tworzy katalog .utt #Kasuje stare configi i tworzy katalog .utt
sub prepareUttUsrHome() { sub prepareUttUsrHome() {
my $dir = shift; my $dir = shift;
print "Preparing user configuration.\n"; print "Preparing user configuration.\n";
if(-d $dir) { if(-d $dir) {
print "Old configuration detected. "; print "Old configuration detected. ";
my $cnt = unlink <$dir/*>; my $cnt = unlink <$dir/*>;
print "($cnt files deleted)\n"; print "($cnt files deleted)\n";
} }
else { else {
print "Creating directory $dir\n"; print "Creating directory $dir\n";
if(1 != mkdir $dir) { if(1 != mkdir $dir) {
die "Unable to create UTT user configuration!\n"; die "Unable to create UTT user configuration!\n";
} }
} }
} }
# Tworzy naglowek dla wszystkich plikow konfiguracyjnych # Tworzy naglowek dla wszystkich plikow konfiguracyjnych
sub makeConfigHeader() { sub makeConfigHeader() {
return "# ************************************************************\n". return "# ************************************************************\n".
"# * This file was created automatically during installation. *\n". "# * This file was created automatically during installation. *\n".
"# * If you don't need do not change it. *\n". "# * If you don't need do not change it. *\n".
"# * *\n". "# * *\n".
"# * UAM Text Tools *\n". "# * UAM Text Tools *\n".
"# * Adam Mickiewicz University, Poland *\n". "# * Adam Mickiewicz University, Poland *\n".
"# * http://utt.amu.edu.pl *\n". "# * http://utt.amu.edu.pl *\n".
"# ************************************************************\n". "# ************************************************************\n".
"#\n". "#\n".
"# All lines must looks like:\n". "# All lines must looks like:\n".
"# parameter_name [=] value\n". "# parameter_name [=] value\n".
"#\n\n"; "#\n\n";
} }
sub conf_compiledic() { sub conf_compiledic() {
my $compiledic_file = shift; my $compiledic_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$compiledic_file"); open(FILE, ">$compiledic_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
my $hm = home(); my $hm = home();
my $lang=`grep language $hm/.utt/utt.conf | cut -d= -f 2`; my $lang=`grep language $hm/.utt/utt.conf | cut -d= -f 2`;
chomp $lang; chomp $lang;
# powinno byc $utthome/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8892-2.sym # powinno byc $utthome/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8892-2.sym
# ale to bez sensu # ale to bez sensu
print FILE "symbols=", abs_path("$utthome/share/utt"); print FILE "symbols=", abs_path("$utthome/share/utt");
print FILE "/$lang/$lang.sym\n"; print FILE "/$lang/$lang.sym\n";
close FILE; close FILE;
} }
sub conf_grp() { sub conf_grp() {
my $grp_file = shift; my $grp_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$grp_file"); open(FILE, ">$grp_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n"; print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n";
close FILE; close FILE;
} }
sub conf_cor() { sub conf_cor() {
my $cor_file = shift; my $cor_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$cor_file"); open(FILE, ">$cor_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n";
close FILE; close FILE;
} }
sub conf_kor() { sub conf_kor() {
my $kor_file = shift; my $kor_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$kor_file"); open(FILE, ">$kor_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n";
print FILE "weights=", abs_path("$utthome/lib/utt/weights.cor"), "\n"; print FILE "weights=", abs_path("$utthome/lib/utt/weights.kor"), "\n";
print FILE "threshold=1.0\n"; print FILE "threshold=1.0\n";
close FILE; close FILE;
} }
sub conf_grp() { sub conf_grp() {
my $grp_file = shift; my $grp_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$grp_file"); open(FILE, ">$grp_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n"; print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n";
close FILE; close FILE;
} }
sub conf_gue() { sub conf_gue() {
my $gue_file = shift; my $gue_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$gue_file"); open(FILE, ">$gue_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
close FILE; close FILE;
} }
sub conf_lem() { sub conf_lem() {
my $lem_file = shift; my $lem_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$lem_file"); open(FILE, ">$lem_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n";
close FILE; close FILE;
} }
sub conf_ser() { sub conf_ser() {
my $ser_file = shift; my $ser_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$ser_file"); open(FILE, ">$ser_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n"; print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n";
print FILE "flex-template=", abs_path("$utthome/lib/utt/ser.l.template"), "\n"; print FILE "flex-template=", abs_path("$utthome/lib/utt/ser.l.template"), "\n";
close FILE; close FILE;
} }
sub conf_utt() { sub conf_utt() {
my $utt_file = shift; my $utt_file = shift;
my $utthome = shift; my $utthome = shift;
my $lang = getUserLanguage(abs_path(catdir($utthome, "share/utt"))); my $lang = getUserLanguage(abs_path(catdir($utthome, "share/utt")));
open(FILE, ">$utt_file"); open(FILE, ">$utt_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "# user locale (dictionary)\n"; print FILE "# user locale (dictionary)\n";
print FILE "language=", $lang, "\n"; print FILE "language=", $lang, "\n";
close FILE; close FILE;
} }
sub getUserLanguage() { sub getUserLanguage() {
my $dict_dir = shift; my $dict_dir = shift;
print "Setup dictionaries.\n"; print "Setup dictionaries.\n";
opendir(DIR, $dict_dir) || die "Install dictionary first!\n"; opendir(DIR, $dict_dir) || die "Install dictionary first!\n";
@files = grep(/[^\.{1,2}]/ && -d "$dict_dir/$_", readdir(DIR)); @files = grep(/[^\.{1,2}]/ && -d "$dict_dir/$_", readdir(DIR));
closedir DIR; closedir DIR;
my $cnt = scalar @files; my $cnt = scalar @files;
print "$cnt dictionary(ies) found.\n"; print "$cnt dictionary(ies) found.\n";
if(0 == $cnt) { if(0 == $cnt) {
die("Install dictionary first!\n"); die("Install dictionary first!\n");
} }
foreach my $file (@files) { foreach my $file (@files) {
print "Do you select dictionary $file [yes/no]? "; print "Do you select dictionary $file [yes/no]? ";
my $ans = <STDIN>; my $ans = <STDIN>;
if($ans =~ /y(es)?/i) { if($ans =~ /y(es)?/i) {
return $file; return $file;
} }
} }
die "No dictionary selected - setup failed!\n"; die "No dictionary selected - setup failed!\n";
} }
# Szuka locali u uzytkownika # Szuka locali u uzytkownika
sub findLocale() { sub findLocale() {
$cur_locale = setlocale(LC_CTYPE); $cur_locale = setlocale(LC_CTYPE);
# we replace Latinx to ISO-8859-x # we replace Latinx to ISO-8859-x
$cur_locale =~ s/(.+?)Latin(.+?)/$1ISO\-8859\-$2/g; $cur_locale =~ s/(.+?)Latin(.+?)/$1ISO\-8859\-$2/g;
if($cur_locale =~ /\w+_\w+\.\S+/) { if($cur_locale =~ /\w+_\w+\.\S+/) {
$best_locale = $cur_locale; $best_locale = $cur_locale;
} }
elsif($cur_locale =~ /\w+_\w+/) { elsif($cur_locale =~ /\w+_\w+/) {
$best_locale = $cur_locale.".UTF-8"; $best_locale = $cur_locale.".UTF-8";
} }
else { else {
$best_locale = toupper($cur_locale).'_'.tolower($cur_locale).'.UTF-8'; $best_locale = toupper($cur_locale).'_'.tolower($cur_locale).'.UTF-8';
} }
return $best_locale; return $best_locale;
} }
sub conf_dgc() { sub conf_dgc() {
my $dgc_file = shift; my $dgc_file = shift;
my $utthome = shift; my $utthome = shift;
open(FILE, ">$dgc_file"); open(FILE, ">$dgc_file");
print FILE makeConfigHeader(); print FILE makeConfigHeader();
print FILE "categories=", abs_path("$utthome/lib/utt/cats.dgc"), "\n"; print FILE "categories=", abs_path("$utthome/lib/utt/cats.dgc"), "\n";
print FILE "grammar=", abs_path("$utthome/lib/utt/gram.dgc"), "\n"; print FILE "grammar=", abs_path("$utthome/lib/utt/gram.dgc"), "\n";
close FILE; close FILE;
open(FILE, ">$utthome/bin/Makefile.go"); open(FILE, ">$utthome/bin/Makefile.go");
print FILE "\ngram.dgp: ", abs_path("$utthome/lib/utt/gram.dgc"), "\n"; print FILE "\ngram.dgp: ", abs_path("$utthome/lib/utt/gram.dgc"), "\n";
print FILE "\tdgc -c ", abs_path("$utthome/lib/utt/cats.dgc"), " < ", abs_path("$utthome/lib/utt/gram.dgc"), " > gram.dgp\n"; print FILE "\tdgc -c ", abs_path("$utthome/lib/utt/cats.dgc"), " < ", abs_path("$utthome/lib/utt/gram.dgc"), " > gram.dgp\n";
close FILE; close FILE;
} }

View File

@ -3,14 +3,14 @@
/usr/local/bin/compiledic /usr/local/bin/compiledic
/usr/local/bin/con /usr/local/bin/con
/usr/local/bin/cor /usr/local/bin/cor
/usr/local/bin/dgc /usr/local/bin/dgc
/usr/local/bin/dgp /usr/local/bin/dgp
/usr/local/bin/fla /usr/local/bin/fla
/usr/local/bin/fsm2aut /usr/local/bin/fsm2aut
/usr/local/bin/go ? /usr/local/bin/go ?
/usr/local/bin/Makefile.go ? /usr/local/bin/Makefile.go ?
/usr/local/bin/attr.pm /usr/local/bin/attr.pm
/usr/local/bin/gph /usr/local/bin/gph
/usr/local/bin/grp /usr/local/bin/grp
/usr/local/bin/gue /usr/local/bin/gue
/usr/local/bin/kot /usr/local/bin/kot
@ -32,6 +32,7 @@
/usr/local/etc/utt/fla.conf /usr/local/etc/utt/fla.conf
/usr/local/etc/utt/grp.conf /usr/local/etc/utt/grp.conf
/usr/local/etc/utt/gue.conf /usr/local/etc/utt/gue.conf
/usr/local/etc/utt/kor.conf
/usr/local/etc/utt/kot.conf /usr/local/etc/utt/kot.conf
/usr/local/etc/utt/lem.conf /usr/local/etc/utt/lem.conf
/usr/local/etc/utt/mar.conf /usr/local/etc/utt/mar.conf
@ -52,10 +53,10 @@
/usr/local/lib/utt/ser.l.template /usr/local/lib/utt/ser.l.template
/usr/local/lib/utt/terms.m4 /usr/local/lib/utt/terms.m4
/usr/local/lib/utt/weights.cor /usr/local/lib/utt/weights.kor
/usr/local/lib/utt/seg.rb /usr/local/lib/utt/seg.rb
/usr/local/lib/utt/cats.dgc /usr/local/lib/utt/cats.dgc
/usr/local/lib/utt/gram.dgc /usr/local/lib/utt/gram.dgc
/usr/local/share/doc/utt/FAQ /usr/local/share/doc/utt/FAQ
/usr/local/share/doc/utt/COPYRIGHT /usr/local/share/doc/utt/COPYRIGHT

View File

@ -43,5 +43,4 @@ ifdef UTT_BIN_DIR
cp dgp dgc canonize tre.rb $(UTT_BIN_DIR)/ cp dgp dgc canonize tre.rb $(UTT_BIN_DIR)/
# ponizsza linijka jest do usuniecia # ponizsza linijka jest do usuniecia
cp go attr.pm seg.rb $(UTT_BIN_DIR)/ cp go attr.pm seg.rb $(UTT_BIN_DIR)/
cp $(LIB_PATH)/*.dgc $(UTT_BIN_DIR)/../lib/utt/
endif endif