Replacing old implementation with working implementation

This commit is contained in:
Adam Kędziora 2010-10-26 10:57:54 +02:00
parent f712e16638
commit 1e121f45e2
69 changed files with 411 additions and 924 deletions

View File

@ -53,9 +53,7 @@ dirs:
mkdir -p ${UTT_SHARE_DIR}/man/man3
.PHONY: components
components:
cd $(SRC_DIR)/lib && make; cd $(CUR_DIR)
components:
@for cmp in $(COMPONENTS); do\
cd $(SRC_DIR)/$$cmp && make && make copy; cd $(CUR_DIR); \
done
@ -81,7 +79,7 @@ clean_doc:
.PHONY: clean_dist
clean_dist:
rm -rf ${UTT_DIR}
# ------------------------------------------------------------------
# sekcja przygotowania paczki (programow wraz z dodatkowymi plikami)
@ -144,7 +142,6 @@ 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

8
_old/app/conf/Makefile Normal file
View File

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

View File

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

14
_old/app/conf/cor.conf Normal file
View File

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

15
_old/app/conf/dgc.conf Normal file
View File

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

18
_old/app/conf/dgp.conf Normal file
View File

@ -0,0 +1,18 @@
# ************************************************************
# * 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

16
_old/app/conf/gph.conf Normal file
View File

@ -0,0 +1,16 @@
# ************************************************************
# * 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

15
_old/app/conf/grp.conf Normal file
View File

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

14
_old/app/conf/gue.conf Normal file
View File

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

16
_old/app/conf/kor.conf Normal file
View File

@ -0,0 +1,16 @@
# ************************************************************
# * 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

14
_old/app/conf/lem.conf Normal file
View File

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

15
_old/app/conf/mar.conf Normal file
View File

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

15
_old/app/conf/ser.conf Normal file
View File

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

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

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

View File

@ -1,8 +1,7 @@
# main: cmdline.c main_template.cc
# g++ -o main cmdline.c common.cc main_template.cc
COMMON_PATH=../common
# cmdline.c cmdline.h : cmdline.ggo
# gengetopt -i cmdline.ggo
include ./common.mk
# cmdline.ggo: cmdline_common.ggo cmdline_program.ggo
# cat cmdline_common.ggo cmdline_program.ggo > cmdline.ggo
clean:
rm -f cmdline.c cmdline.h cmdline.ggo

View File

@ -1,16 +1,13 @@
CFLAG1 = -m32 -Wno-deprecated -O3 -fpermissive
CFLAG1 = -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 <stdlib.h>
#include <cstdlib>
#include "../lib/tfti.h"

View File

@ -1,12 +1,11 @@
PAR=-Wno-deprecated -m32 -fpermissive -static
PAR2=-c -Wno-deprecated -m32 -fpermissive
PAR=-Wno-deprecated -fpermissive -static
PAR2=-c -Wno-deprecated -fpermissive
LIB_PATH=../lib
COMMON_PATH=../common
CMDLINE_FILE='"../cor/cmdline.h"'
cor: main.cc corr.o $(LIB_PATH)/word.o \
$(LIB_PATH)/auttools.o cmdline.c common_cor.o common.o
cor: main.cc corr.o word.o 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
@ -14,8 +13,7 @@ cor: main.cc corr.o $(LIB_PATH)/word.o \
corr.o: corr.cc corr.hh
g++ $(PAR2) corr.cc
common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \
$(COMMON_PATH)/common.h
common.o: cmdline_common
g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
common_cor.o: cmdline.h common_cor.cc common_cor.h
@ -39,3 +37,5 @@ clean: clean.cmdline
clean.cmdline:
rm cmdline.* || true
include $(COMMON_PATH)/common.mk
include $(LIB_PATH)/lib.mk

View File

@ -1,5 +1,3 @@
SHELL = /bin/sh
LIB_PATH=../../lib
COMMON_PATH=../common
@ -8,12 +6,12 @@ CMDLINE_FILE='"../dgp/cmdline.h"'
#vpath %.o .
CXXFLAGS = -O2 -static
CXXFLAGS = -O2 -static -fpermissive
sources = main.cc grammar.cc symbol.cc mgraph.cc sgraph.cc dgp0.cc cmdline.cc \
$(COMMON_PATH)/common.cc global.cc
bin = dgp
bin = dgp dgc canonize tre
# plik *.o sa umieszczane w podkatalogu o
objs = $(sources:%.cc=%.o)
@ -44,8 +42,7 @@ cmdline.ggo: cmdline_dgp.ggo ../common/cmdline_common.ggo
clean:
rm ${bin} ${objs} cmdline.cc cmdline.h
rm -rf *.d
rm ${bin} ${objs} cmdline.cc cmdline.h *.d
prof: dgp
gprof dgp ~/tmp/dgp-pl/gmon.out > dgp.prof

