ANULOWANIE POPRZEDNIEGO COMMITU

Revert "Replacing old implementation with working implementation"

This reverts commit 1e121f45e2.

 Please enter the commit message for your changes. Lines starting
 with '#' will be ignored, and an empty message aborts the commit.

 Committer: tom <tom@lim.(none)>

 On branch master
 Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   _old/app/Makefile
	deleted:    _old/app/conf/Makefile
	deleted:    _old/app/conf/compiledic.conf
	deleted:    _old/app/conf/cor.conf
	deleted:    _old/app/conf/dgc.conf
	deleted:    _old/app/conf/dgp.conf
	deleted:    _old/app/conf/gph.conf
	deleted:    _old/app/conf/grp.conf
	deleted:    _old/app/conf/gue.conf
	deleted:    _old/app/conf/kor.conf
	deleted:    _old/app/conf/lem.conf
	deleted:    _old/app/conf/mar.conf
	deleted:    _old/app/conf/ser.conf
	deleted:    _old/app/conf/utt.conf
	modified:   _old/app/src/common/Makefile
	modified:   _old/app/src/compiledic/Makefile
	modified:   _old/app/src/compiledic/aut2fsa.cc
	modified:   _old/app/src/cor/Makefile
	modified:   _old/app/src/dgp/Makefile
	new file:   _old/app/src/dgp/canonize
	new file:   _old/app/src/dgp/dgc
	modified:   _old/app/src/dgp/grammar.hh
	modified:   _old/app/src/dgp/mgraph.hh
	modified:   _old/app/src/dgp/sgraph.hh
	modified:   _old/app/src/dgp/thesymbols.hh
	new file:   _old/app/src/dgp/tre
	modified:   _old/app/src/gue/Makefile
	modified:   _old/app/src/gue/guess.cc
	modified:   _old/app/src/kor/Makefile
	modified:   _old/app/src/kor/corlist.cc
	modified:   _old/app/src/kor/corr.cc
	new file:   _old/app/src/kor/corr.hh
	modified:   _old/app/src/kor/main.cc
	modified:   _old/app/src/lem/Makefile
	modified:   _old/app/src/lem/lem.cc
	modified:   _old/app/src/lib/Makefile
	modified:   _old/app/src/lib/auttools.cc
	modified:   _old/app/src/lib/symtab.cc
	modified:   _old/app/src/lib/tft.h
	modified:   _old/app/src/lib/tfti.h
	modified:   _old/app/src/lib/ttrans.h
	modified:   _old/app/src/lib/word.cc
	modified:   _old/app/src/lib/word.h
	modified:   _old/app/src/tok.c/Makefile
	modified:   _old/app/src/tok.c/cmdline_tok.ggo
	modified:   _old/app/src/tok.c/common_tok.cc
	modified:   _old/app/src/tok/Makefile
	modified:   _old/nawszelkiwypadek/tools/aut2fsa
	modified:   _old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl
	modified:   _old/nawszelkiwypadek/tools/cor_dic/prep.pl
	modified:   _old/nawszelkiwypadek/tools/fsm2aut
	modified:   _old/nawszelkiwypadek/tools/gue_dic/canon.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/compile_user_dict.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/prep.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/rmDup.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/stat.pl
	modified:   _old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl
	modified:   _old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl
	modified:   _old/nawszelkiwypadek/tools/lem_dic/prep.pl
	modified:   auto/defaults
	modified:   auto/options
	modified:   auto/output/Makefile
	modified:   auto/output/config_h
	modified:   auto/summary
	modified:   configure
This commit is contained in:
tom 2011-12-14 16:08:41 +01:00
parent 1e121f45e2
commit a6e708f37f
69 changed files with 924 additions and 411 deletions

View File

@ -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

View File

@ -1,8 +0,0 @@
main:
copy:
ifdef UTT_CONF_DIR
cp *.conf ${UTT_CONF_DIR}
endif
clean:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -1,6 +1,6 @@
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include "../lib/tfti.h"

