- Timestamp:
- 04/24/08 12:36:13 (17 years ago)
- Branches:
- master, help
- Children:
- 12d8443
- Parents:
- a5fdde9
- git-author:
- pawelk <pawelk@…> (04/24/08 12:36:13)
- git-committer:
- pawelk <pawelk@…> (04/24/08 12:36:13)
- Location:
- app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
app/dist/common/utt_make_config.pl
ra5fdde9 r19dfa5c 14 14 conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 15 15 16 conf_cor(catfile($usr_home, 'cor.conf'), $sys_home); 17 conf_kor(catfile($usr_home, 'kor.conf'), $sys_home); 16 18 conf_compiledic(catfile($usr_home, 'compiledic.conf'), $sys_home); 17 conf_cor(catfile($usr_home, 'cor.conf'), $sys_home);18 conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home);19 19 conf_grp(catfile($usr_home, 'grp.conf'), $sys_home); 20 20 conf_gue(catfile($usr_home, 'gue.conf'), $sys_home); 21 conf_kor(catfile($usr_home, 'kor.conf'), $sys_home);22 21 conf_lem(catfile($usr_home, 'lem.conf'), $sys_home); 23 22 conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); 23 conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home); 24 24 25 25 print "UTT user configuration created in $usr_home\n"; … … 34 34 35 35 if(-d $dir) { 36 37 38 36 print "Old configuration detected. "; 37 my $cnt = unlink <$dir/*>; 38 print "($cnt files deleted)\n"; 39 39 } 40 40 else { 41 42 43 44 41 print "Creating directory $dir\n"; 42 if(1 != mkdir $dir) { 43 die "Unable to create UTT user configuration!\n"; 44 } 45 45 } 46 46 } … … 108 108 print FILE makeConfigHeader(); 109 109 print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; 110 print FILE "weights=", abs_path("$utthome/lib/utt/weights. kor"), "\n";110 print FILE "weights=", abs_path("$utthome/lib/utt/weights.cor"), "\n"; 111 111 print FILE "threshold=1.0\n"; 112 112 … … 222 222 223 223 print FILE makeConfigHeader(); 224 print FILE "cat egories=", abs_path("$utthome/lib/utt/cats.dgc"), "\n";225 print FILE "gram mar=", abs_path("$utthome/lib/utt/gram.dgc"), "\n";224 print FILE "catfile=", abs_path("$utthome/lib/utt/cats.dgc"), "\n"; 225 print FILE "gramfile=", abs_path("$utthome/lib/utt/gram.dgc"), "\n"; 226 226 227 227 close FILE; -
app/src/dgp/dgc
r0214596 r19dfa5c 6 6 #author: Tomasz Obrebski 7 7 8 # wymaga niejawnie programu canonize!!!! 8 9 #use lib "ENV{HOME}/.utt/lib/perl"; 9 #use strict; 10 11 use strict; 10 12 use Getopt::Long; 11 13 use Data::Dumper; 12 14 13 15 use attr; 14 #use File::HomeDir; 16 use File::HomeDir; 17 18 my $systemconfigfile='/usr/local/etc/utt/dgc.conf'; 19 my $userconfigfile=home()."/.utt/dgc.conf"; 20 21 Getopt::Long::Configure('no_ignore_case_always'); 15 22 16 23 my $help=0; … … 18 25 my $dicfile=0; 19 26 my $gramfile=0; 27 my $outputfile=0; 28 29 #read configuration files########################### 30 my $file; 31 foreach $file ($systemconfigfile, $userconfigfile){ 32 if(open(CONFIG, $file)){ 33 while (<CONFIG>) { 34 chomp; 35 s/#.*//; 36 s/^\s+//; 37 s/\s+$//; 38 next unless length; 39 my ($name, $value) = split(/\s*=\s*/, $_, 2); 40 if(($name eq "catfile")or($name eq "c")){ 41 $catfile=$value; 42 } 43 elsif(($name eq "dicfile")or($name eq "d")){ 44 $dicfile=$value; 45 } 46 elsif(($name eq "gramfile")or($name eq "g")){ 47 $gramfile=$value; 48 } 49 elsif(($name eq "outputfile")or($name eq "o")){ 50 $outputfile=$value; 51 } 52 elsif(($name eq "help")or($name eq "h")){ 53 $help=1; 54 } 55 56 } 57 close CONFIG; 58 } 59 } 60 ######################################################### 61 62 GetOptions("help|h" => \$help, 63 "catfile|c=s" => \$catfile, 64 "dicfile|d=s" => \$dicfile, 65 "gramfile|g=s" => \$gramfile, 66 "outputfile|o=s" => \$outputfile); 67 68 if($help) 69 { 70 print <<'END' 71 Usage: dgc [OPTIONS] 72 73 Options: 74 --catfile -c filename List of syntactic categories. 75 --dicfile -d filename Dictionary. 76 --gramfile -g filename List of grammar rules. 77 --outputfile -o filename Output filename. 78 --help -h Help. 79 END 80 ; 81 exit 0; 82 } 83 84 die("At least one of --cats and --dic must be given.\n") if !$catfile && !$dicfile; 20 85 21 86 my $ncat=0; … … 27 92 my $nlink=0; 28 93 29 GetOptions("help|h" => \$help,30 "catfile|c=s" => \$catfile,31 "dicfile|d=s" => \$dicfile,32 "gramfile|g=s" => \$gramfile);33 34 if($help)35 {36 print <<'END'37 Usage: dgpcompile [OPTIONS]38 39 Options:40 --cats -c filename List of syntactic categories.41 --dic -d filename Dictionary.42 --help -h Help.43 END44 ;45 exit 0;46 }47 48 die("At least one of --cats and --dic must be given.\n") if !$catfile && !$dicfile;49 50 94 my %cats; 51 95 my %roles; … … 53 97 my %gov; 54 98 99 if(!$outputfile) { 100 *OUTPUT = *STDOUT; 101 } 102 elsif($outputfile eq "-") { 103 *OUTPUT = *STDOUT; 104 } 105 else { 106 open(OUTPUT, ">$outputfile") or die("Can't open output file: $outputfile!"); 107 } 108 109 110 55 111 loadcats($catfile) if $catfile; 56 112 extractcats($dicfile) if $dicfile; 57 113 58 114 59 $cats_re = qr/(?:$attr::cat_re\s*(?:,\s*$attr::cat_re)*)/;115 my $cats_re = qr/(?:$attr::cat_re\s*(?:,\s*$attr::cat_re)*)/; 60 116 61 117 # class parse_class: 62 118 # /$attr::cat_re/g; 63 119 64 while(<>) 120 121 if(!$gramfile) { 122 *INPUT = *STDIN; 123 } 124 elsif($gramfile eq "-"){ 125 *INPUT = *STDIN; 126 } 127 else { 128 open(INPUT, $gramfile) or die("Unable to open: $gramfile!"); 129 } 130 131 while(<INPUT>) 65 132 { 66 133 if(/^\s*AGR\s+(\S+)\s+(\S+)\s*$/) … … 75 142 { 76 143 $roles{$_}=1; 77 print ;144 print OUTPUT; 78 145 } 79 146 elsif(/^\s*SGL\s+\S+\s*$/) 80 147 { 81 148 ++$nsgl; 82 print ;149 print OUTPUT; 83 150 } 84 151 elsif(/^\s*REQ\s+(\S+)\s+(\S+)\s*$/) 85 152 { 86 print "#$_";153 print OUTPUT "#$_"; 87 154 my $cat = attr::parse $1; 88 155 for my $atomcat (keys %cats) … … 90 157 if(attr::match @$cat, @{$cats{$atomcat}}) 91 158 { 92 print "REQ ".$atomcat." $2\n";159 print OUTPUT "REQ ".$atomcat." $2\n"; 93 160 ++$nreq; 94 161 } … … 98 165 { 99 166 ++$nleft; 100 print ;167 print OUTPUT; 101 168 } 102 169 elsif(/^\s*RIGHT\s+\S+\s*$/) 103 170 { 104 171 ++$nright; 105 print ;106 } 107 elsif( ($hs,$ds,$r) = /^\s*LINK\s+($cats_re)\s+($cats_re)\s+(\S+)\s*$/)108 { 109 print "#$_";110 for $h ($hs =~ /$attr::cat_re/g)111 { 112 for $d ($ds =~ /$attr::cat_re/g)172 print OUTPUT; 173 } 174 elsif(my ($hs,$ds,$r) = /^\s*LINK\s+($cats_re)\s+($cats_re)\s+(\S+)\s*$/) 175 { 176 print OUTPUT "#$_"; 177 for my $h ($hs =~ /$attr::cat_re/g) 178 { 179 for my $d ($ds =~ /$attr::cat_re/g) 113 180 { 114 181 addlinks($h,$d,$r); … … 119 186 else 120 187 { 121 print ;188 print OUTPUT; 122 189 } 123 190 } … … 126 193 sub addlinks 127 194 { 128 ($h,$d,$r) = @_;129 130 for my $a (@{$agr{$r}}) { print "#AGR $r $a\n"; }131 for my $c (@{$gov{$r}}) { print "#GOV $r ".attr::unparse(@$c)."\n"; }195 my ($h,$d,$r) = @_; 196 197 for my $a (@{$agr{$r}}) { print OUTPUT "#AGR $r $a\n"; } 198 for my $c (@{$gov{$r}}) { print OUTPUT "#GOV $r ".attr::unparse(@$c)."\n"; } 132 199 my $head = attr::parse $h; 133 200 my $dep = attr::parse $d; … … 152 219 } 153 220 154 print "LINK ";155 print $atomhead." ";156 print $atomdep." $r\n";221 print OUTPUT "LINK "; 222 print OUTPUT $atomhead." "; 223 print OUTPUT $atomdep." $r\n"; 157 224 ++$nlink; 158 225 … … 180 247 while(/,([^[:space:];]+)/g) 181 248 { 182 $cat=$1;249 my $cat=$1; 183 250 next if !$cat || exists $cats{$cat}; 184 251 $ncat++; 185 print "CAT $1\n";252 print OUTPUT "CAT $1\n"; 186 253 $cats{$cat}=attr::parse($cat); 187 254 } … … 199 266 tr/ \t\n//d; 200 267 next if !$_ || exists $cats{$_}; 201 print "CAT $_\n";268 print OUTPUT "CAT $_\n"; 202 269 ++$ncat; 203 270 $cats{$_}=attr::parse($_); … … 205 272 close CATFILE; 206 273 } 274 -
app/src/gph/gph
rcfed5c1 r19dfa5c 8 8 use strict; 9 9 use Getopt::Long; 10 use File::HomeDir; 10 11 11 my @process; 12 13 14 15 16 my $systemconfigfile='/usr/local/etc/utt/gph.conf'; 17 my $userconfigfile=home()."/.utt/gph.conf"; 18 19 Getopt::Long::Configure('no_ignore_case_always'); 20 12 21 my $help=0; 22 my $inputfile=0; 23 my $outputfile=0; 24 my @process=(); 13 25 my $reset; 14 my $interactive=1; 26 my $interactive=0; 27 28 #read configuration files########################### 29 my $file; 30 my @process_conf=(); 31 foreach $file ($systemconfigfile, $userconfigfile){ 32 if(open(CONFIG, $file)){ 33 while (<CONFIG>) { 34 chomp; 35 s/#.*//; 36 s/^\s+//; 37 s/\s+$//; 38 next unless length; 39 my ($name, $value) = split(/\s*=\s*/, $_, 2); 40 if(($name eq "inputfile")or($name eq "f")){ 41 $inputfile=$value; 42 } 43 elsif(($name eq "outputfile")or($name eq "o")){ 44 $outputfile=$value; 45 } 46 elsif(($name eq "process")or($name eq "p")){ 47 push @process_conf, $value; 48 } 49 elsif(($name eq "reset")or($name eq "r")){ 50 $reset=$value; 51 } 52 elsif(($name eq "interactive")or($name eq "i")){ 53 $interactive=1; 54 } 55 elsif(($name eq "help")or($name eq "h")){ 56 $help=1; 57 } 58 59 } 60 close CONFIG; 61 } 62 } 63 ######################################################### 64 65 15 66 16 67 GetOptions("process|p=s" => \@process, 68 "inputfile|f=s" => \$inputfile, 69 "outputfile|o=s" => \$outputfile, 17 70 "help|h" => \$help, 18 71 "reset|r=s" => \$reset, 19 72 "interactive|i" => \$interactive); 73 74 @process = @process_conf if @process<1; 20 75 21 76 if($help) … … 27 82 -p tag Process segments with this tag as nodes. 28 83 -r tag Start new graph at this tag. 29 -f filename Input file (NIE DZIALA).30 -o filename Output file (NIE DZIALA).31 -i Toggle interactive mode (default=o n).84 -f filename Input file. 85 -o filename Output file. 86 -i Toggle interactive mode (default=off). 32 87 END 33 88 ; … … 38 93 $|=1 if $interactive; 39 94 95 96 if(!$inputfile or $inputfile eq "-") { 97 *INPUT = *STDIN; 98 } 99 else { 100 open(INPUT, "$inputfile") or die("Can't open input file: $inputfile!"); 101 } 102 103 if(!$outputfile or $outputfile eq "-") { 104 *OUTPUT = *STDOUT; 105 } 106 else { 107 open(OUTPUT, "$outputfile") or die("Can't open output file: $outputfile!"); 108 } 109 40 110 my @prev; 41 42 111 my $n=0; 43 112 44 while(< >)113 while(<INPUT>) 45 114 { 46 115 chomp; … … 89 158 } 90 159 91 print $_.$gph."\n";160 print OUTPUT $_.$gph."\n"; 92 161 } 93 162
Note: See TracChangeset
for help on using the changeset viewer.