View File

@ -1,50 +0,0 @@
#!/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 );
}

View File

@ -1,292 +0,0 @@
#!/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,8 +11,6 @@
#include "sgraph.hh"
using namespace std;
class Link
{
Role role;

View File

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

View File

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

View File

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

View File

@ -1,304 +0,0 @@
#!/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,12 +1,11 @@
PAR=-Wno-deprecated -O3 -fpermissive -m32 -static
PAR2=-c -Wno-deprecated -O3 -fpermissive -m32
PAR=-Wno-deprecated -O2 -fpermissive -static
PAR2=-c -Wno-deprecated -O2 -fpermissive
LIB_PATH=../lib
COMMON_PATH=../common
CMDLINE_FILE='"../gue/cmdline.h"'
gue: main.cc guess.o $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o \
cmdline.c common_guess.o common.o
gue: main.cc guess.o auttools.o 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
@ -17,8 +16,7 @@ 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 $(COMMON_PATH)/common.cc \
$(COMMON_PATH)/common.h
common.o: $(COMMON_PATH)/cmdline_common.ggo cmdline_common
g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
cmdline.c cmdline.h: cmdline.ggo
@ -40,3 +38,6 @@ 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 <string.h>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <cstdlib>
#include <cassert>
#include <ctime>
#define DICT 1
#define COR 2
@ -17,10 +17,8 @@
#define PREF_SIGN '_'
using namespace std;
Guess::Guess(const char* suf_file)
: _suf(suf_file) {
/* _suf = NULL;

View File

@ -1,26 +1,22 @@
PAR=-Wno-deprecated -m32 -fpermissive -static
PAR2=-c -Wno-deprecated -m32 -fpermissive
PAR=-Wno-deprecated -fpermissive -static
PAR2=-c -Wno-deprecated -fpermissive
LIB_PATH=../lib
COMMON_PATH=../common
CMDLINE_FILE='"../kor/cmdline.h"'
kor: main.cc corr.o corlist.o cmdline.o $(LIB_PATH)/word.o \
$(LIB_PATH)/auttools.o cmdline.c common_cor.o common.o
kor: main.cc corr.o corlist.o cmdline.o word.o 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.hh cmdline.h
corr.o: corr.cc corr.h 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 $(COMMON_PATH)/common.cc \
$(COMMON_PATH)/common.h
common.o: cmdline.h $(COMMON_PATH)/cmdline_common.ggo cmdline_common
g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
common_cor.o: cmdline.h common_cor.cc common_cor.h
@ -44,3 +40,5 @@ clean: clean.cmdline
clean.cmdline:
rm cmdline.* || true
include $(COMMON_PATH)/common.mk
include $(LIB_PATH)/lib.mk

View File

@ -1,9 +1,10 @@
#include <stdio.h>
#include <malloc.h>
#include <cstdio>
//#include <alloc.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.hh"
#include "corr.h"
#define MAXPATH 256

View File

@ -1,39 +0,0 @@
//---------------------------------------------------------------------------
#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.hh"
#include "corr.h"
#include <locale.h>

View File

@ -1,12 +1,11 @@
PAR=-Wno-deprecated -m32 -O3 -fpermissive -static
PAR2=-c -Wno-deprecated -m32 -O3 -fpermissive -static
PAR=-Wno-deprecated -O2 -fpermissive -static
PAR2=-c -Wno-deprecated -O2 -fpermissive -static
LIB_PATH=../lib
COMMON_PATH=../common
CMDLINE_FILE='"../lem/cmdline.h"'
lem: main.cc lem.o $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o \
cmdline.c common_lem.o common.o symtab.o
lem: main.cc lem.o auttools.o 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 \
@ -27,8 +26,7 @@ lem.o: lem.h lem.cc
# erro.o: $(LIB_PATH)/erro.h $(LIB_PATH)/erro.cc
# g++ $(PAR2) $(LIB_PATH)/erro.cc
common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \
$(COMMON_PATH)/common.h
common.o: cmdline_common
g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
common_lem.o: cmdline.h common_lem.h common_lem.cc
@ -37,7 +35,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/cmdline_common.ggo
cmdline.ggo: cmdline_lem.ggo $(COMMON_PATH)/cmdline_common.ggo
cat cmdline_lem.ggo ../common/cmdline_common.ggo > cmdline.ggo
symtab.o: $(LIB_PATH)/symtab.h $(LIB_PATH)/symtab.cc
@ -54,3 +52,6 @@ copy:
ifdef UTT_BIN_DIR
cp lem $(UTT_BIN_DIR)
endif
include $(COMMON_PATH)/common.mk
include $(LIB_PATH)/lib.mk

View File

@ -1,9 +1,12 @@
#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,17 +1,11 @@
PAR=-Wno-deprecated -m32 -O3
PAR2=-c -Wno-deprecated -m32 -O3 -fpermissive
PAR=-Wno-deprecated -O3
PAR2=-c -Wno-deprecated -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
@ -19,3 +13,5 @@ copy:
#ifdef UTT_LIB_DIR
# cp -r perl $(UTT_LIB_DIR)/
#endif
include ./lib.mk

View File

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

View File

@ -1,8 +1,9 @@
#include "symtab.h"
#include <values.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <cstdio>
//#include <alloc.h>
#include <cstdlib>
using namespace std;
//---------------------------------------------------------------------------
SymbolTable::SymbolTable(int n, int (*h)(const char*,int), const char* filename)
@ -157,7 +158,8 @@ 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 abs((i1+i2+i3) % _sz);
return (i1+i2+i3) % _sz;
}
else
{

View File

@ -4,20 +4,19 @@
#include <stddef.h>
#include <iostream>
#include <typeinfo>
#include <string.h>
#include <cstring>
#include <stdio.h>
#include <cstdio>
//#include "top.h"
#include "ttrans.h"
using namespace std;
using namespace std;
//---------------------------------------------------------------------------
/// Klasa bazowa przetwornika skończonego.
/// Klasa bazowa przetwornika sko<EFBFBD>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<EFBFBD><EFBFBD>, przenie<EFBFBD><EFBFBD> do TTrans,
reszt<EFBFBD> wcieli<EFBFBD> do TFT.
*/
class FT
{
@ -25,46 +24,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<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
};
/// maks długość ścieżki
/// maks d<EFBFBD>ugo<EFBFBD><EFBFBD> <20>cie<69>ki
static const unsigned int ftMAXPATH=500;
/// maks długość opisu typu symbolu we/wy
/// maks d<EFBFBD>ugo<EFBFBD><EFBFBD> opisu typu symbolu we/wy
/**
\remark Przenieść do TTrans
\remark Przenie<EFBFBD><EFBFBD> do TTrans
*/
static const unsigned int ftTYPELEN=32;
/// specjalny symbol dla wartości 'epsilon'
/// specjalny symbol dla warto<EFBFBD>ci 'epsilon'
/**
\remark Przenieść do TTrans
\remark Przenie<EFBFBD><EFBFBD> do TTrans
*/
static const char ftEPSILON='~';
/// specialny symbol dla wartości 'default'
/// specialny symbol dla warto<EFBFBD>ci 'default'
/**
\remark Przenieść do TTrans
\remark Przenie<EFBFBD><EFBFBD> do TTrans
*/
static const char ftDEFAULT='@';
/// domyślny symbol wyjściowy (true-'@', flase-'~')
/// domy<EFBFBD>lny symbol wyj<79>ciowy (true-'@', flase-'~')
/**
\remark Przenieść do TTrans(???)
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
*/
bool copy_default;
/// tryb wyjścia
/// tryb wyj<EFBFBD>cia
OUTPUT print_mode;
/// false, jeśli automat nie ma przejść
/// false, je<EFBFBD>li automat nie ma przej<65><6A>
operator bool() { return (bool)ttn; };
virtual const char* intype() { return itype; };
@ -72,39 +71,39 @@ public:
protected:
/// liczba elementów tablicy tt
/// liczba element<EFBFBD>w tablicy tt
unsigned long ttn;
/// liczba stanów
/// liczba stan<EFBFBD>w
unsigned long states;
/// liczba przejść
/// liczba przej<EFBFBD><EFBFBD>
unsigned long transitions;
/// typ symboli wejściowych (napis)
/// typ symboli wej<EFBFBD>ciowych (napis)
/**
\remark Przenieść do TTrans(???)
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
*/
char itype[ftTYPELEN];
/// typ symboli wyjściowych (napis)
/// typ symboli wyj<EFBFBD>ciowych (napis)
/**
\remark Przenieść do TTrans(???)
\remark Przenie<EFBFBD><EFBFBD> do TTrans(???)
*/
char otype[ftTYPELEN];
};
//---------------------------------------------------------------------------
/// Szablon przetwornika skończonego
/// Szablon przetwornika sko<EFBFBD>czonego
/**
\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
\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
*/
template<class I, class Ipass, class O, class Opass, class TT>
class TFT : public FT
@ -117,58 +116,58 @@ public:
/**
\name Metody poziomu 1
Poziom przejść.
Poziom przej<EFBFBD><EFBFBD>.
*/
//@{
/// Test, czy przejście \a t akceptuje symbol \a in.
/// Test, czy przej<EFBFBD>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<EFBFBD><EFBFBD> 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<EFBFBD>rego prowadzi przej<65>cie \a t.
/**
\pre !empty(t)
*/
long next(long t) const;
/// Symbol wejściowy przejścia \a t.
/// Symbol wej<EFBFBD>ciowy przej<65>cia \a t.
Ipass input(long t) const;
/// Symbol wyjściowy przejścia \a t.
/// Symbol wyj<EFBFBD>ciowy przej<65>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<EFBFBD>li symbolem we przej<65>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<EFBFBD>li symbolem we przej<65>cia \a t jest symbol domy<6D>lny.
bool defi(long t) const;
/// Zwraca \c true, jeśli symbolem wy przejścia \a t jest epsilon.
/// Zwraca \c true, je<EFBFBD>li symbolem wy przej<65>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<EFBFBD>li symbolem wy przej<65>cia \a t jest symbol domy<6D>lny.
bool defo(long t) const;
/// Indeks przejścia przez \a in.
/// Indeks przej<EFBFBD>cia przez \a in.
long tra(long t, Ipass in) const;
/// Indeks przejścia przez \a in - non-deterministic.
/// Indeks przej<EFBFBD>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<EFBFBD>w. Stan (indeks stanu) = indeks jego pierwszego przej<EFBFBD>cia
*/
//@{
/// Zwraca \c true jeśli stan \a s jest pusty (nie ma z niego przejść).
/// Zwraca \c true je<EFBFBD>li stan \a s jest pusty (nie ma z niego przej<65><6A>).
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<EFBFBD>li stan \a s jest stanem ko<6B>cowym.
bool final(long s) const { return tt[s].final(); }
long next(long t, Ipass in) const;
@ -202,7 +201,7 @@ Poziom ...
protected:
TT* tt; // tablica przejść
TT* tt; // tablica przej<EFBFBD><EFBFBD>
long prn(const I* si, long* p, O* so) const;
@ -210,7 +209,7 @@ protected:
void sort();
void setiotypes(); // NIE DZIAŁA (dlaczego???)
void setiotypes(); // NIE DZIA<EFBFBD>A (dlaczego???)
// friend ostream& operator<<(ostream&,const CDFA&);
// friend istream& operator>>(istream&,CDFA&);
@ -228,12 +227,12 @@ private:
//---------------------------------------------------------------------------
/**
stan = indeks pierwszego przejścia
stan = indeks pierwszego przej<EFBFBD>cia
state(t) = stan, do którego należy t
state(t) = stan, do kt<EFBFBD>rego nale<EFBFBD>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<EFBFBD>rego (bool)s zwraca \c false,
w przypadku znak<EFBFBD>w - '\0'
*/
//---------------------------------------------------------------------------
@ -290,10 +289,10 @@ bool TFT<I,Ipass,O,Opass,TT>::defo(long t) const
{ return tt[t].defo(); }
/**
\param +t - indeks przejścia
\param +t - indeks przej<EFBFBD>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<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
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::tra(long t, Ipass in) const
@ -311,13 +310,13 @@ long TFT<I,Ipass,O,Opass,TT>::tra(long t, Ipass in) const
}
//---------------------------------------------------------------------------
/// Indeks przejścia - wersja dla automatu niedeterministycznego.
/// Indeks przej<EFBFBD>cia - wersja dla automatu niedeterministycznego.
/**
\param +t - indeks przejścia
\param +t - indeks przej<EFBFBD>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<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.
*/
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
@ -348,12 +347,12 @@ long TFT<I,Ipass,O,Opass,TT>::tra_nd(long t, Ipass in, long nth) const
//----------------------------------------------------------------------------
/// Funkcja przejścia.
/// Funkcja przej<EFBFBD>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<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
*/
template <class I, class Ipass, class O, class Opass, class TT>
@ -376,13 +375,13 @@ long TFT<I,Ipass,O,Opass,TT>::next(long t, Ipass in) const
//---------------------------------------------------------------------------
//----------------------------------------------------------------------------
/// Uogólniona funkcja przejscia.
/// Uog<EFBFBD>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<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
*/
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
@ -411,12 +410,12 @@ long TFT<I,Ipass,O,Opass,TT>::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<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!!!
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>::cont(long s, I* c) const
@ -482,10 +481,10 @@ long TFT<I,Ipass,O,Opass,TT>::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<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?)
*/
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
@ -526,13 +525,13 @@ long TFT<I,Ipass,O,Opass,TT>::match_nd(const I* w, long* p) const
}
//----------------------------------------------------------------------------
/// Najdłuższe dopasowanie.
/// Najd<EFBFBD>u<EFBFBD>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<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
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -556,13 +555,13 @@ long TFT<I,Ipass,O,Opass,TT>
}
//----------------------------------------------------------------------------
/// Najdłuższa ścieżka.
/// Najd<EFBFBD>u<EFBFBD>sza <20>cie<69>ka.
/**
\param +buf wskaźnik pierwszego elementu ciągu symboli wejściowych
\param +buf wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli wej<EFBFBD>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<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)
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -582,14 +581,14 @@ long TFT<I,Ipass,O,Opass,TT>
}
//----------------------------------------------------------------------------
/// Najdłuższy prefiks.
/// Najd<EFBFBD>u<EFBFBD>szy prefiks.
/**
\param +buf wskaźnik pierwszego elementu ciągu symboli wejściowych
\param +buf wska<EFBFBD>nik pierwszego elementu ci<EFBFBD>gu symboli wej<EFBFBD>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 == . dopasowania.
\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.
*/
template <class I, class Ipass, class O, class Opass, class TT>
long TFT<I,Ipass,O,Opass,TT>
@ -601,14 +600,14 @@ long TFT<I,Ipass,O,Opass,TT>
static bool more;
long s;
if(*buf) // pierwsze wywołanie
if(*buf) // pierwsze wywo<EFBFBD>anie
{
if(!lgstpath(buf,path,start))
return -1;
--path;
more=true;
}
else // kolejne wywołanie
else // kolejne wywo<EFBFBD>anie
--buf,--path;
while(more)
if(path>=pathtab)

