Pierwsza przymiarka do umieszczenia plikow w ~/.local/utt. Obsługa nowych opcji domyslnych. Nieskonczona dystrybucja tarball.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@41 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
pawelk 2008-05-07 18:30:20 +00:00
parent a7b254ce77
commit 6b3be72395
14 changed files with 403 additions and 379 deletions

View File

@ -1,18 +1,18 @@
BARDZO WAZNE: BARDZO WAZNE:
* w dystrybucji tarball umieszczac pliki w określonych miejscach
* gue SIE NIE KOMPILUJE !!! * gue SIE NIE KOMPILUJE !!!
WAZNE: WAZNE:
* zamienic kota na lepszego (Kubis) [TO] * zamienic kota na lepszego (Kubis) [TO]
* sen - unikać dwukrotnego wstawiania BOSów i EOSów * sen - unikać dwukrotnego wstawiania BOSów i EOSów
* uniezaleznic mar od attr.pm (ew. wcielic attr.pm) [TO]
* mar nie obsluguje plikow konfiguracyjnych [JW]
* ser i grp - parametr tags (zeby bral wskazany program tag2re) [TO]
* polaczyc sen'y [TO] * polaczyc sen'y [TO]
* programy z atrybutyem input-field: funkcja process_seg zwraca false, gdy nie ma pola podanego po -I * programy z atrybutyem input-field: funkcja process_seg zwraca false, gdy nie ma pola podanego po -I
* generowanie i sprawdzanie zaleznosci dla tarballa [PK] * generowanie i sprawdzanie zaleznosci dla tarballa [PK]
* przygotowanie dystrybujcji slownikow [PK] * przygotowanie dystrybujcji slownikow [PK]
* (zrobione dla ser?) Nazwy pmdb2re -> pmdb.tag2re (grp, ser). * (zrobione dla ser?) Nazwy pmdb2re -> pmdb.tag2re (grp, ser).
* Zadania zwiazane z rozbudowa ser (src/ser/TODO). * Zadania zwiazane z rozbudowa ser (src/ser/TODO).
* Nowa funkcjonalność dla kot? con? - każde zdanie w nowym wierszu * Nowa funkcjonalność dla kot? con? - kaĹĽde zdanie w nowym wierszu
* opcja info w dgp powinna miec domyslna wartosc d lub h * opcja info w dgp powinna miec domyslna wartosc d lub h

View File

