diff --git a/_old/app/Makefile b/_old/app/Makefile index 6c95c7e..7f65981 100644 --- a/_old/app/Makefile +++ b/_old/app/Makefile @@ -53,7 +53,9 @@ dirs: mkdir -p ${UTT_SHARE_DIR}/man/man3 .PHONY: components -components: +components: + cd $(SRC_DIR)/lib && make; cd $(CUR_DIR) + @for cmp in $(COMPONENTS); do\ cd $(SRC_DIR)/$$cmp && make && make copy; cd $(CUR_DIR); \ done @@ -79,7 +81,7 @@ clean_doc: .PHONY: clean_dist clean_dist: - rm -rf ${UTT_DIR} + # ------------------------------------------------------------------ # sekcja przygotowania paczki (programow wraz z dodatkowymi plikami) @@ -142,6 +144,7 @@ dist_deb: build #dist: all # tar -czvf $(UTT_DIST_NAME).tgz $(UTT_DIR) + #clean_dist: # if [ -d $(UTT_DIST_DIR) ]; then rm -r $(UTT_DIST_DIR); else true; fi # if [ -f $(UTT_DIST_FILE).tar.bz2 ]; then rm $(UTT_DIST_FILE).tar.bz2; else true; fi diff --git a/_old/app/conf/Makefile b/_old/app/conf/Makefile deleted file mode 100644 index c6df9a7..0000000 --- a/_old/app/conf/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -main: - -copy: -ifdef UTT_CONF_DIR - cp *.conf ${UTT_CONF_DIR} -endif - -clean: diff --git a/_old/app/conf/compiledic.conf b/_old/app/conf/compiledic.conf deleted file mode 100644 index a7e7574..0000000 --- a/_old/app/conf/compiledic.conf +++ /dev/null @@ -1,13 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt/pl_PL.ISO-8859-2/pl_PL.ISO-8859-2.sym diff --git a/_old/app/conf/cor.conf b/_old/app/conf/cor.conf deleted file mode 100644 index 044cdd4..0000000 --- a/_old/app/conf/cor.conf +++ /dev/null @@ -1,14 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt -process = W diff --git a/_old/app/conf/dgc.conf b/_old/app/conf/dgc.conf deleted file mode 100644 index 11a3bcf..0000000 --- a/_old/app/conf/dgc.conf +++ /dev/null @@ -1,15 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt/cats.dgc -grammar = PATH_PREFIX/share/utt/gram.dgc -outputfile = PATH_PREFIX/share/utt/gram.dgp diff --git a/_old/app/conf/dgp.conf b/_old/app/conf/dgp.conf deleted file mode 100644 index 938affa..0000000 --- a/_old/app/conf/dgp.conf +++ /dev/null @@ -1,18 +0,0 @@ -# ************************************************************ -# * 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 -# - -grammar = PATH_PREFIX/share/utt/gram.dgp -process = W -process = BOS -process = EOS -info = d diff --git a/_old/app/conf/gph.conf b/_old/app/conf/gph.conf deleted file mode 100644 index 796c7c7..0000000 --- a/_old/app/conf/gph.conf +++ /dev/null @@ -1,16 +0,0 @@ -# ************************************************************ -# * 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 -# -process = W -process = BOS -process = EOS -reset = BOS diff --git a/_old/app/conf/grp.conf b/_old/app/conf/grp.conf deleted file mode 100644 index 4fdf0f0..0000000 --- a/_old/app/conf/grp.conf +++ /dev/null @@ -1,15 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/lib/utt/terms.m4 -tags=uam - diff --git a/_old/app/conf/gue.conf b/_old/app/conf/gue.conf deleted file mode 100644 index 044cdd4..0000000 --- a/_old/app/conf/gue.conf +++ /dev/null @@ -1,14 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt -process = W diff --git a/_old/app/conf/kor.conf b/_old/app/conf/kor.conf deleted file mode 100644 index e4b9315..0000000 --- a/_old/app/conf/kor.conf +++ /dev/null @@ -1,16 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt -weights = PATH_PREFIX/share/utt/weights.kor -threshold = 1.0 -process=W diff --git a/_old/app/conf/lem.conf b/_old/app/conf/lem.conf deleted file mode 100644 index 044cdd4..0000000 --- a/_old/app/conf/lem.conf +++ /dev/null @@ -1,14 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/share/utt -process = W diff --git a/_old/app/conf/mar.conf b/_old/app/conf/mar.conf deleted file mode 100644 index 4fdf0f0..0000000 --- a/_old/app/conf/mar.conf +++ /dev/null @@ -1,15 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/lib/utt/terms.m4 -tags=uam - diff --git a/_old/app/conf/ser.conf b/_old/app/conf/ser.conf deleted file mode 100644 index 3e52657..0000000 --- a/_old/app/conf/ser.conf +++ /dev/null @@ -1,15 +0,0 @@ -# ************************************************************ -# * 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 = PATH_PREFIX/lib/utt/terms.m4 -flex-template = PATH_PREFIX/lib/utt/ser.l.template -tags=uam diff --git a/_old/app/conf/utt.conf b/_old/app/conf/utt.conf deleted file mode 100644 index fa3f5a1..0000000 --- a/_old/app/conf/utt.conf +++ /dev/null @@ -1,14 +0,0 @@ -# ************************************************************ -# * 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 diff --git a/_old/app/src/common/Makefile b/_old/app/src/common/Makefile index db812f7..cd4bb61 100644 --- a/_old/app/src/common/Makefile +++ b/_old/app/src/common/Makefile @@ -1,7 +1,8 @@ -COMMON_PATH=../common +# main: cmdline.c main_template.cc +# g++ -o main cmdline.c common.cc main_template.cc -include ./common.mk +# cmdline.c cmdline.h : cmdline.ggo +# gengetopt -i cmdline.ggo -clean: - rm -f cmdline.c cmdline.h cmdline.ggo - +# cmdline.ggo: cmdline_common.ggo cmdline_program.ggo +# cat cmdline_common.ggo cmdline_program.ggo > cmdline.ggo diff --git a/_old/app/src/compiledic/Makefile b/_old/app/src/compiledic/Makefile index 9f14541..3b35b22 100644 --- a/_old/app/src/compiledic/Makefile +++ b/_old/app/src/compiledic/Makefile @@ -1,13 +1,16 @@ -CFLAG1 = -Wno-deprecated -O3 -fpermissive +CFLAG1 = -m32 -Wno-deprecated -O3 -fpermissive CFLAG_ST = -Wno-deprecated -O3 -fpermissive -static all: compiledic aut2fsa compiledic: + aut2fsa: aut2fsa.cc + #g++ -m32 -Wno-deprecated -O3 -fpermissive -static -o aut2fsa aut2fsa.cc g++ $(CFLAG1) -o aut2fsa aut2fsa.cc + copy: ifdef UTT_BIN_DIR cp compiledic fsm2aut aut2fsa ${UTT_BIN_DIR} diff --git a/_old/app/src/compiledic/aut2fsa.cc b/_old/app/src/compiledic/aut2fsa.cc index c1d3875..a6a695f 100644 --- a/_old/app/src/compiledic/aut2fsa.cc +++ b/_old/app/src/compiledic/aut2fsa.cc @@ -1,6 +1,6 @@ #include -#include +#include #include "../lib/tfti.h" diff --git a/_old/app/src/cor/Makefile b/_old/app/src/cor/Makefile index 59c2514..08b9a70 100644 --- a/_old/app/src/cor/Makefile +++ b/_old/app/src/cor/Makefile @@ -1,11 +1,12 @@ -PAR=-Wno-deprecated -fpermissive -static -PAR2=-c -Wno-deprecated -fpermissive +PAR=-Wno-deprecated -m32 -fpermissive -static +PAR2=-c -Wno-deprecated -m32 -fpermissive LIB_PATH=../lib COMMON_PATH=../common CMDLINE_FILE='"../cor/cmdline.h"' -cor: main.cc corr.o word.o auttools.o cmdline.c common_cor.o common.o +cor: main.cc corr.o $(LIB_PATH)/word.o \ + $(LIB_PATH)/auttools.o cmdline.c common_cor.o common.o g++ $(PAR) -D _CMDLINE_FILE=$(CMDLINE_FILE) main.cc corr.o common.o \ $(LIB_PATH)/word.o $(LIB_PATH)/auttools.o cmdline.c common_cor.o \ -o cor @@ -13,7 +14,8 @@ cor: main.cc corr.o word.o auttools.o cmdline.c common_cor.o common.o corr.o: corr.cc corr.hh g++ $(PAR2) corr.cc -common.o: cmdline_common +common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \ + $(COMMON_PATH)/common.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc common_cor.o: cmdline.h common_cor.cc common_cor.h @@ -37,5 +39,3 @@ clean: clean.cmdline clean.cmdline: rm cmdline.* || true -include $(COMMON_PATH)/common.mk -include $(LIB_PATH)/lib.mk diff --git a/_old/app/src/dgp/Makefile b/_old/app/src/dgp/Makefile index 726f028..974b12c 100644 --- a/_old/app/src/dgp/Makefile +++ b/_old/app/src/dgp/Makefile @@ -1,3 +1,5 @@ + + SHELL = /bin/sh LIB_PATH=../../lib COMMON_PATH=../common @@ -6,12 +8,12 @@ CMDLINE_FILE='"../dgp/cmdline.h"' #vpath %.o . -CXXFLAGS = -O2 -static -fpermissive +CXXFLAGS = -O2 -static sources = main.cc grammar.cc symbol.cc mgraph.cc sgraph.cc dgp0.cc cmdline.cc \ $(COMMON_PATH)/common.cc global.cc -bin = dgp dgc canonize tre +bin = dgp # plik *.o sa umieszczane w podkatalogu o objs = $(sources:%.cc=%.o) @@ -42,7 +44,8 @@ cmdline.ggo: cmdline_dgp.ggo ../common/cmdline_common.ggo clean: - rm ${bin} ${objs} cmdline.cc cmdline.h *.d + rm ${bin} ${objs} cmdline.cc cmdline.h + rm -rf *.d prof: dgp gprof dgp ~/tmp/dgp-pl/gmon.out > dgp.prof diff --git a/_old/app/src/dgp/canonize b/_old/app/src/dgp/canonize new file mode 100755 index 0000000..f9bd7b3 --- /dev/null +++ b/_old/app/src/dgp/canonize @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +#package: UAM TExt Tools +#component: canonize +#version: 1.0 +#author: Tomasz Obrebski + +use lib "/usr/local/lib/utt"; +use lib "$ENV{'HOME'}/.local/lib/utt"; + +use strict; +use Getopt::Long; +use attr; + + +my $help; + +GetOptions("help|h" => \$help); + +if($help) +{ + print <<'END' + +Transforms syntactic categories to their canonical form. + +Usage: canonize + +Options: + --help -h Help. + +END +; + exit 0; +} + +#$|=1; + +my %tra; + +while(<>) +{ + s/$attr::pos_re\/$attr::avlist_re/trans($&)/ge; + print; +} + +sub trans +{ + my $cat=shift; + exists($tra{$cat}) ? $tra{$cat} : ( $tra{$cat} = attr::canonize $cat ); +} diff --git a/_old/app/src/dgp/dgc b/_old/app/src/dgp/dgc new file mode 100755 index 0000000..8fd9d40 --- /dev/null +++ b/_old/app/src/dgp/dgc @@ -0,0 +1,292 @@ +#!/usr/bin/perl + +#package: UAM Text Tools +#component: dgc (dg compiler) +#version: 1.0 +#author: Tomasz Obrebski + +# wymaga niejawnie programu canonize!!!! +use lib "/usr/local/lib/utt"; +use lib "$ENV{'HOME'}/.local/lib/utt"; + +use strict; +use Getopt::Long; +use Data::Dumper; +use attr; +use File::HomeDir; + +my $systemconfigfile='/usr/local/etc/utt/dgc.conf'; +my $userconfigfile=home()."/.utt/dgc.conf"; + +Getopt::Long::Configure('no_ignore_case_always'); + +my $help=0; +my $catfile=0; +my $dicfile=0; +my $gramfile=0; +my $outputfile=0; + +#read configuration files########################### +my $file; +foreach $file ($systemconfigfile, $userconfigfile){ + if(open(CONFIG, $file)){ + while () { + chomp; + s/#.*//; + s/^\s+//; + s/\s+$//; + next unless length; + my ($name, $value) = split(/\s*=\s*/, $_, 2); + if(($name eq "categories")or($name eq "c")){ + $catfile=$value; + } + elsif(($name eq "dictionary")or($name eq "d")){ + $dicfile=$value; + } + elsif(($name eq "grammar")or($name eq "g")){ + $gramfile=$value; + } + elsif(($name eq "outputfile")or($name eq "o")){ + $outputfile=$value; + } + elsif(($name eq "help")or($name eq "h")){ + $help=1; + } + + } + close CONFIG; + } +} +######################################################### + +GetOptions("help|h" => \$help, + "categories|c=s" => \$catfile, + "dictionary|d=s" => \$dicfile, + "grammar|g=s" => \$gramfile, + "outputfile|o=s" => \$outputfile); + +my $homedir = $ENV{'HOME'}; +$catfile =~ s/~/$homedir/; +$dicfile =~ s/~/$homedir/; +$gramfile =~ s/~/$homedir/; +$outputfile =~ s/~/$homedir/; + + +if($help) +{ + print <<'END' +Usage: dgc [OPTIONS] + +Options: + --categories -c filename List of syntactic categories. + --dictionary -d filename Dictionary. + --grammar -g filename List of grammar rules. + --outputfile -o filename Output file name. + --help -h Help. +END +; + exit 0; +} + +die("At least one of --cats and --dic must be given.\n") if !$catfile && !$dicfile; + +my $ncat=0; +my $nrole=0; +my $nsgl=0; +my $nleft=0; +my $nright=0; +my $nreq=0; +my $nlink=0; +my $nflag=0; + +my %cats; +my %roles; +my %agr; +my %gov; + +if(!$outputfile) { + *OUTPUT = *STDOUT; +} +elsif($outputfile eq "-") { + *OUTPUT = *STDOUT; +} +else { + open(OUTPUT, ">$outputfile") or die("Can't open output file: $outputfile!"); +} + + +loadcats($catfile) if $catfile; +extractcats($dicfile) if $dicfile; + + +my $cats_re = qr/(?:$attr::cat_re\s*(?:,\s*$attr::cat_re)*)/; + +# class parse_class: +# /$attr::cat_re/g; + + +if(!$gramfile) { + *INPUT = *STDIN; +} +elsif($gramfile eq "-"){ + *INPUT = *STDIN; +} +else { + open(INPUT, $gramfile) or die("Unable to open: $gramfile!"); +} + +while() +{ + s/#.*//; + s/^\s+//; + s/\s+$//; + if(/^AGR\s+(\S+)\s+(\S+)$/) + { + push @{$agr{$1}}, $2; + } + elsif(/^GOV\s+(\S+)\s+(\S+)$/) + { + push @{$gov{$1}}, attr::parse($2); + } + elsif(/^ROLE\s+\S+$/) + { + $roles{$_}=1; + print OUTPUT "$_\n"; + } + elsif(/^SGL\s+\S+$/) + { + ++$nsgl; + print OUTPUT "$_\n"; + } + elsif(/^REQ\s+(\S+)\s+(\S+)$/) + { + print OUTPUT "#$_\n"; + my $cat = attr::parse $1; + for my $atomcat (keys %cats) + { + if(attr::match @$cat, @{$cats{$atomcat}}) + { + print OUTPUT "REQ ".$atomcat." $2\n"; + ++$nreq; + } + } + } + elsif(/^LEFT\s+\S+$/) + { + ++$nleft; + print OUTPUT "$_\n"; + } + elsif(/^RIGHT\s+\S+$/) + { + ++$nright; + print OUTPUT "$_\n"; + } + elsif(my ($hs,$ds,$r) = /^LINK\s+($cats_re)\s+($cats_re)\s+(\S+)$/) + { + print OUTPUT "#$_\n"; + for my $h ($hs =~ /$attr::cat_re/g) + { + for my $d ($ds =~ /$attr::cat_re/g) + { + addlinks($h,$d,$r); + } + } + } + elsif(/^FLAG\s+\S+$/) + { + ++$nflag; + print OUTPUT "$_\n" + } + elsif(/^$/) { + # pomijamy puste linie oraz komentarze + } + else + { + print STDERR "Illegal format: $_\n"; + } +} + + +sub addlinks +{ + my ($h,$d,$r) = @_; + + for my $a (@{$agr{$r}}) { print OUTPUT "#AGR $r $a\n"; } + for my $c (@{$gov{$r}}) { print OUTPUT "#GOV $r ".attr::unparse(@$c)."\n"; } + my $head = attr::parse $h; + my $dep = attr::parse $d; + + for my $atomhead (keys %cats) + { + if(attr::match @$head, @{$cats{$atomhead}}) + { + DEP: + for my $atomdep (keys %cats) + { + next DEP if ! attr::match @$dep, @{$cats{$atomdep}}; + + for my $a (@{$agr{$r}}) + { + next DEP if ! attr::agree(@{$cats{$atomhead}},@{$cats{$atomdep}},$a); + } + + for my $c (@{$gov{$r}}) + { + next DEP if ! attr::match(@$c,@{$cats{$atomdep}}); + } + + print OUTPUT "LINK "; + print OUTPUT $atomhead." "; + print OUTPUT $atomdep." $r\n"; + ++$nlink; + + } + } + } +} + + +printf STDERR "%6d CAT statements\n", 0+keys(%cats); +printf STDERR "%6d ROLE statements\n", 0+keys(%roles); +printf STDERR "%6d SGL statements\n", $nsgl; +printf STDERR "%6d REQ statements\n", $nreq; +printf STDERR "%6d LEFT statements\n", $nleft; +printf STDERR "%6d RIGHT statements\n", $nright; +printf STDERR "%6d LINK statements\n", $nlink; +printf STDERR "%6d FLAG statements\n", $nflag; + + +sub extractcats +{ + my $file = shift; + open DICFILE, "canonize $file |"; + while() + { + while(/,([^[:space:];]+)/g) + { + my $cat=$1; + next if !$cat || exists $cats{$cat}; + $ncat++; + print OUTPUT "CAT $1\n"; + $cats{$cat}=attr::parse($cat); + } + } + close DICFILE; +} + + +sub loadcats +{ + my $file = shift; + open CATFILE, "canonize $file |"; + while() + { + tr/ \t\n//d; + next if !$_ || exists $cats{$_}; + print OUTPUT "CAT $_\n"; + ++$ncat; + $cats{$_}=attr::parse($_); + } + close CATFILE; +} + diff --git a/_old/app/src/dgp/grammar.hh b/_old/app/src/dgp/grammar.hh index 27c19c4..81f56b7 100644 --- a/_old/app/src/dgp/grammar.hh +++ b/_old/app/src/dgp/grammar.hh @@ -11,6 +11,8 @@ #include "sgraph.hh" +using namespace std; + class Link { Role role; diff --git a/_old/app/src/dgp/mgraph.hh b/_old/app/src/dgp/mgraph.hh index 373eac2..fd309f6 100644 --- a/_old/app/src/dgp/mgraph.hh +++ b/_old/app/src/dgp/mgraph.hh @@ -7,6 +7,9 @@ #include "thesymbols.hh" #include "../common/common.h" + +using namespace std; + class MNode { public: diff --git a/_old/app/src/dgp/sgraph.hh b/_old/app/src/dgp/sgraph.hh index 1c04e39..3e7d964 100644 --- a/_old/app/src/dgp/sgraph.hh +++ b/_old/app/src/dgp/sgraph.hh @@ -11,6 +11,8 @@ #include "thesymbols.hh" +using namespace std; + class MNode; diff --git a/_old/app/src/dgp/thesymbols.hh b/_old/app/src/dgp/thesymbols.hh index b90f997..6d72dbc 100644 --- a/_old/app/src/dgp/thesymbols.hh +++ b/_old/app/src/dgp/thesymbols.hh @@ -8,6 +8,9 @@ #include #include + +using namespace std; + typedef Symbol<1> Cat; typedef Symbol<2> Role; diff --git a/_old/app/src/dgp/tre b/_old/app/src/dgp/tre new file mode 100755 index 0000000..fc337ae --- /dev/null +++ b/_old/app/src/dgp/tre @@ -0,0 +1,304 @@ +#!/usr/bin/ruby -I /usr/local/lib/utt -I $HOME/.local/lib/utt + +$: << "#{ENV['HOME']}/.local/lib/utt" +$: << "/usr/local/lib/utt" + +require 'getoptlong' +require 'seg.rb' + +opts = GetoptLong.new( +[ '--help', '-h', GetoptLong::NO_ARGUMENT ], +[ '--debug', '-d', GetoptLong::NO_ARGUMENT ], +[ '--format', '-F', GetoptLong::REQUIRED_ARGUMENT ], +[ '--info', '-I', GetoptLong::REQUIRED_ARGUMENT ], +[ '--only-trees','-t', GetoptLong::NO_ARGUMENT ]) + +$helptext= +"The program generates trees from the graph output by dgp. dgp must\n"+ +"must be run with '-i ds' option.\n\n"+ +"Command: tre [options]\n\n"+ +"Options:\n"+ +"--help -h Print help (this text) and exit.\n"+ +"--debug -d Verbose output. For developers only.\n"+ +"--format=s -F s Output format. Recognized values:\n"+ +" a root + list of arcs\n"+ +" p parenthesized notation\n"+ +" h human readable indented tree format\n"+ +" Multiple values are allowed. (default p)\n"+ +"--info=s -I s Information printed. Recognized values:\n"+ +" n node identifier\n"+ +" f surface form\n"+ +" m morphological information\n"+ +" l arc labels\n"+ +"--only-trees -t Do not copy input. Print trees only.\n" + +$DEBUG=false +$FORMAT='p' +$INFO='DEFAULT' +$ONLYTREES=false + +opts.each do |opt, arg| + case opt + when '--help' + print $helptext + exit 0 + when '--debug' + $DEBUG=true + when '--format' + $FORMAT=arg + when '--info' + $INFO=arg + when '--only-trees' + $ONLYTREES=true + else + print "Unknown option #{opt}. Ignored.\n" + end +end + +if $INFO=='DEFAULT' + case $FORMAT + when 'p','a' + $INFO='nl' + when 'h' + $INFO='fmnl' + end +end + +$dgpsep=';' + +def tre(input) + $gphid=[] + $form=[] + $lem=[] + nodes=[] + count=0 + seg=Seg.new + for line in input + print line unless $ONLYTREES + seg.set(line) + if dgp=seg['dgp'] + if nodes==[] && seg[3]!='BOS' + print "A sentence must start with BOS segment. Aborting.\n" + return + end + + id=dgp[/^\d+/].to_i + + if gph=seg['gph'] + $gphid[id]=gph[/^\d+/].to_i + else + print "No gph field. Aborting.\n" + return + end + + $form[$gphid[id]]=seg[4] + $lem[$gphid[id]]=seg['lem'] + + nodes[id] = [seg[1].to_i,dgp] + + if seg[3]=='EOS' + $pref = "#{seg[1]} #{seg[2]} SYN *" + parsegraph(nodes) + printgraph if $DEBUG + $thetrees=[] + gentrees2 + for t in $thetrees + count += 1 + t1=ground(t) + case $FORMAT + when /a/ + print "#{$pref} tre:#{count} arc:" + printarcs(t1[0],t1[1]) + print "\n" + when /p/ + print "#{$pref} tre:#{count} par:" + printpar(t1[0],t1[1]) + print "\n" + when /h/ + print "#\n# tree #{count}\n# ------\n" + printtree(t1[0],t1[1],0) + end + end + nodes=[] + end + end + end +end + + +def nodeinfo(id) + info="" + if $INFO =~ /n/ + info += id.to_s + info += '.' if $INFO =~ /[fm]/ + end + if $INFO =~ /f/ + info += $form[id] + info += ';' if $INFO =~ /m/ + end + if $INFO =~ /m/ + info += $lem[id] + end + info +end + + +def printarcs(root,arcs) + print nodeinfo(root) + for a in arcs + print ';' + print "#{a[2]}:" if $INFO =~ /l/ + print nodeinfo(a[0])+'-'+nodeinfo(a[1]) + end +end + +def printtree(root,arcs,o) + if o==0 + print "# %-16s" % "root: " + end + print nodeinfo(root),"\n" + for arc in arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] } + print '# '," "*(o+1) + print "%-16s" % (arc[2]+": ") + printtree(arc[1],arcs,o+1) + end +end + +def printpar(root,arcs) + print nodeinfo(root) + deps = arcs.select{ |a| a[0]==root }.sort{|a,b| a[1]<=>b[1] } + unless deps == [] + print '(' + cont=false + for arc in deps + if cont then print ',' else cont=true end + print arc[2],':' if $INFO =~ /l/ + printpar(arc[1],arcs) + end + print ')' + end +end + + +def parsegraph(nodes) + + $n =nodes.length + $sat =[]; + + $vis =[]; + $succ=[]; + $lhs =[]; + $arcs=[]; + $pos=[] + + for dgp in nodes + + parts = dgp[1].split($dgpsep,6) + + if parts[3]==nil || parts[4]==nil || parts[5]==nil + $stderr.print "ERR: tre requires dgp be called with '--info s' option. Aborting.\n" + exit + end + + i = parts[0].to_i + $pos[i] = dgp[0].to_i + $sat << i if parts[1]=="s" + $arcs |= parts[2].split(',').map{ |a| case a + when /\-\-(\w+)-(\d+)\/(\d+)/ + [i, $2.to_i, $1, $3.to_i] + when /\+\+(\d+)-(\w+)\/(\d+)/ + [$1.to_i, i, $2, $3.to_i] + end } + $succ |= parts[3][1..-2].split(',').map{|x| [x.to_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 + + +def ground(t) + [ $gphid[t[0]] , t[1].map{|a| [$gphid[a[0]],$gphid[a[1]],a[2]]} ] +end + + +def gentrees2() + $thetrees=[]; + bos=0; eos=$n-1; + roots = (1...eos).select{|i| $vis.include? [i,eos]}.select{|i| $vis.include? [bos,i]} + if $DEBUG then print "ROOTS: #{roots.inspect}\n" end + for i in roots + $theroot=i + for r in buildR(i , eos, []) + (rmin,rmax,rtree) = r + buildR(bos, rmin, rtree) + end + end +end + + +def buildR(min, max, tree) + if $DEBUG then print "buildR--#{min}--#{max}--#{tree.inspect}\n" end + trees=[] + for a in $arcs.select{|a| a[0]==max && $vis.include?([min,a[1]]) } + if $DEBUG then print "ARC: #{a.inspect}\n" end + for r in buildR(a[1],a[3],tree+[a]) + (rmin,rmax,rarcs) = r + for l in buildR(min,rmin,rarcs) + (lmin,lmax,larcs) = l + trees << [lmin,rmax,larcs] + end + end + end + for i in (0...$n).select{|i| $succ.include?([i,max])}.select{|i| $lhs.include?([min,i])} + for l in buildL(min,i,tree) + (lmin,lmax,larcs) = l + trees << [lmin,lmax,larcs] + end + end + trees +end + + +def buildL(min,max,tree) + if $DEBUG then print "buildL--#{min}--#{max}--#{tree.inspect}\n" end + if $pos[min]==$pos[max] + if min==0 && max==0 + $thetrees.push [$theroot,tree] + if $DEBUG then print "adding tree: #{tree.inspect}\n" end + end + return [[max,max,tree]] + end + trees=[] + for arc in $arcs.select{|a| a[1]==max && $lhs.include?([min,a[0]]) } + if $DEBUG then print "ARC: #{arc.inspect}\n" end + for r in buildR(arc[3],max,tree+[arc]) + (rmin,rmax,rarcs) = r + for l in buildL(min,rmin,rarcs) + (lmin,lmax,larcs) = l + trees << [lmin,lmax,larcs] + end + end + end + trees +end + + +def printgraph() + + print "N: #{$n}\n" + print "SAT: #{set_to_s($sat)}\n" + print "SUCC: #{rel_to_s($succ)}\n" + print "VIS: #{rel_to_s($vis)}\n" + print "LHS: #{rel_to_s($lhs)}\n" + 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 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) diff --git a/_old/app/src/gue/Makefile b/_old/app/src/gue/Makefile index 97f72c1..abd1da5 100644 --- a/_old/app/src/gue/Makefile +++ b/_old/app/src/gue/Makefile @@ -1,11 +1,12 @@ -PAR=-Wno-deprecated -O2 -fpermissive -static -PAR2=-c -Wno-deprecated -O2 -fpermissive +PAR=-Wno-deprecated -O3 -fpermissive -m32 -static +PAR2=-c -Wno-deprecated -O3 -fpermissive -m32 LIB_PATH=../lib COMMON_PATH=../common CMDLINE_FILE='"../gue/cmdline.h"' -gue: main.cc guess.o auttools.o word.o cmdline.c common_guess.o common.o +gue: main.cc guess.o $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o \ + cmdline.c common_guess.o common.o g++ $(PAR) main.cc guess.o \ $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o cmdline.c common.o common_guess.o \ -o gue @@ -16,7 +17,8 @@ guess.o: guess.h guess.cc common_guess.o: cmdline.h common_guess.cc common_guess.h g++ $(PAR2) common_guess.cc -common.o: $(COMMON_PATH)/cmdline_common.ggo cmdline_common +common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \ + $(COMMON_PATH)/common.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc cmdline.c cmdline.h: cmdline.ggo @@ -38,6 +40,3 @@ copy: ifdef UTT_BIN_DIR cp gue ${UTT_BIN_DIR} endif - -include $(LIB_PATH)/lib.mk -include $(COMMON_PATH)/common.mk diff --git a/_old/app/src/gue/guess.cc b/_old/app/src/gue/guess.cc index fa5908a..c52429a 100644 --- a/_old/app/src/gue/guess.cc +++ b/_old/app/src/gue/guess.cc @@ -1,11 +1,11 @@ #include "guess.h" -#include +#include #include -#include -#include -#include +#include +#include +#include #define DICT 1 #define COR 2 @@ -17,8 +17,10 @@ #define PREF_SIGN '_' + using namespace std; + Guess::Guess(const char* suf_file) : _suf(suf_file) { /* _suf = NULL; diff --git a/_old/app/src/kor/Makefile b/_old/app/src/kor/Makefile index ed0aac4..68113a9 100755 --- a/_old/app/src/kor/Makefile +++ b/_old/app/src/kor/Makefile @@ -1,22 +1,26 @@ -PAR=-Wno-deprecated -fpermissive -static -PAR2=-c -Wno-deprecated -fpermissive +PAR=-Wno-deprecated -m32 -fpermissive -static +PAR2=-c -Wno-deprecated -m32 -fpermissive LIB_PATH=../lib COMMON_PATH=../common CMDLINE_FILE='"../kor/cmdline.h"' -kor: main.cc corr.o corlist.o cmdline.o word.o auttools.o cmdline.c common_cor.o common.o +kor: main.cc corr.o corlist.o cmdline.o $(LIB_PATH)/word.o \ + $(LIB_PATH)/auttools.o cmdline.c common_cor.o common.o g++ $(PAR) -D _CMDLINE_FILE=$(CMDLINE_FILE) main.cc corlist.o corr.o common.o \ $(LIB_PATH)/word.o $(LIB_PATH)/auttools.o cmdline.c common_cor.o \ -o kor -corr.o: corr.cc corr.h cmdline.h +corr.o: corr.cc corr.hh cmdline.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) corr.cc corlist.o: corlist.cc corlist.h cmdline.h - g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) corlist.cc + g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) corlist.cc + -common.o: cmdline.h $(COMMON_PATH)/cmdline_common.ggo cmdline_common + +common.o: cmdline.h $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \ + $(COMMON_PATH)/common.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc common_cor.o: cmdline.h common_cor.cc common_cor.h @@ -40,5 +44,3 @@ clean: clean.cmdline clean.cmdline: rm cmdline.* || true -include $(COMMON_PATH)/common.mk -include $(LIB_PATH)/lib.mk diff --git a/_old/app/src/kor/corlist.cc b/_old/app/src/kor/corlist.cc index 83da1d0..79c92ec 100755 --- a/_old/app/src/kor/corlist.cc +++ b/_old/app/src/kor/corlist.cc @@ -1,10 +1,9 @@ -#include -//#include +#include +#include #include "corlist.h" #define min(x,y) ((x +{ +private: + Weight H[100][100]; + char X[100]; // misspelled string + char Y[100]; // (possibly partial) candidate string + int m; // length of X + int n; // maximal length of Y + + Weight ed(int,int); + Weight cuted(int); + void recomputeH(int); + + +public: + Weight (*H2)[100]; // moje: zmiana z int na Weight (float) + int t; // threshold + CorList CL; // moje + + Corr() : H2((Weight(*)[100])&H[2][2]) {}; // moje (int->float) + Corr(const char* a) : TFTiv(a), H2((Weight(*)[100])&H[2][2]) { }; + + int correct(const char* w, Words& tab); + + int load2(char *Name); // moje +}; + +//--------------------------------------------------------------------------- +#endif diff --git a/_old/app/src/kor/main.cc b/_old/app/src/kor/main.cc index 23eabd6..8095c7b 100755 --- a/_old/app/src/kor/main.cc +++ b/_old/app/src/kor/main.cc @@ -2,7 +2,7 @@ #include #include "../lib/iotools.h" #include "common_cor.h" -#include "corr.h" +#include "corr.hh" #include diff --git a/_old/app/src/lem/Makefile b/_old/app/src/lem/Makefile index 18d6483..a04fde9 100644 --- a/_old/app/src/lem/Makefile +++ b/_old/app/src/lem/Makefile @@ -1,11 +1,12 @@ -PAR=-Wno-deprecated -O2 -fpermissive -static -PAR2=-c -Wno-deprecated -O2 -fpermissive -static +PAR=-Wno-deprecated -m32 -O3 -fpermissive -static +PAR2=-c -Wno-deprecated -m32 -O3 -fpermissive -static LIB_PATH=../lib COMMON_PATH=../common CMDLINE_FILE='"../lem/cmdline.h"' -lem: main.cc lem.o auttools.o word.o cmdline.c common_lem.o common.o symtab.o +lem: main.cc lem.o $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o \ + cmdline.c common_lem.o common.o symtab.o g++ $(PAR) -D _CMDLINE_FILE=$(CMDLINE_FILE) \ main.cc lem.o $(LIB_PATH)/auttools.o \ $(LIB_PATH)/word.o cmdline.c common.o common_lem.o \ @@ -26,7 +27,8 @@ lem.o: lem.h lem.cc # erro.o: $(LIB_PATH)/erro.h $(LIB_PATH)/erro.cc # g++ $(PAR2) $(LIB_PATH)/erro.cc -common.o: cmdline_common +common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \ + $(COMMON_PATH)/common.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc common_lem.o: cmdline.h common_lem.h common_lem.cc @@ -35,7 +37,7 @@ common_lem.o: cmdline.h common_lem.h common_lem.cc cmdline.c cmdline.h: cmdline.ggo gengetopt -i cmdline.ggo --conf-parser -cmdline.ggo: cmdline_lem.ggo $(COMMON_PATH)/cmdline_common.ggo +cmdline.ggo: cmdline_lem.ggo ../common/cmdline_common.ggo cat cmdline_lem.ggo ../common/cmdline_common.ggo > cmdline.ggo symtab.o: $(LIB_PATH)/symtab.h $(LIB_PATH)/symtab.cc @@ -52,6 +54,3 @@ copy: ifdef UTT_BIN_DIR cp lem $(UTT_BIN_DIR) endif - -include $(COMMON_PATH)/common.mk -include $(LIB_PATH)/lib.mk diff --git a/_old/app/src/lem/lem.cc b/_old/app/src/lem/lem.cc index 5f5fb3f..d5b21c8 100644 --- a/_old/app/src/lem/lem.cc +++ b/_old/app/src/lem/lem.cc @@ -1,12 +1,9 @@ #include "lem.h" +#include #include -#include - -using namespace std; - /* Znajduje opisy slownikowe dla wyrazu. * Parametry: * form - wyraz, diff --git a/_old/app/src/lib/Makefile b/_old/app/src/lib/Makefile index 5da435d..708f12d 100644 --- a/_old/app/src/lib/Makefile +++ b/_old/app/src/lib/Makefile @@ -1,11 +1,17 @@ -PAR=-Wno-deprecated -O3 -PAR2=-c -Wno-deprecated -O3 -fpermissive +PAR=-Wno-deprecated -m32 -O3 +PAR2=-c -Wno-deprecated -m32 -O3 -fpermissive # -static LIB_PATH=../lib COMMON_PATH=../common main: auttools.o word.o copy +auttools.o: auttools.h auttools.cc + g++ $(PAR2) auttools.cc + +word.o: word.h word.cc + g++ $(PAR2) word.cc + clean: rm *.o @@ -13,5 +19,3 @@ copy: #ifdef UTT_LIB_DIR # cp -r perl $(UTT_LIB_DIR)/ #endif - -include ./lib.mk diff --git a/_old/app/src/lib/auttools.cc b/_old/app/src/lib/auttools.cc index 4a74ea7..daf018d 100644 --- a/_old/app/src/lib/auttools.cc +++ b/_old/app/src/lib/auttools.cc @@ -162,4 +162,3 @@ void despos(const char* des, char* pos) pos[pi]='\0'; } - diff --git a/_old/app/src/lib/symtab.cc b/_old/app/src/lib/symtab.cc index 51e2a1c..15579e0 100644 --- a/_old/app/src/lib/symtab.cc +++ b/_old/app/src/lib/symtab.cc @@ -1,9 +1,8 @@ #include "symtab.h" #include -#include -//#include -#include -using namespace std; +#include +#include +#include //--------------------------------------------------------------------------- SymbolTable::SymbolTable(int n, int (*h)(const char*,int), const char* filename) @@ -158,8 +157,7 @@ int hash2(const char* s, int _sz) strncpy((char*)&i1,s,sizeof(int)); strncpy((char*)&i2,s+(l/2-2),sizeof(int)); strncpy((char*)&i3,s+(l-4),sizeof(int)); - //return abs((i1+i2+i3) % _sz); - return (i1+i2+i3) % _sz; + return abs((i1+i2+i3) % _sz); } else { diff --git a/_old/app/src/lib/tft.h b/_old/app/src/lib/tft.h index a861949..85bab05 100755 --- a/_old/app/src/lib/tft.h +++ b/_old/app/src/lib/tft.h @@ -4,19 +4,20 @@ #include #include #include -#include +#include -#include +#include //#include "top.h" #include "ttrans.h" -using namespace std; + +using namespace std; //--------------------------------------------------------------------------- -/// Klasa bazowa przetwornika skoďż˝czonego. +/// Klasa bazowa przetwornika skończonego. /** - \remark Po co ta klasa? Co dotyczy samych przej��, przenie�� do TTrans, - resztďż˝ wcieliďż˝ do TFT. + \remark Po co ta klasa? Co dotyczy samych przejść, przenieść do TTrans, + resztę wcielić do TFT. */ class FT { @@ -24,46 +25,46 @@ public: FT() : copy_default(false), print_mode(OO), ttn(0) {}; //print mode - enum OUTPUT { II, ///< tylko symbole wejďż˝ciowe - OO, ///< tylko symbole wyjďż˝ciowe - IOIO, ///< symbol wyjďż˝ciowy po wejďż˝ciowym - OIOI, ///< symbol wyjďż˝ciowy przed wejďż˝ciowym - IIOO, ///< caďż˝e wejďż˝cie, potem caďż˝e wyjďż˝cie - OOII ///< caďż˝e wyjďż˝cie, potem caďż˝e wejďż˝cie + enum OUTPUT { II, ///< tylko symbole wejściowe + OO, ///< tylko symbole wyjściowe + IOIO, ///< symbol wyjściowy po wejściowym + OIOI, ///< symbol wyjściowy przed wejściowym + IIOO, ///< całe wejście, potem całe wyjście + OOII ///< całe wyjście, potem całe wejście }; -/// maks dďż˝ugo�� ďż˝cieďż˝ki +/// maks długość ścieżki static const unsigned int ftMAXPATH=500; -/// maks dďż˝ugo�� opisu typu symbolu we/wy +/// maks długość opisu typu symbolu we/wy /** - \remark Przenie�� do TTrans + \remark Przenieść do TTrans */ static const unsigned int ftTYPELEN=32; -/// specjalny symbol dla wartoďż˝ci 'epsilon' +/// specjalny symbol dla wartości 'epsilon' /** - \remark Przenie�� do TTrans + \remark Przenieść do TTrans */ static const char ftEPSILON='~'; -/// specialny symbol dla wartoďż˝ci 'default' +/// specialny symbol dla wartości 'default' /** - \remark Przenie�� do TTrans + \remark Przenieść do TTrans */ static const char ftDEFAULT='@'; -/// domyďż˝lny symbol wyjďż˝ciowy (true-'@', flase-'~') +/// domyślny symbol wyjściowy (true-'@', flase-'~') /** - \remark Przenie�� do TTrans(???) + \remark Przenieść do TTrans(???) */ bool copy_default; -/// tryb wyjďż˝cia +/// tryb wyjścia OUTPUT print_mode; -/// false, jeďż˝li automat nie ma przej�� +/// false, jeśli automat nie ma przejść operator bool() { return (bool)ttn; }; virtual const char* intype() { return itype; }; @@ -71,39 +72,39 @@ public: protected: -/// liczba elementďż˝w tablicy tt +/// liczba elementów tablicy tt unsigned long ttn; -/// liczba stanďż˝w +/// liczba stanów unsigned long states; -/// liczba przej�� +/// liczba przejść unsigned long transitions; -/// typ symboli wejďż˝ciowych (napis) +/// typ symboli wejściowych (napis) /** - \remark Przenie�� do TTrans(???) + \remark Przenieść do TTrans(???) */ char itype[ftTYPELEN]; -/// typ symboli wyjďż˝ciowych (napis) +/// typ symboli wyjściowych (napis) /** - \remark Przenie�� do TTrans(???) + \remark Przenieść do TTrans(???) */ char otype[ftTYPELEN]; }; //--------------------------------------------------------------------------- -/// Szablon przetwornika skoďż˝czonego +/// Szablon przetwornika skończonego /** - \param I - typ symbolu wejďż˝ciowego - \param Ipass - typ, jaki ma byďż˝ uďż˝yty przy przekazywaniu symbolu we jako parametru - do funkcji (metody), rďż˝wny \a I lub \a I& - \param O - typ symbolu wyjďż˝ciowego - \param Opass - typ, jaki ma byďż˝ uďż˝yty przy przekazywaniu symbolu wy jako parametru - do funkcji (metody), rďż˝wny \a O lub \a O& - \param - typ przejďż˝cia, musi byďż˝ podklasďż˝ TTrans + \param I - typ symbolu wejściowego + \param Ipass - typ, jaki ma być użyty przy przekazywaniu symbolu we jako parametru + do funkcji (metody), równy \a I lub \a I& + \param O - typ symbolu wyjściowego + \param Opass - typ, jaki ma być użyty przy przekazywaniu symbolu wy jako parametru + do funkcji (metody), równy \a O lub \a O& + \param - typ przejścia, musi być podklasą TTrans */ template class TFT : public FT @@ -116,58 +117,58 @@ public: /** \name Metody poziomu 1 -Poziom przej��. +Poziom przejść. */ //@{ -/// Test, czy przejďż˝cie \a t akceptuje symbol \a in. +/// Test, czy przejście \a t akceptuje symbol \a in. bool accepts(long t, Ipass in) const; -/// Test, czy lista przej�� dla aktualnego stanu jest kontynuowana po \a t. +/// Test, czy lista przejść dla aktualnego stanu jest kontynuowana po \a t. bool continued(long t) const; -/// Stan, do ktďż˝rego prowadzi przejďż˝cie \a t. +/// Stan, do którego prowadzi przejście \a t. /** \pre !empty(t) */ long next(long t) const; -/// Symbol wejďż˝ciowy przejďż˝cia \a t. +/// Symbol wejściowy przejścia \a t. Ipass input(long t) const; -/// Symbol wyjďż˝ciowy przejďż˝cia \a t. +/// Symbol wyjściowy przejścia \a t. Opass output(long t) const; -/// Zwraca \c true, jeďż˝li symbolem we przejďż˝cia \a t jest epsilon. +/// Zwraca \c true, jeśli symbolem we przejścia \a t jest epsilon. bool epsi(long t) const; -/// Zwraca \c true, jeďż˝li symbolem we przejďż˝cia \a t jest symbol domyďż˝lny. +/// Zwraca \c true, jeśli symbolem we przejścia \a t jest symbol domyślny. bool defi(long t) const; -/// Zwraca \c true, jeďż˝li symbolem wy przejďż˝cia \a t jest epsilon. +/// Zwraca \c true, jeśli symbolem wy przejścia \a t jest epsilon. bool epso(long t) const; -/// Zwraca \c true, jeďż˝li symbolem wy przejďż˝cia \a t jest symbol domyďż˝lny. +/// Zwraca \c true, jeśli symbolem wy przejścia \a t jest symbol domyślny. bool defo(long t) const; -/// Indeks przejďż˝cia przez \a in. +/// Indeks przejścia przez \a in. long tra(long t, Ipass in) const; -/// Indeks przejďż˝cia przez \a in - non-deterministic. +/// Indeks przejścia przez \a in - non-deterministic. long tra_nd(long t, Ipass in, long nth) const; //@} /** \name Poziom 2 -Poziom stanďż˝w. Stan (indeks stanu) = indeks jego pierwszego przejďż˝cia +Poziom stanów. Stan (indeks stanu) = indeks jego pierwszego przejścia */ //@{ -/// Zwraca \c true jeďż˝li stan \a s jest pusty (nie ma z niego przej��). +/// Zwraca \c true jeśli stan \a s jest pusty (nie ma z niego przejść). bool empty(long s) const { return tt[s].empty(); } -/// Zwraca \c true jeďż˝li stan \a s jest stanem koďż˝cowym. +/// Zwraca \c true jeśli stan \a s jest stanem końcowym. bool final(long s) const { return tt[s].final(); } long next(long t, Ipass in) const; @@ -201,7 +202,7 @@ Poziom ... protected: - TT* tt; // tablica przej�� + TT* tt; // tablica przejść long prn(const I* si, long* p, O* so) const; @@ -209,7 +210,7 @@ protected: void sort(); - void setiotypes(); // NIE DZIAďż˝A (dlaczego???) + void setiotypes(); // NIE DZIAŁA (dlaczego???) // friend ostream& operator<<(ostream&,const CDFA&); // friend istream& operator>>(istream&,CDFA&); @@ -227,12 +228,12 @@ private: //--------------------------------------------------------------------------- /** - stan = indeks pierwszego przejďż˝cia + stan = indeks pierwszego przejścia - state(t) = stan, do ktďż˝rego naleďż˝y t + state(t) = stan, do którego należy t - symbol zerowy = symbol s, dla ktďż˝rego (bool)s zwraca \c false, - w przypadku znakďż˝w - '\0' + symbol zerowy = symbol s, dla którego (bool)s zwraca \c false, + w przypadku znaków - '\0' */ //--------------------------------------------------------------------------- @@ -289,10 +290,10 @@ bool TFT::defo(long t) const { return tt[t].defo(); } /** - \param +t - indeks przejďż˝cia + \param +t - indeks przejścia \param +in - symbol we - \return Indeks przjďż˝cia (>=\a t) dla bie��cego stanu, ktďż˝re - akceptuje symbol we \a in lub -1, jeďż˝li nie ma takiego przejďż˝cia + \return Indeks przjścia (>=\a t) dla bieżącego stanu, które + akceptuje symbol we \a in lub -1, jeśli nie ma takiego przejścia */ template long TFT::tra(long t, Ipass in) const @@ -310,13 +311,13 @@ long TFT::tra(long t, Ipass in) const } //--------------------------------------------------------------------------- -/// Indeks przejďż˝cia - wersja dla automatu niedeterministycznego. +/// Indeks przejścia - wersja dla automatu niedeterministycznego. /** - \param +t - indeks przejďż˝cia + \param +t - indeks przejścia \param +in - symbol we - \return Indeks przjďż˝cia (>=\a t) dla bie��cego stanu, ktďż˝re - akceptuje symbol we \a in lub -1, jeďż˝li nie ma takiego przejďż˝cia - Jeďż˝li nth==0, t1>=t, w przeciwnym razie t1>t. + \return Indeks przjścia (>=\a t) dla bieżącego stanu, które + akceptuje symbol we \a in lub -1, jeśli nie ma takiego przejścia + Jeśli nth==0, t1>=t, w przeciwnym razie t1>t. */ template long TFT::tra_nd(long t, Ipass in, long nth) const @@ -347,12 +348,12 @@ long TFT::tra_nd(long t, Ipass in, long nth) const //---------------------------------------------------------------------------- -/// Funkcja przejďż˝cia. +/// Funkcja przejścia. /** \param t - stan \param in - symbol we - \return Stan, do ktďż˝rego moďż˝na przej�� z \a t po wpďż˝ywem symbolu \a in - lub -1, jeďż˝li nie ma przejďż˝cia przez \a in + \return Stan, do którego można przejść z \a t po wpływem symbolu \a in + lub -1, jeśli nie ma przejścia przez \a in */ template @@ -375,13 +376,13 @@ long TFT::next(long t, Ipass in) const //--------------------------------------------------------------------------- //---------------------------------------------------------------------------- -/// Uogďż˝lniona funkcja przejscia. +/// Uogólniona funkcja przejscia. /** \param +s - stan - \param +w - wskaďż˝nik pierwszego elementu ciďż˝gu symboli we, zakoďż˝czonego symbolem zerowym - \param maxpath maksymalna dďż˝ugo�� ďż˝cieďż˝ki, domyďż˝lnie ftMAXPATH - \return stan osiďż˝galny z \a s pod wpďż˝ywem \a w (na ďż˝cieďż˝ce mogďż˝ siďż˝ pojawiďż˝ - epsilon-przejďż˝cia + \param +w - wskaźnik pierwszego elementu ciągu symboli we, zakończonego symbolem zerowym + \param maxpath maksymalna długość ścieżki, domyślnie ftMAXPATH + \return stan osiągalny z \a s pod wpływem \a w (na ścieżce mogą się pojawić + epsilon-przejścia */ template long TFT::gtra(long s, const I* w, long maxpath) const @@ -410,12 +411,12 @@ long TFT::gtra(long s, const I* w, long maxpath) const /// Kontynuacja. /** ... -\param +s stan, jeďż˝li -1 - poszukiwane jest nastďż˝pne rozwiďż˝zanie -\param -c ciďż˝g symboli we ze ďż˝cieďż˝ki prowadzďż˝cej z \a s do - stanu koďż˝cowego -\return dďż˝ugo�� ciďż˝gu \a c (= dďż˝ugo�� ďż˝cieďż˝ki) -\remark DZIAďż˝A TYLKO DLA ZNAKďż˝W!!! - EPSILON-PRZEJďż˝CIA NIEDOZWOLONE!!! +\param +s stan, jeśli -1 - poszukiwane jest następne rozwiązanie +\param -c ciąg symboli we ze ścieżki prowadzącej z \a s do + stanu końcowego +\return długość ciągu \a c (= długość ścieżki) +\remark DZIAŁA TYLKO DLA ZNAKÓW!!! + EPSILON-PRZEJŚCIA NIEDOZWOLONE!!! */ template long TFT::cont(long s, I* c) const @@ -481,10 +482,10 @@ long TFT::match(const I* w, long* p) const //---------------------------------------------------------------------------- /// Dopasowanie niedeterministyczne. /** - \param +w - wskaďż˝nik pierwszego elementu ciďż˝gu symboli we, zakoďż˝czonego symbolem zerowym, - jeďż˝li NULL - poszukiwane jest nastďż˝pne rozwiďż˝zanie - \param -p ciďż˝g przej�� zakoďż˝czony -1 - \return dďż˝ugo�� dopasowania (PO CO?) + \param +w - wskaźnik pierwszego elementu ciągu symboli we, zakończonego symbolem zerowym, + jeśli NULL - poszukiwane jest następne rozwiązanie + \param -p ciąg przejść zakończony -1 + \return długość dopasowania (PO CO?) */ template long TFT::match_nd(const I* w, long* p) const @@ -525,13 +526,13 @@ long TFT::match_nd(const I* w, long* p) const } //---------------------------------------------------------------------------- -/// Najdďż˝uďż˝sze dopasowanie. +/// Najdłuższe dopasowanie. /** - \param +w wskaďż˝nik pierwszego elementu ciďż˝gu symboli wejďż˝ciowych - \param -p ďż˝cieďż˝ka - \param -plen dďż˝ugo�� ďż˝cieďż˝ki - \param +maxpath maks ddďż˝ugo�� ďż˝cieďż˝ki, domyďż˝lnie FT::ftMAXPATH - \return dďż˝ugo�� skonsumowanego wejďż˝cia + \param +w wskaźnik pierwszego elementu ciągu symboli wejściowych + \param -p ścieżka + \param -plen długość ścieżki + \param +maxpath maks ddługość ścieżki, domyślnie FT::ftMAXPATH + \return długość skonsumowanego wejścia */ template long TFT @@ -555,13 +556,13 @@ long TFT } //---------------------------------------------------------------------------- -/// Najdďż˝uďż˝sza ďż˝cieďż˝ka. +/// Najdłuższa ścieżka. /** - \param +buf wskaďż˝nik pierwszego elementu ciďż˝gu symboli wejďż˝ciowych + \param +buf wskaźnik pierwszego elementu ciągu symboli wejściowych \param -buf pozycja jeden za skonsumowanym prefiksem - \param +path wskaďż˝nik pierwszego elementu wektora przej�� - \param -path wskaďż˝nik jeden za ostatnim przejďż˝ciem - \return dďż˝ugo�� skonsumowanego prefiksu (PO CO? LEPIEJ Dďż˝ ďż˝CIEďż˝KI) + \param +path wskaźnik pierwszego elementu wektora przejść + \param -path wskaźnik jeden za ostatnim przejściem + \return długość skonsumowanego prefiksu (PO CO? LEPIEJ DŁ ŚCIEŻKI) */ template long TFT @@ -581,14 +582,14 @@ long TFT } //---------------------------------------------------------------------------- -/// Najdďż˝uďż˝szy prefiks. +/// Najdłuższy prefiks. /** - \param +buf wskaďż˝nik pierwszego elementu ciďż˝gu symboli wejďż˝ciowych + \param +buf wskaźnik pierwszego elementu ciągu symboli wejściowych \param -buf pozycja jeden za skonsumowanym prefiksem \param +sep separator - \return stan po przejďż˝ciu przez \a sep - \remark Dziaďż˝a tylko dla automatďż˝w deterministycznych, minimalnych, eps-wolnych, - gdzie dďż˝. ďż˝cieďż˝ki == dďż˝. dopasowania. + \return stan po przejściu przez \a sep + \remark Działa tylko dla automatów deterministycznych, minimalnych, eps-wolnych, + gdzie dł. ścieżki == dł. dopasowania. */ template long TFT @@ -600,14 +601,14 @@ long TFT static bool more; long s; - if(*buf) // pierwsze wywoďż˝anie + if(*buf) // pierwsze wywołanie { if(!lgstpath(buf,path,start)) return -1; --path; more=true; } - else // kolejne wywoďż˝anie + else // kolejne wywołanie --buf,--path; while(more) if(path>=pathtab) diff --git a/_old/app/src/lib/tfti.h b/_old/app/src/lib/tfti.h index 44c59ec..5f19735 100755 --- a/_old/app/src/lib/tfti.h +++ b/_old/app/src/lib/tfti.h @@ -2,16 +2,17 @@ #define TFTiH //--------------------------------------------------------------------------- #include -#include +#include #include -#include //#include #include "tft.h" //--------------------------------------------------------------------------- -using namespace std; - + +using namespace std; + + template class TFTi : public TFT > { diff --git a/_old/app/src/lib/ttrans.h b/_old/app/src/lib/ttrans.h index 587b574..1acdd15 100755 --- a/_old/app/src/lib/ttrans.h +++ b/_old/app/src/lib/ttrans.h @@ -2,9 +2,11 @@ #define _TTransi_h //--------------------------------------------------------------------------- #include -using namespace std; //--------------------------------------------------------------------------- + +using namespace std; + //! The template for a transition with input and output symbols stored internally. /*! A state is identified with the set of its outgoing transitions. diff --git a/_old/app/src/lib/word.cc b/_old/app/src/lib/word.cc index 75eaedb..8b4df0a 100644 --- a/_old/app/src/lib/word.cc +++ b/_old/app/src/lib/word.cc @@ -1,11 +1,11 @@ //--------------------------------------------------------------------------- #include "word.h" #include "auttools.h" -//#include #include -#include -using namespace std; //--------------------------------------------------------------------------- + +using namespace std; + //--------------------------------------------------------------------------- void Word::autodescr(const char* fo, const char* de) @@ -122,13 +122,13 @@ int Words::next() { } //--------------------------------------------------------------------------- -void Words::sort() { - std::sort(tab.begin(), tab.end(), Word::cmp_w); +void Words::sort() { +// sort(tab.begin(), tab.end(), Word::cmp_w); //NIE DZIALA } //--------------------------------------------------------------------------- -void Words::sort_rev() { - std::sort(tab.begin(), tab.end(), cmp_w_rev_fun); +void Words::sort_rev() { +// sort(tab.begin(), tab.end(), cmp_w_rev_fun); // NIE DZIALA } //--------------------------------------------------------------------------- @@ -143,15 +143,15 @@ int Words::add(const char* fo) if (cnt>=tab.capacity()-1) tab.resize(tab.size()*2); - - Word o; - o.form(fo); - o.w_suf(0.0); - tab.push_back(o); + + Word o; + o.form(fo); + o.w_suf(0.0); + tab.push_back(o); // tab[cnt].form(fo); // tab[cnt].w_suf(0.0); - + // if(cntform(fo); @@ -163,8 +163,7 @@ int Words::add(const char* fo) } //--------------------------------------------------------------------------- - - //TYMCZASOWO TAK(DLA CORA) + //TYMCZASOWO TAK(DLA CORA) int Words::add(const char* fo, float weight) { int i = find(fo); @@ -175,13 +174,13 @@ int Words::add(const char* fo, float weight) if (cnt>=tab.capacity()-1) tab.resize(tab.size()*2); - Word o; - o.form(fo); - o.w_suf(weight); - tab.push_back(o); + Word o; + o.form(fo); + o.w_suf(weight); + tab.push_back(o); // tab[cnt].form(fo); // tab[cnt].w_suf(weight); - + return cnt++; // } //return -1; diff --git a/_old/app/src/lib/word.h b/_old/app/src/lib/word.h index 1eff97f..216ac6c 100644 --- a/_old/app/src/lib/word.h +++ b/_old/app/src/lib/word.h @@ -5,17 +5,17 @@ //#include "alphabet.h" //#include "erro.h" #include "const.h" -//#include #include + +#include + #include -#include -using namespace std; //--------------------------------------------------------------------------- using namespace std; - - + + class Word { public: @@ -81,7 +81,7 @@ public: }; - + inline Word::Word(const Word& word) { strcpy(f,word.f); strcpy(l,word.l); strcpy(d,word.d); _len_suf=word._len_suf; _w_suf=word._w_suf; returned = 0; } @@ -106,14 +106,14 @@ inline int Word::cmp(const Word& w) { return strcmp(f,w.f); } //inline int Word::cmpi(const Word& w) { return PL.cmpi(f,w.f); } //--------------------------------------------------------------------------- - - - - -bool cmp_w_fun(Word a, Word b); -bool cmp_w_rev_fun(Word a, Word b); - - + + + + +bool cmp_w_fun(Word a, Word b); +bool cmp_w_rev_fun(Word a, Word b); + + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -132,7 +132,7 @@ class Words int count() const { return cnt; } void clear() { cnt=0; tab.clear(); } int add(const char* fo); - int add(const char* fo, float weight); + int add(const char* fo, float weight); int add(const char* fo, const char* des); /* zwraca index nastepnego wyniku, podczas pierwszego wywolania diff --git a/_old/app/src/tok.c/Makefile b/_old/app/src/tok.c/Makefile index 0fe5320..8bdf536 100644 --- a/_old/app/src/tok.c/Makefile +++ b/_old/app/src/tok.c/Makefile @@ -1,7 +1,6 @@ -PAR=-Wno-deprecated -O3 -fpermissive +PAR=-Wno-deprecated -O3 PAR2=-c -Wno-deprecated -O3 LIB_PATH=../lib -COMMON_PATH=../common CMDLINE_FILE='"../tok.c/cmdline.h"' @@ -15,11 +14,12 @@ tok.o: tok.c cmdline.h common_tok.o: cmdline.h common_tok.cc common_tok.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) common_tok.cc -common.o: cmdline_common +common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \ + $(COMMON_PATH)/common.h g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc -cmdline.ggo: cmdline_tok.ggo $(COMMON_PATH)/cmdline_common.ggo - cat cmdline_tok.ggo $(COMMON_PATH)/cmdline_common.ggo > cmdline.ggo +cmdline.ggo: cmdline_tok.ggo ../common/cmdline_common.ggo + cat cmdline_tok.ggo ../common/cmdline_common.ggo > cmdline.ggo cmdline.c cmdline.h: cmdline.ggo gengetopt -i cmdline.ggo --conf-parser @@ -31,11 +31,7 @@ endif clean: clean.cmdline - rm *.o || true - rm tok || true + rm *.o clean.cmdline: rm cmdline.* - -include $(COMMON_PATH)/common.mk -include $(LIB_PATH)/lib.mk diff --git a/_old/app/src/tok.c/cmdline_tok.ggo b/_old/app/src/tok.c/cmdline_tok.ggo index 2533547..8316f5c 100644 --- a/_old/app/src/tok.c/cmdline_tok.ggo +++ b/_old/app/src/tok.c/cmdline_tok.ggo @@ -1,5 +1,4 @@ package "tok" version "0.1" -option "dictionary" d "Dictionary" string typestr="FILENAME" default="cor.bin" no diff --git a/_old/app/src/tok.c/common_tok.cc b/_old/app/src/tok.c/common_tok.cc index f9d5f6b..eb4dca1 100644 --- a/_old/app/src/tok.c/common_tok.cc +++ b/_old/app/src/tok.c/common_tok.cc @@ -1,9 +1,7 @@ -#include -#include +#include +#include #include "common_tok.h" -using namespace std; - char dictionary[255]; void process_tok_options(gengetopt_args_info args) diff --git a/_old/app/src/tok/Makefile b/_old/app/src/tok/Makefile index cda37cc..f6d4bb7 100644 --- a/_old/app/src/tok/Makefile +++ b/_old/app/src/tok/Makefile @@ -1,6 +1,6 @@ tok: -copy: +copy: ifdef UTT_BIN_DIR cp tok ${UTT_BIN_DIR} endif diff --git a/_old/nawszelkiwypadek/tools/aut2fsa b/_old/nawszelkiwypadek/tools/aut2fsa old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl b/_old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/cor_dic/prep.pl b/_old/nawszelkiwypadek/tools/cor_dic/prep.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/fsm2aut b/_old/nawszelkiwypadek/tools/fsm2aut old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/canon.pl b/_old/nawszelkiwypadek/tools/gue_dic/canon.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/compile_user_dict.pl b/_old/nawszelkiwypadek/tools/gue_dic/compile_user_dict.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl b/_old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl b/_old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl b/_old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/prep.pl b/_old/nawszelkiwypadek/tools/gue_dic/prep.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl b/_old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/rmDup.pl b/_old/nawszelkiwypadek/tools/gue_dic/rmDup.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/stat.pl b/_old/nawszelkiwypadek/tools/gue_dic/stat.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl b/_old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl b/_old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl old mode 100644 new mode 100755 diff --git a/_old/nawszelkiwypadek/tools/lem_dic/prep.pl b/_old/nawszelkiwypadek/tools/lem_dic/prep.pl old mode 100644 new mode 100755 diff --git a/auto/defaults b/auto/defaults old mode 100644 new mode 100755 diff --git a/auto/options b/auto/options old mode 100644 new mode 100755 diff --git a/auto/output/Makefile b/auto/output/Makefile old mode 100644 new mode 100755 diff --git a/auto/output/config_h b/auto/output/config_h old mode 100644 new mode 100755 diff --git a/auto/summary b/auto/summary old mode 100644 new mode 100755 diff --git a/configure b/configure old mode 100644 new mode 100755