View File

@ -2,17 +2,16 @@
#define TFTiH
//---------------------------------------------------------------------------
#include <fstream>
#include <math.h>
#include <cmath>
#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,11 +2,9 @@
#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() {
// sort(tab.begin(), tab.end(), Word::cmp_w); //NIE DZIALA
void Words::sort() {
std::sort(tab.begin(), tab.end(), Word::cmp_w);
}
//---------------------------------------------------------------------------
void Words::sort_rev() {
// sort(tab.begin(), tab.end(), cmp_w_rev_fun); // NIE DZIALA
void Words::sort_rev() {
std::sort(tab.begin(), tab.end(), cmp_w_rev_fun);
}
//---------------------------------------------------------------------------
@ -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,7 +163,8 @@ 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);
@ -174,13 +175,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,6 +1,7 @@
PAR=-Wno-deprecated -O3
PAR=-Wno-deprecated -O3 -fpermissive
PAR2=-c -Wno-deprecated -O3
LIB_PATH=../lib
COMMON_PATH=../common
CMDLINE_FILE='"../tok.c/cmdline.h"'
@ -14,12 +15,11 @@ 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: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \
$(COMMON_PATH)/common.h
common.o: cmdline_common
g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
cmdline.ggo: cmdline_tok.ggo ../common/cmdline_common.ggo
cat cmdline_tok.ggo ../common/cmdline_common.ggo > cmdline.ggo
cmdline.ggo: cmdline_tok.ggo $(COMMON_PATH)/cmdline_common.ggo
cat cmdline_tok.ggo $(COMMON_PATH)/cmdline_common.ggo > cmdline.ggo
cmdline.c cmdline.h: cmdline.ggo
gengetopt -i cmdline.ggo --conf-parser
@ -31,7 +31,11 @@ endif
clean: clean.cmdline
rm *.o
rm *.o || true
rm tok || true
clean.cmdline:
rm cmdline.*
include $(COMMON_PATH)/common.mk
include $(LIB_PATH)/lib.mk

View File

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

View File

@ -1,7 +1,9 @@
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#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 Executable file → Normal file
View File

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

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

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

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

View File

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

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

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

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

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

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

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

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

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

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

0
auto/defaults Executable file → Normal file
View File

0
auto/options Executable file → Normal file
View File

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

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

0
auto/summary Executable file → Normal file
View File

0
configure vendored Executable file → Normal file
View File