@ -19,6 +19,7 @@ conf_compiledic(catfile($usr_home, 'compiledic.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_lem(catfile($usr_home, 'lem.conf'), $sys_home);
conf_mar(catfile($usr_home, 'mar.conf'), $sys_home);
conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); conf_ser(catfile($usr_home, 'ser.conf'), $sys_home);
conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home); conf_dgc(catfile($usr_home, 'dgc.conf'), $sys_home);
@ -85,6 +86,7 @@ sub conf_grp() {
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 "tags=uam\n";
close FILE; close FILE;
} }
@ -145,6 +147,17 @@ sub conf_lem() {
close FILE; close FILE;
} }
sub conf_mar() {
my $mar_file = shift;
my $utthome = shift;
open(FILE, ">$mar_file");
print FILE makeConfigHeader();
print FILE "tags=uam\n";
close FILE;
}
sub conf_ser() { sub conf_ser() {
my $ser_file = shift; my $ser_file = shift;
my $utthome = shift; my $utthome = shift;
@ -153,6 +166,7 @@ sub conf_ser() {
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";
print FILE "tags=uam\n";
close FILE; close FILE;
} }

148
app/dist/struktura.txt vendored
View File

@ -1,71 +1,77 @@
/usr/local/bin/aut2fsa /usr/local/bin/aut2fsa
/usr/local/bin/canonize /usr/local/bin/canonize
/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/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 /usr/local/bin/lem
/usr/local/bin/lem /usr/local/bin/mar
/usr/local/bin/mar /usr/local/bin/sen
/usr/local/bin/sen /usr/local/bin/sen-nl
/usr/local/bin/sen-nl /usr/local/bin/ser
/usr/local/bin/ser /usr/local/bin/tok
/usr/local/bin/tok /usr/local/bin/tre.rb
/usr/local/bin/tre.rb /usr/local/bin/unfla
/usr/local/bin/unfla /usr/local/bin/utt-make-config.pl
/usr/local/bin/utt-make-config.pl /usr/local/bin/ipi.tag2re
/usr/local/bin/ipi.tag2re /usr/local/bin/uam.tag2re
/usr/local/bin/uam.tag2re
# R.D. sugeruje /etc/utt
# R.D. sugeruje /etc/utt # lokalnie: ~/.utt lub (trendy) ~/.config/utt
# lokalnie: ~/.utt lub (trendy) ~/.config/utt /usr/local/etc/utt/con.conf
/usr/local/etc/utt/con.conf /usr/local/etc/utt/cor.conf
/usr/local/etc/utt/cor.conf /usr/local/etc/utt/dgc.conf
/usr/local/etc/utt/dgc.conf /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/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 /usr/local/etc/utt/sen.conf
/usr/local/etc/utt/sen.conf /usr/local/etc/utt/ser.conf
/usr/local/etc/utt/ser.conf /usr/local/etc/utt/tok.conf
/usr/local/etc/utt/tok.conf /usr/local/etc/utt/unfla.conf
/usr/local/etc/utt/unfla.conf /usr/local/etc/utt/utt.conf
/usr/local/etc/utt/utt.conf
/usr/local/share/utt/weights.kor
/usr/local/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8859-2.sym # lokalnie: ~/.local/share/utt/weights.kor
/usr/local/share/utt/pl_PL.ISO-8859-2/cor.bin /usr/local/share/utt/cats.dgc
/usr/local/share/utt/pl_PL.ISO-8859-2/gue.bin # lokalnie: ~/.local/share/utt/cats.dgc
/usr/local/share/utt/pl_PL.ISO-8859-2/lem.bin /usr/local/share/utt/gram.dgc
/usr/local/share/utt/pl_PL.UTF-8/pl_PL.UTF-8.sym # lokalnie: ~/.local/share/utt/gram.dgc
/usr/local/share/utt/pl_PL.UTF-8/cor.bin
/usr/local/share/utt/pl_PL.UTF-8/gue.bin /usr/local/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8859-2.sym
/usr/local/share/utt/pl_PL.UTF-8/lem.bin /usr/local/share/utt/pl_PL.ISO-8859-2/cor.bin
/usr/local/share/utt/pl_PL.ISO-8859-2/gue.bin
/usr/local/lib/utt/ser.l.template /usr/local/share/utt/pl_PL.ISO-8859-2/lem.bin
/usr/local/lib/utt/terms.m4 /usr/local/share/utt/pl_PL.UTF-8/pl_PL.UTF-8.sym
/usr/local/lib/utt/weights.kor # -> share /usr/local/share/utt/pl_PL.UTF-8/cor.bin
/usr/local/lib/utt/seg.rb # lok. ~/.local/lib/utt/seg.rb /usr/local/share/utt/pl_PL.UTF-8/gue.bin
/usr/local/lib/utt/cats.dgc # -> share /usr/local/share/utt/pl_PL.UTF-8/lem.bin
/usr/local/lib/utt/gram.dgc # -> share
/usr/local/lib/utt/ser.l.template
/usr/local/share/doc/utt/FAQ /usr/local/lib/utt/terms.m4
/usr/local/share/doc/utt/COPYRIGHT /usr/local/lib/utt/seg.rb
/usr/local/share/doc/utt/NEWS # lokalnie: ~/.local/lib/utt/seg.rb <-- tego nie trzeba tak
/usr/local/share/doc/utt/README /usr/local/lib/attr.pm
/usr/local/share/info/utt.info.gz # lokalnie: ~/.local/lib/utt/attr.pm
/usr/local/share/man/man3/utt.gz
/usr/local/share/doc/utt/FAQ
~/.utt/*.conf (wszystko z /usr/local/etc/utt) /usr/local/share/doc/utt/COPYRIGHT
/usr/local/share/doc/utt/NEWS
/usr/local/share/doc/utt/README
/usr/local/share/info/utt.info.gz
/usr/local/share/man/man3/utt.gz
~/.utt/*.conf (wszystko z /usr/local/etc/utt)

View File

@ -5,11 +5,13 @@
#version: 1.0 #version: 1.0
#author: Tomasz Obrebski #author: Tomasz Obrebski
use lib "/usr/local/lib/utt";
use lib "ENV{HOME}/.local/lib/utt";
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use attr; use attr;
#use File::HomeDir;
#use lib "$ENV{HOME}/.utt/lib/perl";
my $help; my $help;

View File

@ -6,12 +6,12 @@
#author: Tomasz Obrebski #author: Tomasz Obrebski
# wymaga niejawnie programu canonize!!!! # wymaga niejawnie programu canonize!!!!
#use lib "ENV{HOME}/.utt/lib/perl"; use lib "/usr/local/lib/utt";
use lib "ENV{HOME}/.local/lib/utt";
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Data::Dumper; use Data::Dumper;
use attr; use attr;
use File::HomeDir; use File::HomeDir;

View File

@ -1,297 +1,298 @@
#!/usr/bin/ruby #!/usr/bin/ruby -I /usr/local/lib/utt -I ~/.local/lib/utt
require 'getoptlong' require 'getoptlong'
opts = GetoptLong.new( opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ], [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--debug', '-d', GetoptLong::NO_ARGUMENT ], [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
[ '--format', '-F', GetoptLong::REQUIRED_ARGUMENT ], [ '--format', '-F', GetoptLong::REQUIRED_ARGUMENT ],
[ '--info', '-I', GetoptLong::REQUIRED_ARGUMENT ], [ '--info', '-I', GetoptLong::REQUIRED_ARGUMENT ],
[ '--only-trees','-t', GetoptLong::NO_ARGUMENT ]) [ '--only-trees','-t', GetoptLong::NO_ARGUMENT ])
$helptext= $helptext=
"The program generates trees from the graph output by dgp. dgp must\n"+ "The program generates trees from the graph output by dgp. dgp must\n"+
"must be run with '-i ds' option.\n\n"+ "must be run with '-i ds' option.\n\n"+
"Command: tre [options]\n\n"+ "Command: tre [options]\n\n"+
"Options:\n"+ "Options:\n"+
"--help -h Print help (this text) and exit.\n"+ "--help -h Print help (this text) and exit.\n"+
"--debug -d Verbose output. For developers only.\n"+ "--debug -d Verbose output. For developers only.\n"+
"--format=s -F s Output format. Recognized values:\n"+ "--format=s -F s Output format. Recognized values:\n"+
" a root + list of arcs\n"+ " a root + list of arcs\n"+
" p parenthesized notation\n"+ " p parenthesized notation\n"+
" h human readable indented tree format\n"+ " h human readable indented tree format\n"+
" Multiple values are allowed. (default p)\n"+ " Multiple values are allowed. (default p)\n"+
"--info=s -I s Information printed. Recognized values:\n"+ "--info=s -I s Information printed. Recognized values:\n"+
" n node identifier\n"+ " n node identifier\n"+
" f surface form\n"+ " f surface form\n"+
" m morphological information\n"+ " m morphological information\n"+
" l arc labels\n"+ " l arc labels\n"+
"--only-trees -t Do not copy input. Print trees only.\n" "--only-trees -t Do not copy input. Print trees only.\n"
$DEBUG=false $DEBUG=false
$FORMAT='p' $FORMAT='p'
$INFO='DEFAULT' $INFO='DEFAULT'
$ONLYTREES=false $ONLYTREES=false
opts.each do |opt, arg| opts.each do |opt, arg|
case opt case opt
when '--help' when '--help'
print $helptext print $helptext
exit 0 exit 0
when '--debug' when '--debug'
$DEBUG=true $DEBUG=true
when '--format' when '--format'
$FORMAT=arg $FORMAT=arg
when '--info' when '--info'
$INFO=arg $INFO=arg
when '--only-trees' when '--only-trees'
$ONLYTREES=true $ONLYTREES=true
else else
print "Unknown option #{opt}. Ignored.\n" print "Unknown option #{opt}. Ignored.\n"
end end
end end
if $INFO=='DEFAULT' if $INFO=='DEFAULT'
case $FORMAT case $FORMAT
when 'p','a' when 'p','a'
$INFO='nl' $INFO='nl'
when 'h' when 'h'
$INFO='fmnl' $INFO='fmnl'
end end
end end
load 'seg.rb' require File.expand_path(File.dirname(__FILE__) + "../lib/utt/seg.rb")
#require 'seg.rb'
$dgpsep=';'
$dgpsep=';'
def tre(input)
$gphid=[] def tre(input)
$form=[] $gphid=[]
$lem=[] $form=[]
nodes=[] $lem=[]
count=0 nodes=[]
seg=Seg.new count=0
for line in input seg=Seg.new
print line unless $ONLYTREES for line in input
seg.set(line) print line unless $ONLYTREES
if dgp=seg['dgp'] seg.set(line)
if nodes==[] && seg[3]!='BOS' if dgp=seg['dgp']
print "A sentence must start with BOS segment. Aborting.\n" if nodes==[] && seg[3]!='BOS'
return print "A sentence must start with BOS segment. Aborting.\n"
end return
end
id=dgp[/^\d+/].to_i
id=dgp[/^\d+/].to_i
if gph=seg['gph']
$gphid[id]=gph[/^\d+/].to_i if gph=seg['gph']
else $gphid[id]=gph[/^\d+/].to_i
print "No gph field. Aborting.\n" else
return print "No gph field. Aborting.\n"
end return
end
$form[$gphid[id]]=seg[4]
$lem[$gphid[id]]=seg['lem'] $form[$gphid[id]]=seg[4]
$lem[$gphid[id]]=seg['lem']
nodes[id] = [seg[1].to_i,dgp]
nodes[id] = [seg[1].to_i,dgp]
if seg[3]=='EOS'
$pref = "#{seg[1]} #{seg[2]} SYN *" if seg[3]=='EOS'
parsegraph(nodes) $pref = "#{seg[1]} #{seg[2]} SYN *"
printgraph if $DEBUG parsegraph(nodes)
$thetrees=[] printgraph if $DEBUG
gentrees2 $thetrees=[]
for t in $thetrees gentrees2
count += 1 for t in $thetrees
t1=ground(t) count += 1
case $FORMAT t1=ground(t)
when /a/ case $FORMAT
print "#{$pref} tre:#{count} arc:" when /a/
printarcs(t1[0],t1[1]) print "#{$pref} tre:#{count} arc:"
print "\n" printarcs(t1[0],t1[1])
when /p/ print "\n"
print "#{$pref} tre:#{count} par:" when /p/
printpar(t1[0],t1[1]) print "#{$pref} tre:#{count} par:"
print "\n" printpar(t1[0],t1[1])
when /h/ print "\n"
print "#\n# tree #{count}\n# ------\n" when /h/
printtree(t1[0],t1[1],0) print "#\n# tree #{count}\n# ------\n"
end printtree(t1[0],t1[1],0)
end end
nodes=[] end
end nodes=[]
end end
end end
end end
end
def nodeinfo(id)
info="" def nodeinfo(id)
if $INFO =~ /n/ info=""
info += id.to_s if $INFO =~ /n/
info += '.' if $INFO =~ /[fm]/ info += id.to_s
end info += '.' if $INFO =~ /[fm]/
if $INFO =~ /f/ end
info += $form[id] if $INFO =~ /f/
info += ';' if $INFO =~ /m/ info += $form[id]
end info += ';' if $INFO =~ /m/
if $INFO =~ /m/ end
info += $lem[id] if $INFO =~ /m/
end info += $lem[id]
info end
end info
end
def printarcs(root,arcs)
print nodeinfo(root) def printarcs(root,arcs)
for a in arcs print nodeinfo(root)
print ';' for a in arcs
print "#{a[2]}:" if $INFO =~ /l/ print ';'
print nodeinfo(a[0])+'-'+nodeinfo(a[1]) print "#{a[2]}:" if $INFO =~ /l/
end print nodeinfo(a[0])+'-'+nodeinfo(a[1])
end end
end
def printtree(root,arcs,o)
if o==0 def printtree(root,arcs,o)
print "# %-16s" % "root: " if o==0
end print "# %-16s" % "root: "
print nodeinfo(root),"\n" end
for arc in arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] } print nodeinfo(root),"\n"
print '# '," "*(o+1) for arc in arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] }
print "%-16s" % (arc[2]+": ") print '# '," "*(o+1)
printtree(arc[1],arcs,o+1) print "%-16s" % (arc[2]+": ")
end printtree(arc[1],arcs,o+1)
end end
end
def printpar(root,arcs)
print nodeinfo(root) def printpar(root,arcs)
deps = arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] } print nodeinfo(root)
unless deps == [] deps = arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] }
print '(' unless deps == []
cont=false print '('
for arc in deps cont=false
if cont then print ',' else cont=true end for arc in deps
print arc[2],':' if $INFO =~ /l/ if cont then print ',' else cont=true end
printpar(arc[1],arcs) print arc[2],':' if $INFO =~ /l/
end printpar(arc[1],arcs)
print ')' end
end print ')'
end end
end
def parsegraph(nodes)
def parsegraph(nodes)
$n =nodes.length
$sat =[]; $n =nodes.length
$sat =[];
$vis =[];
$succ=[]; $vis =[];
$lhs =[]; $succ=[];
$arcs=[]; $lhs =[];
$pos=[] $arcs=[];
$pos=[]
for dgp in nodes
for dgp in nodes
parts = dgp[1].split($dgpsep,6)
parts = dgp[1].split($dgpsep,6)
i = parts[0].to_i
$pos[i] = dgp[0].to_i i = parts[0].to_i
$sat << i if parts[1]=="s" $pos[i] = dgp[0].to_i
$arcs |= parts[2].split(',').map{ |a| case a $sat << i if parts[1]=="s"
when /\-\-(\w+)-(\d+)\/(\d+)/ $arcs |= parts[2].split(',').map{ |a| case a
[i, $2.to_i, $1, $3.to_i] when /\-\-(\w+)-(\d+)\/(\d+)/
when /\+\+(\d+)-(\w+)\/(\d+)/ [i, $2.to_i, $1, $3.to_i]
[$1.to_i, i, $2, $3.to_i] when /\+\+(\d+)-(\w+)\/(\d+)/
end } [$1.to_i, i, $2, $3.to_i]
$succ |= parts[3][1..-2].split(',').map{|x| [x.to_i,i]} end }
$vis |= parts[4][1..-2].split(',').map{|x| [x.to_i,i]} $succ |= parts[3][1..-2].split(',').map{|x| [x.to_i,i]}
$lhs |= parts[5][1..-2].split(',').map{|x| [x.to_i,i]} + [[i,i]] $vis |= parts[4][1..-2].split(',').map{|x| [x.to_i,i]}
$lhs |= parts[5][1..-2].split(',').map{|x| [x.to_i,i]} + [[i,i]]
end
end end
end
def ground(t)
[ $gphid[t[0]] , t[1].map{|a| [$gphid[a[0]],$gphid[a[1]],a[2]]} ] def ground(t)
end [ $gphid[t[0]] , t[1].map{|a| [$gphid[a[0]],$gphid[a[1]],a[2]]} ]
end
def gentrees2()
$thetrees=[]; def gentrees2()
bos=0; eos=$n-1; $thetrees=[];
roots = (1...eos).select{|i| $vis.include? [i,eos]}.select{|i| $vis.include? [bos,i]} bos=0; eos=$n-1;
if $DEBUG then print "ROOTS: #{roots.inspect}\n" end roots = (1...eos).select{|i| $vis.include? [i,eos]}.select{|i| $vis.include? [bos,i]}
for i in roots if $DEBUG then print "ROOTS: #{roots.inspect}\n" end
$theroot=i for i in roots
for r in buildR(i , eos, []) $theroot=i
(rmin,rmax,rtree) = r for r in buildR(i , eos, [])
buildR(bos, rmin, rtree) (rmin,rmax,rtree) = r
end buildR(bos, rmin, rtree)
end end
end end
end
def buildR(min, max, tree)
if $DEBUG then print "buildR--#{min}--#{max}--#{tree.inspect}\n" end def buildR(min, max, tree)
trees=[] if $DEBUG then print "buildR--#{min}--#{max}--#{tree.inspect}\n" end
for a in $arcs.select{|a| a[0]==max && $vis.include?([min,a[1]]) } trees=[]
if $DEBUG then print "ARC: #{a.inspect}\n" end for a in $arcs.select{|a| a[0]==max && $vis.include?([min,a[1]]) }
for r in buildR(a[1],a[3],tree+[a]) if $DEBUG then print "ARC: #{a.inspect}\n" end
(rmin,rmax,rarcs) = r for r in buildR(a[1],a[3],tree+[a])
for l in buildR(min,rmin,rarcs) (rmin,rmax,rarcs) = r
(lmin,lmax,larcs) = l for l in buildR(min,rmin,rarcs)
trees << [lmin,rmax,larcs] (lmin,lmax,larcs) = l
end trees << [lmin,rmax,larcs]
end end
end end
for i in (0...$n).select{|i| $succ.include?([i,max])}.select{|i| $lhs.include?([min,i])} end
for l in buildL(min,i,tree) for i in (0...$n).select{|i| $succ.include?([i,max])}.select{|i| $lhs.include?([min,i])}
(lmin,lmax,larcs) = l for l in buildL(min,i,tree)
trees << [lmin,lmax,larcs] (lmin,lmax,larcs) = l
end trees << [lmin,lmax,larcs]
end end
trees end
end trees
end
def buildL(min,max,tree)
if $DEBUG then print "buildL--#{min}--#{max}--#{tree.inspect}\n" end def buildL(min,max,tree)
if $pos[min]==$pos[max] if $DEBUG then print "buildL--#{min}--#{max}--#{tree.inspect}\n" end
if min==0 && max==0 if $pos[min]==$pos[max]
$thetrees.push [$theroot,tree] if min==0 && max==0
if $DEBUG then print "adding tree: #{tree.inspect}\n" end $thetrees.push [$theroot,tree]
end if $DEBUG then print "adding tree: #{tree.inspect}\n" end
return [[max,max,tree]] end
end return [[max,max,tree]]
trees=[] end
for arc in $arcs.select{|a| a[1]==max && $lhs.include?([min,a[0]]) } trees=[]
if $DEBUG then print "ARC: #{arc.inspect}\n" end for arc in $arcs.select{|a| a[1]==max && $lhs.include?([min,a[0]]) }
for r in buildR(arc[3],max,tree+[arc]) if $DEBUG then print "ARC: #{arc.inspect}\n" end
(rmin,rmax,rarcs) = r for r in buildR(arc[3],max,tree+[arc])
for l in buildL(min,rmin,rarcs) (rmin,rmax,rarcs) = r
(lmin,lmax,larcs) = l for l in buildL(min,rmin,rarcs)
trees << [lmin,lmax,larcs] (lmin,lmax,larcs) = l
end trees << [lmin,lmax,larcs]
end end
end end
trees end
end trees
end
def printgraph()
def printgraph()
print "N: #{$n}\n"
print "SAT: #{set_to_s($sat)}\n" print "N: #{$n}\n"
print "SUCC: #{rel_to_s($succ)}\n" print "SAT: #{set_to_s($sat)}\n"
print "VIS: #{rel_to_s($vis)}\n" print "SUCC: #{rel_to_s($succ)}\n"
print "LHS: #{rel_to_s($lhs)}\n" print "VIS: #{rel_to_s($vis)}\n"
print "ARCS: #{arcs_to_s($arcs)}\n" print "LHS: #{rel_to_s($lhs)}\n"
end print "ARCS: #{arcs_to_s($arcs)}\n"
end
def set_to_s(s) "{#{s.join(',')}}" end
def rel_to_s(r) "{#{r.map{|p| "(#{p[0]},#{p[1]})"}.join(',')}}" end def set_to_s(s) "{#{s.join(',')}}" end
def arc_to_s(q) "-#{q[0]}-#{q[2]}-#{q[1]}/#{q[3]}" end def rel_to_s(r) "{#{r.map{|p| "(#{p[0]},#{p[1]})"}.join(',')}}" end
def arcs_to_s(a) "{#{a.map{|q| arc_to_s(q)}.join(',')}}" end def arc_to_s(q) "-#{q[0]}-#{q[2]}-#{q[1]}/#{q[3]}" end
def arcs_to_s(a) "{#{a.map{|q| arc_to_s(q)}.join(',')}}" end
######################################################################
######################################################################
tre($stdin)
tre($stdin)

View File

@ -13,7 +13,6 @@ use File::HomeDir;
my $LIB_DIR="/usr/local/lib/utt"; my $LIB_DIR="/usr/local/lib/utt";
my $systemconfigfile="/usr/local/etc/utt/grp.conf"; my $systemconfigfile="/usr/local/etc/utt/grp.conf";
#my $userconfigfile="$ENV{'HOME'}/.utt/grp.conf";
my $userconfigfile=home()."/.utt/grp.conf"; my $userconfigfile=home()."/.utt/grp.conf";
Getopt::Long::Configure('no_ignore_case_always'); Getopt::Long::Configure('no_ignore_case_always');

View File

@ -5,11 +5,14 @@
#version: 1.0 #version: 1.0
#author: Marcin Walas #author: Marcin Walas
#this program tags the tokenized file with given tags #this program tags the tokenized file with given tags
#tags can be given in any order and configuration through the expression #tags can be given in any order and configuration through the expression
#which is one of the parametres of the script #which is one of the parametres of the script
#contact: d287572@atos.wmid.amu.edu.pl, walasiek@gmail.com #contact: d287572@atos.wmid.amu.edu.pl, walasiek@gmail.com
use lib "/usr/local/lib/utt";
use lib "ENV{HOME}/.local/lib/utt";
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use File::HomeDir; use File::HomeDir;

View File

@ -12,7 +12,6 @@ use File::HomeDir;
my $LIB_DIR="/usr/local/lib/utt"; my $LIB_DIR="/usr/local/lib/utt";
my $systemconfigfile='/usr/local/etc/utt/ser.conf'; my $systemconfigfile='/usr/local/etc/utt/ser.conf';
#my $userconfigfile="$ENV{'HOME'}/.utt/ser.conf";
my $userconfigfile=home()."/.utt/ser.conf"; my $userconfigfile=home()."/.utt/ser.conf";
Getopt::Long::Configure('no_ignore_case_always'); Getopt::Long::Configure('no_ignore_case_always');