View File

@ -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

View File

@ -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

50
_old/app/src/dgp/canonize Executable file
View File

@ -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 );
}

292
_old/app/src/dgp/dgc Executable file
View File

@ -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 (<CONFIG>) {
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(<INPUT>)
{
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(<DICFILE>)
{
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(<CATFILE>)
{
tr/ \t\n//d;
next if !$_ || exists $cats{$_};
print OUTPUT "CAT $_\n";
++$ncat;
$cats{$_}=attr::parse($_);
}
close CATFILE;
}

View File

@ -11,6 +11,8 @@
#include "sgraph.hh"
using namespace std;
class Link
{
Role role;

View File

@ -7,6 +7,9 @@
#include "thesymbols.hh"
#include "../common/common.h"
using namespace std;
class MNode
{
public:

View File

@ -11,6 +11,8 @@
#include "thesymbols.hh"
using namespace std;
class MNode;

View File

@ -8,6 +8,9 @@
#include <set>
#include <bitset>
using namespace std;
typedef Symbol<1> Cat;
typedef Symbol<2> Role;

304
_old/app/src/dgp/tre Executable file
View File

@ -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)

View File

@ -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

View File

@ -1,11 +1,11 @@
#include "guess.h"
#include <cstring>
#include <string.h>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#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;

View File

@ -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

View File

@ -1,10 +1,9 @@
#include <cstdio>
//#include <alloc.h>
#include <stdio.h>
#include <malloc.h>
#include "corlist.h"
#define min(x,y) ((x<y)?(x):(y))
using namespace std;
Weight CorList::GetValue(char X[100], char Y[100], Weight (*H2)[100], int i, int j)
{

View File

@ -1,6 +1,6 @@
//---------------------------------------------------------------------------
#include "common_cor.h"
#include "corr.h"
#include "corr.hh"
#define MAXPATH 256

39
_old/app/src/kor/corr.hh Executable file
View File

@ -0,0 +1,39 @@
//---------------------------------------------------------------------------
#ifndef _corr_hh
#define _corr_hh
//---------------------------------------------------------------------------
#include "../lib/tfti.h"
#include "../lib/word.h"
#include "corlist.h"
#include "../common/common.h"
class Corr : public TFTiv<char,char>
{
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<char,char>(a), H2((Weight(*)[100])&H[2][2]) { };
int correct(const char* w, Words& tab);
int load2(char *Name); // moje
};
//---------------------------------------------------------------------------
#endif

View File

@ -2,7 +2,7 @@
#include <ctype.h>
#include "../lib/iotools.h"
#include "common_cor.h"
#include "corr.h"
#include "corr.hh"
#include <locale.h>

View File

@ -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

View File

@ -1,12 +1,9 @@
#include "lem.h"
#include <stdlib.h>
#include <assert.h>
#include <cstdlib>
using namespace std;
/* Znajduje opisy slownikowe dla wyrazu.
* Parametry:
* form - wyraz,

View File

@ -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

View File

@ -162,4 +162,3 @@ void despos(const char* des, char* pos)
pos[pi]='\0';
}

View File

@ -1,9 +1,8 @@
#include "symtab.h"
#include <values.h>
#include <cstdio>
//#include <alloc.h>
#include <cstdlib>
using namespace std;
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
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
{

View File

@ -4,19 +4,20 @@
#include <stddef.h>
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <string.h>
#include <cstdio>
#include <stdio.h>
//#include "top.h"
#include "ttrans.h"
using namespace std;
using namespace std;
//---------------------------------------------------------------------------
/// Klasa bazowa przetwornika sko<EFBFBD>czonego.
/// Klasa bazowa przetwornika skończonego.
/**
\remark Po co ta klasa? Co dotyczy samych przej<EFBFBD><EFBFBD>, przenie<EFBFBD><EFBFBD> do TTrans,
reszt<EFBFBD> wcieli<EFBFBD> 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<EFBFBD>ciowe
OO, ///< tylko symbole wyj<EFBFBD>ciowe
IOIO, ///< symbol wyj<EFBFBD>ciowy po wej<65>ciowym
OIOI, ///< symbol wyj<EFBFBD>ciowy przed wej<65>ciowym
IIOO, ///< ca<EFBFBD>e wej<65>cie, potem ca<63>e wyj<79>cie
OOII ///< ca<EFBFBD>e wyj<79>cie, potem ca<63>e wej<65>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<EFBFBD>ugo<EFBFBD><EFBFBD> <20>cie<69>ki
/// maks długość ścieżki
static const unsigned int ftMAXPATH=500;
/// maks d<EFBFBD>ugo<EFBFBD><EFBFBD> opisu typu symbolu we/wy
/// maks długość opisu typu symbolu we/wy
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans
\remark Przenieść do TTrans
*/
static const unsigned int ftTYPELEN=32;
/// specjalny symbol dla warto<EFBFBD>ci 'epsilon'
/// specjalny symbol dla wartości 'epsilon'
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans
\remark Przenieść do TTrans
*/
static const char ftEPSILON='~';
/// specialny symbol dla warto<EFBFBD>ci 'default'
/// specialny symbol dla wartości 'default'
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans
\remark Przenieść do TTrans
*/
static const char ftDEFAULT='@';
/// domy<EFBFBD>lny symbol wyj<79>ciowy (true-'@', flase-'~')
/// domyślny symbol wyjściowy (true-'@', flase-'~')
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
\remark Przenieść do TTrans(???)
*/
bool copy_default;
/// tryb wyj<EFBFBD>cia
/// tryb wyjścia
OUTPUT print_mode;
/// false, je<EFBFBD>li automat nie ma przej<65><6A>
/// 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<EFBFBD>w tablicy tt
/// liczba elementów tablicy tt
unsigned long ttn;
/// liczba stan<EFBFBD>w
/// liczba stanów
unsigned long states;
/// liczba przej<EFBFBD><EFBFBD>
/// liczba przejść
unsigned long transitions;
/// typ symboli wej<EFBFBD>ciowych (napis)
/// typ symboli wejściowych (napis)
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
\remark Przenieść do TTrans(???)
*/
char itype[ftTYPELEN];
/// typ symboli wyj<EFBFBD>ciowych (napis)
/// typ symboli wyjściowych (napis)
/**
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
\remark Przenieść do TTrans(???)
*/
char otype[ftTYPELEN];
};
//---------------------------------------------------------------------------
/// Szablon przetwornika sko<EFBFBD>czonego
/// Szablon przetwornika skończonego
/**
\param I - typ symbolu wej<EFBFBD>ciowego
\param Ipass - typ, jaki ma by<EFBFBD> u<EFBFBD>yty przy przekazywaniu symbolu we jako parametru
do funkcji (metody), r<EFBFBD>wny \a I lub \a I&
\param O - typ symbolu wyj<EFBFBD>ciowego
\param Opass - typ, jaki ma by<EFBFBD> u<EFBFBD>yty przy przekazywaniu symbolu wy jako parametru
do funkcji (metody), r<EFBFBD>wny \a O lub \a O&
\param - typ przej<EFBFBD>cia, musi by<EFBFBD> podklas<EFBFBD> TTrans
\param I - typ symbolu wejściowego
\param Ipass - typ, jaki ma być 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ć 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 I, class Ipass, class O, class Opass, class TT>
class TFT : public FT
@ -116,58 +117,58 @@ public:
/**
\name Metody poziomu 1
Poziom przej<EFBFBD><EFBFBD>.
Poziom przejść.
*/
//@{
/// Test, czy przej<EFBFBD>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<EFBFBD><EFBFBD> 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<EFBFBD>rego prowadzi przej<65>cie \a t.
/// Stan, do którego prowadzi przejście \a t.
/**
\pre !empty(t)
*/
long next(long t) const;
/// Symbol wej<EFBFBD>ciowy przej<65>cia \a t.
/// Symbol wejściowy przejścia \a t.
Ipass input(long t) const;
/// Symbol wyj<EFBFBD>ciowy przej<65>cia \a t.
/// Symbol wyjściowy przejścia \a t.
Opass output(long t) const;
/// Zwraca \c true, je<EFBFBD>li symbolem we przej<65>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<EFBFBD>li symbolem we przej<65>cia \a t jest symbol domy<6D>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<EFBFBD>li symbolem wy przej<65>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<EFBFBD>li symbolem wy przej<65>cia \a t jest symbol domy<6D>lny.
/// Zwraca \c true, jeśli symbolem wy przejścia \a t jest symbol domyślny.
bool defo(long t) const;
/// Indeks przej<EFBFBD>cia przez \a in.
/// Indeks przejścia przez \a in.
long tra(long t, Ipass in) const;
/// Indeks przej<EFBFBD>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<EFBFBD>w. Stan (indeks stanu) = indeks jego pierwszego przej<EFBFBD>cia
Poziom stanów. Stan (indeks stanu) = indeks jego pierwszego przejścia
*/
//@{
/// Zwraca \c true je<EFBFBD>li stan \a s jest pusty (nie ma z niego przej<65><6A>).
/// 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<EFBFBD>li stan \a s jest stanem ko<6B>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<EFBFBD><EFBFBD>
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<EFBFBD>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<EFBFBD>cia
stan = indeks pierwszego przejścia
state(t) = stan, do kt<EFBFBD>rego nale<EFBFBD>y t
state(t) = stan, do którego należy t
symbol zerowy = symbol s, dla kt<EFBFBD>rego (bool)s zwraca \c false,
w przypadku znak<EFBFBD>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<I,Ipass,O,Opass,TT>::defo(long t) const
{ return tt[t].defo(); }
/**
\param +t - indeks przej<EFBFBD>cia
\param +t - indeks przejścia
\param +in - symbol we
\return Indeks przj<EFBFBD>cia (>=\a t) dla bie<EFBFBD><EFBFBD>cego stanu, kt<EFBFBD>re
akceptuje symbol we \a in lub -1, je<EFBFBD>li nie ma takiego przej<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::tra(long t, Ipass in) const
@ -310,13 +311,13 @@ long TFT<I,Ipass,O,Opass,TT>::tra(long t, Ipass in) const
}
//---------------------------------------------------------------------------
/// Indeks przej<EFBFBD>cia - wersja dla automatu niedeterministycznego.
/// Indeks przejścia - wersja dla automatu niedeterministycznego.
/**
\param +t - indeks przej<EFBFBD>cia
\param +t - indeks przejścia
\param +in - symbol we
\return Indeks przj<EFBFBD>cia (>=\a t) dla bie<EFBFBD><EFBFBD>cego stanu, kt<EFBFBD>re
akceptuje symbol we \a in lub -1, je<EFBFBD>li nie ma takiego przej<EFBFBD>cia
Je<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::tra_nd(long t, Ipass in, long nth) const
@ -347,12 +348,12 @@ long TFT<I,Ipass,O,Opass,TT>::tra_nd(long t, Ipass in, long nth) const
//----------------------------------------------------------------------------
/// Funkcja przej<EFBFBD>cia.
/// Funkcja przejścia.
/**
\param t - stan
\param in - symbol we
\return Stan, do kt<EFBFBD>rego mo<EFBFBD>na przej<EFBFBD><EFBFBD> z \a t po wp<EFBFBD>ywem symbolu \a in
lub -1, je<EFBFBD>li nie ma przej<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
@ -375,13 +376,13 @@ long TFT<I,Ipass,O,Opass,TT>::next(long t, Ipass in) const
//---------------------------------------------------------------------------
//----------------------------------------------------------------------------
/// Uog<EFBFBD>lniona funkcja przejscia.
/// Uogólniona funkcja przejscia.
/**
\param +s - stan
\param +w - wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli we, zako<EFBFBD>czonego symbolem zerowym
\param maxpath maksymalna d<EFBFBD>ugo<EFBFBD><EFBFBD> <EFBFBD>cie<EFBFBD>ki, domy<EFBFBD>lnie ftMAXPATH
\return stan osi<EFBFBD>galny z \a s pod wp<EFBFBD>ywem \a w (na <EFBFBD>cie<EFBFBD>ce mog<EFBFBD> si<EFBFBD> pojawi<EFBFBD>
epsilon-przej<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::gtra(long s, const I* w, long maxpath) const
@ -410,12 +411,12 @@ long TFT<I,Ipass,O,Opass,TT>::gtra(long s, const I* w, long maxpath) const
/// Kontynuacja.
/**
...
\param +s stan, je<EFBFBD>li -1 - poszukiwane jest nast<EFBFBD>pne rozwi<EFBFBD>zanie
\param -c ci<EFBFBD>g symboli we ze <EFBFBD>cie<EFBFBD>ki prowadz<EFBFBD>cej z \a s do
stanu ko<EFBFBD>cowego
\return d<EFBFBD>ugo<EFBFBD><EFBFBD> ci<EFBFBD>gu \a c (= d<EFBFBD>ugo<EFBFBD><EFBFBD> <EFBFBD>cie<EFBFBD>ki)
\remark DZIA<EFBFBD>A TYLKO DLA ZNAK<EFBFBD>W!!!
EPSILON-PRZEJ<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::cont(long s, I* c) const
@ -481,10 +482,10 @@ long TFT<I,Ipass,O,Opass,TT>::match(const I* w, long* p) const
//----------------------------------------------------------------------------
/// Dopasowanie niedeterministyczne.
/**
\param +w - wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli we, zako<EFBFBD>czonego symbolem zerowym,
je<EFBFBD>li NULL - poszukiwane jest nast<EFBFBD>pne rozwi<EFBFBD>zanie
\param -p ci<EFBFBD>g przej<EFBFBD><EFBFBD> zako<EFBFBD>czony -1
\return d<EFBFBD>ugo<EFBFBD><EFBFBD> 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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::match_nd(const I* w, long* p) const
@ -525,13 +526,13 @@ long TFT<I,Ipass,O,Opass,TT>::match_nd(const I* w, long* p) const
}
//----------------------------------------------------------------------------
/// Najd<EFBFBD>u<EFBFBD>sze dopasowanie.
/// Najdłuższe dopasowanie.
/**
\param +w wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli wej<EFBFBD>ciowych
\param -p <EFBFBD>cie<EFBFBD>ka
\param -plen d<EFBFBD>ugo<EFBFBD><EFBFBD> <EFBFBD>cie<EFBFBD>ki
\param +maxpath maks dd<EFBFBD>ugo<EFBFBD><EFBFBD> <EFBFBD>cie<EFBFBD>ki, domy<EFBFBD>lnie FT::ftMAXPATH
\return d<EFBFBD>ugo<EFBFBD><EFBFBD> skonsumowanego wej<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -555,13 +556,13 @@ long TFT<I,Ipass,O,Opass,TT>
}
//----------------------------------------------------------------------------
/// Najd<EFBFBD>u<EFBFBD>sza <20>cie<69>ka.
/// Najdłuższa ścieżka.
/**
\param +buf wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli wej<EFBFBD>ciowych
\param +buf wskaźnik pierwszego elementu ciągu symboli wejściowych
\param -buf pozycja jeden za skonsumowanym prefiksem
\param +path wska<EFBFBD>nik pierwszego elementu wektora przej<EFBFBD><EFBFBD>
\param -path wska<EFBFBD>nik jeden za ostatnim przej<EFBFBD>ciem
\return d<EFBFBD>ugo<EFBFBD><EFBFBD> skonsumowanego prefiksu (PO CO? LEPIEJ D<EFBFBD> <EFBFBD>CIE<EFBFBD>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 <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -581,14 +582,14 @@ long TFT<I,Ipass,O,Opass,TT>
}
//----------------------------------------------------------------------------
/// Najd<EFBFBD>u<EFBFBD>szy prefiks.
/// Najdłuższy prefiks.
/**
\param +buf wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli wej<EFBFBD>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<EFBFBD>ciu przez \a sep
\remark Dzia<EFBFBD>a tylko dla automat<EFBFBD>w deterministycznych, minimalnych, eps-wolnych,
gdzie d<EFBFBD>. <EFBFBD>cie<EFBFBD>ki == d<EFBFBD>. dopasowania.
\return stan po przejściu przez \a sep
\remark Działa tylko dla automatów deterministycznych, minimalnych, eps-wolnych,
gdzie dł. ścieżki == . dopasowania.
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -600,14 +601,14 @@ long TFT<I,Ipass,O,Opass,TT>
static bool more;
long s;
if(*buf) // pierwsze wywo<EFBFBD>anie
if(*buf) // pierwsze wywołanie
{
if(!lgstpath(buf,path,start))
return -1;
--path;
more=true;
}
else // kolejne wywo<EFBFBD>anie
else // kolejne wywołanie
--buf,--path;
while(more)
if(path>=pathtab)

View File

@ -2,16 +2,17 @@
#define TFTiH
//---------------------------------------------------------------------------
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <iostream>
//#include <typeinfo.h>
#include "tft.h"
//---------------------------------------------------------------------------
using namespace std;
using namespace std;
template<class I, class Ipass, class O, class Opass>
class TFTi : public TFT<I,Ipass,O,Opass,TTrans_i<I,Ipass,O,Opass> >
{

View File

@ -2,9 +2,11 @@
#define _TTransi_h
//---------------------------------------------------------------------------
#include <iostream>
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.

View File

@ -1,11 +1,11 @@
//---------------------------------------------------------------------------
#include "word.h"
#include "auttools.h"
//#include <istream.h>
#include <istream>
#include <algorithm>
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(cnt<MAX-1) {
/* tab.push_back(new Word());
tab[cnt]->form(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;

View File

@ -5,17 +5,17 @@
//#include "alphabet.h"
//#include "erro.h"
#include "const.h"
//#include <iostream.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <cstring>
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

View File

@ -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

View File

@ -1,5 +1,4 @@
package "tok"
version "0.1"
option "dictionary" d "Dictionary" string typestr="FILENAME" default="cor.bin" no

View File

@ -1,9 +1,7 @@
#include <cstdlib>
#include <cstring>
#include <stdlib.h>
#include <string.h>
#include "common_tok.h"
using namespace std;
char dictionary[255];
void process_tok_options(gengetopt_args_info args)

View File

@ -1,6 +1,6 @@
tok:
copy:
copy:
ifdef UTT_BIN_DIR
cp tok ${UTT_BIN_DIR}
endif

0
_old/nawszelkiwypadek/tools/aut2fsa Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/cor_dic/prep.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/fsm2aut Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/canon.pl Normal file → Executable file
View File

View File

0
_old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/prep.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/rmDup.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/stat.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl Normal file → Executable file
View File

0
_old/nawszelkiwypadek/tools/lem_dic/prep.pl Normal file → Executable file
View File

0
auto/defaults Normal file → Executable file
View File

0
auto/options Normal file → Executable file
View File

0
auto/output/Makefile Normal file → Executable file
View File

0
auto/output/config_h Normal file → Executable file
View File

0
auto/summary Normal file → Executable file
View File

0
configure vendored Normal file → Executable file
View File