update pack

This commit is contained in:
Tomasz Obrębski 2016-11-11 17:08:18 +01:00
parent c03f8a55bd
commit 4a25a92db7
38 changed files with 2342 additions and 490 deletions

2
configure vendored
View File

@ -8,7 +8,7 @@ CUR_DIR=$(pwd)
SRC_DIR="${CUR_DIR}/src"
# list of components to compile
CMPLIST="compdic cor dgc dgp fla gph grp gue kon kor kot lem mar rm12 rs12 sen sen-nl ser tags tok.c tok.l tok.pl tre unfla"
CMPLIST="compdic cor dgc dgp fla gph grp gue kon kor kot lem mar rat rm12 rs12 sen sen-nl ser tags tok.c tok.l tok.pl tre unfla"
COMP=

View File

@ -29,7 +29,7 @@ Documentation License,,GNU Free Documentation License.
@titlepage
@title UAM Text Tools 0.90 - User Manual
@subtitle edition 0.01, @today
@subtitle edition 0.01, @today{}
@subtitle status: prescript
@author by Justyna Walkowska, Tomasz Obrębski and Michał Stolarski
@page

View File

@ -4,7 +4,7 @@ include ../config.mak
TARGETS = gram.dgp
.PHONY: all
all: $(TARGETS)
all:
# ------------------------------------------------------------------
# main section
@ -15,7 +15,7 @@ gram.dgp: gram.dgc
.PHONY: install
install: install-grammar install-dictionaries
install:
.PHONY: install-grammar
install-grammar:

View File

@ -1,362 +1,223 @@
# TODO!
#====================================================================================================
#====================================================================================================
# FLAGI
#====================================================================================================
#====================================================================================================
#==================================================================================================== FLAGI
FLAG RQ
FLAG NEG
FLAG init
#====================================================================================================
#====================================================================================================
# KLASY DYSTRYBUCYJNE BIERNE
#====================================================================================================
#====================================================================================================
#==================================================================================================== KLASY DYSTRYBUCYJNE BIERNE
class $V- = V|VM|AUX|BYC
class $N- = N|NV|NPRO|NUMCRD
class $ADJ- = ADJ|ADJPRP|ADJPAP|ADJPP|ADJPRO
class $ADV- = ADV|ADVPRP|ADVANP
#====================================================================================================
#====================================================================================================
# KLASY DYSTRYBUCYJNE CZYNNE
#====================================================================================================
#====================================================================================================
class $ADV- = ADV|ADVPRP|ADVANP|ADVPRO|P
#==================================================================================================== KLASY DYSTRYBUCYJNE CZYNNE
class $V+ = V|ADVPRP|ADVANP|ADJPRP|ADJPAP|NV
class $FIN+ = (V|BYC)/Vp|V/Vi
####################################################################################################
# NEG
####################################################################################################
#==================================================================================================== NEGACJA
#==================================================================================================== neg
ROLE neg
SGL neg
LEFT neg
LINK V|VM|AUX|BYC|ADJPRP|ADJPAP|ADJPP NEG neg
#==================================================================================================== PYTANIE CZY
#==================================================================================================== czy
ROLE czy
SGL czy
RIGHT czy
LINK CZY $FIN+/Mdc|V/Vb czy
####################################################################################################
# subj
####################################################################################################
#==================================================================================================== PODMIOT
#==================================================================================================== subj
ROLE subj
SGL subj
AGR subj N
AGR subj G
GOV subj */Cn
LINK (V/Kn|BYC|ZOSTAC)/VpP3 (N|NUMCRD) subj
LINK (V/Kn|BYC|ZOSTAC)/VpP12 NPRO//RQ- subj
LINK (V/Kn|BYC|ZOSTAC)/VpP3 NPRO//RQ- subj
LINK (V/Kn|BYC|ZOSTAC)/VpP3 NPRO//RQ+ subj&INIT
LINK (V/Kn|BYC)/VpP3 (N|NUMCRD) subj
LINK (V/Kn|BYC)/VpP12 NPRO//RQ- subj
LINK (V/Kn|BYC)/VpP3 NPRO//RQ- subj
LINK (V/Kn|BYC)/VpP3 NPRO//RQ+ subj&INIT
#====================================================================================================
# cmpl_g
#====================================================================================================
ROLE cmpl_g
SGL cmpl_g
GOV cmpl_g */Cg
LINK $V+ $N-//RQ- cmpl_g
LINK $V+ $N-//RQ+ cmpl_g&INIT
#====================================================================================================
# cmpl_a
#====================================================================================================
ROLE cmpl_a
SGL cmpl_a
GOV cmpl_a */Ca
LINK $V+ $N-//RQ-NEG- cmpl_a
LINK $V+ $N-//RQ+NEG- cmpl_a&INIT
#====================================================================================================
# cmpl_d
#====================================================================================================
ROLE cmpl_d
SGL cmpl_d
GOV cmpl_d */Cd
LINK $V+ $N-//RQ- cmpl_d
#====================================================================================================
# cmpl_i
#====================================================================================================
ROLE cmpl_i
SGL cmpl_i
GOV cmpl_i */Ci
LINK $V+ $N-//RQ- cmpl_i
#====================================================================================================
# cmpl_ze
#====================================================================================================
ROLE cmpl_ze
SGL cmpl_ze
LINK $V+ CONJ/Si cmpl_ze&FIN
#====================================================================================================
# cmpl_inf
#====================================================================================================
ROLE cmpl_inf
SGL cmpl_inf
LINK $V+ V/Vb cmpl_inf
#====================================================================================================
# cmpl_s
#====================================================================================================
ROLE cmpl_s
SGL cmpl_s
LINK $V+ V/Vp//RQ+ cmpl_s
#====================================================================================================
#====================================================================================================
# aux
#====================================================================================================
#====================================================================================================
ROLE aux
SGL aux
AGR aux N
AGR aux G
LINK BYC/VpMdTf (V/VpP3|V/Vb)/Ai aux #czas przyszly analityczny
LINK BYC/VpMc V/VpP3 aux #czas zaprzeszły
LINK BYC (ADJPAP|ADJ)/Cn aux #BYC jako lacznik w (jest bialy, jest zaszlachtowany)
LINK BYC N/Ci aux #BYC jako lacznik w (jest pilotem)
#====================================================================================================
# MOD
#====================================================================================================
#==================================================================================================== DOPE£NIENIA
#==================================================================================================== gen
#ROLE gen
#SGL gen
#GOV gen */Cg
#LINK $V+ $N-//RQ- gen
#LINK $V+ $N-//RQ+ gen&INIT
#==================================================================================================== obj
ROLE obj
SGL obj
LINK $V+//NEG- $N-/Ca//RQ- obj
LINK $V+//NEG+ $N-/Cg//RQ- obj
LINK $V+//NEG- $N-/Ca//RQ+ obj&LEFT&INIT
LINK $V+//NEG+ $N-/Cg//RQ+ obj&LEFT&INIT
#==================================================================================================== dat
ROLE dat
SGL dat
GOV dat */Cd
LINK $V+ $N-//RQ- dat
#==================================================================================================== instr
ROLE instr
SGL instr
GOV instr */Ci
LINK $V+ $N-//RQ- instr
#==================================================================================================== ze
ROLE ze
SGL ze
LINK $V+ CONJ/Si ze&FIN
#==================================================================================================== inf
ROLE inf
SGL inf
LINK $V+ V/Vb inf
#==================================================================================================== int
ROLE int
SGL int
LINK $V+ V/Vp//RQ+ int
#==================================================================================================== CZASY
#==================================================================================================== fut
ROLE pred
SGL pred
AGR pred N
AGR pred G
ROLE fut
SGL fut
LINK BYC/VpMdTf (V/VpP3|V/Vb)/Ai fut #czas przyszly analityczny
#==================================================================================================== pass
ROLE pass
SGL pass
LINK BYC/Vpb ADJPAP/Cn pass #strona bierna
LINK ZOSTAC/Vpb ADJPAP/ApCn pass #strona bierna
#==================================================================================================== past
ROLE past
SGL past
LINK BYC/VpMc V/VpP3 past #czas zaprzesz³y
#==================================================================================================== cop
ROLE qpred
#ONE qpred
AGR qpred N
ROLE pred qpred
AGR pred G
ROLE fut pred
ROLE pass pred
ROLE past pred
ROLE pred
SGL pred
AGR pred N
AGR pred G
LINK BYC ADJ/Cn pred #BYC jako lacznik w (jest bialy, jest zaszlachtowany)
LINK BYC N/Ci pred #BYC jako lacznik w (jest pilotem)
#==================================================================================================== mod
ROLE mod
AGR mod N
AGR mod C
AGR mod G
LINK V|VM|AUX|BYC $ADV- mod
LINK V|VM|AUX|BYC ADVPRO/Zqr mod&LEFT&INIT # kiedy uśnie
LINK N|NV $ADJ- mod
LINK N|NV ADJPRO/Zqr mod&LEFT&INIT
LINK N|NV P mod
LINK N|NV P/Zqr mod&LEFT&INIT
#====================================================================================================
# PREP
#====================================================================================================
ROLE prep
LINK V P prep
LINK N P//RQ- prep
#====================================================================================================
# PCMPL
#====================================================================================================
LINK V|VM|AUX|BYC $ADV-//RQ- mod
LINK V|VM|AUX|BYC $ADV-//RQ+ mod&LEFT&INIT # kiedy u¶nie
LINK N|NV $ADJ-//RQ- mod
LINK N|NV $ADJ-//RQ+ mod&LEFT&INIT
#==================================================================================================== pp
ROLE pp
#LINK V P prep
LINK N|NV P//RQ- pp
LINK N|NV P//RQ+ pp&LEFT&INIT
#==================================================================================================== pcmpl
ROLE pcmpl
RIGHT pcmpl
SGL pcmpl
AGR pcmpl C
LINK P $N- pcmpl
REQ P pcmpl
#====================================================================================================
# conj
#====================================================================================================
#==================================================================================================== conj
ROLE conj
RIGHT conj
LINK $V+ CONJ/Sc conj&FIN
LINK $N- CONJ/Sc conj
LINK $ADJ- CONJ/Sc conj
LINK $ADV- CONJ/Sc conj
#====================================================================================================
# conj1
#====================================================================================================
#==================================================================================================== conj1
ROLE conj1
SGL conj1
LEFT conj1
LINK N CONJ/S1 conj1
#====================================================================================================
# conj2
#====================================================================================================
#==================================================================================================== conj2
ROLE conj2
SGL conj2
RIGHT conj2
LINK N CONJ/S2 conj2
#====================================================================================================
# ccmpl
#====================================================================================================
#==================================================================================================== ¿e
ROLE ze
SGL ze
LINK $V+ CONJ/S<¿e> ze
#==================================================================================================== ccmpl
ROLE ccmpl
SGL ccmpl
RIGHT ccmpl
LINK CONJ/JcSci2 V/Vf ccmpl
LINK CONJ/JcSci2 V/Vpi ccmpl
LINK CONJ/JpSci2 ($N-|$V+|$ADJ-|$ADV-) ccmpl
REQ CONJ/Sci2 ccmpl
#====================================================================================================
# poss
#====================================================================================================
#==================================================================================================== poss
ROLE poss
SGL poss
GOV poss */Cg
LINK N $N- ~ NPRO poss
LINK N NPRO/Zqr poss&LEFT&INIT
#====================================================================================================
# numa
#====================================================================================================
#==================================================================================================== numa
ROLE num_a
SGL num_a
AGR num_a C
AGR num_a G
GOV num_a */Ns
LINK NUMCRD/Sa N|NV num_a
#====================================================================================================
# num
#====================================================================================================
#==================================================================================================== num
ROLE num
SGL num
LINK NUMCRD N|NV num
#====================================================================================================
# restr
#====================================================================================================
#==================================================================================================== restr
ROLE restr
SGL restr
LINK ADJ ADV restr
#====================================================================================================
# quant
#====================================================================================================
#==================================================================================================== quant
ROLE quant
SGL quant
AGR quant N
AGR quant C
AGR quant G
LEFT quant
LINK N ADJPRO/Zg quant
#====================================================================================================
# part
#====================================================================================================
#==================================================================================================== part
ROLE part
LINK $V+ PART part
#====================================================================================================
# part
#====================================================================================================
ROLE czy
LINK $V+ CZY czy
#====================================================================================================
# subj_copred
#====================================================================================================
#==================================================================================================== subj_copred
ROLE subj_copred
SGL subj_copred
#====================================================================================================
# cmpl_g_copred
#====================================================================================================
ROLE cmpl_g_copred
SGL cmpl_g_copred
#====================================================================================================
# cmpl_a_copred
#====================================================================================================
ROLE cmpl_a_copred
SGL cmpl_a_copred
#====================================================================================================
# CMPL_D_COPRED
#====================================================================================================
#==================================================================================================== gen_copred
ROLE gen_copred
SGL gen_copred
#==================================================================================================== acc_copred
ROLE acc_copred
SGL acc_copred
#==================================================================================================== cmpl_d_copred
ROLE cmpl_d_copred
SGL cmpl_d_copred
#====================================================================================================
# CMPL_I_COPRED
#====================================================================================================
#==================================================================================================== cmpl_i_copred
ROLE cmpl_i_copred
SGL cmpl_i_copred
#====================================================================================================
# REL
#====================================================================================================
#==================================================================================================== rel
ROLE rel
RIGHT rel
SGL rel
FIN rel
LINK N V/Vpi//RQ+ rel&FIN
LINK N V/Vp//RQ+ rel&FIN
#====================================================================================================
#====================================================================================================
# CONSTR
#====================================================================================================
#====================================================================================================
CONSTRE cmpl_g cmpl_a
CONSTRE cmpl_a cmpl_g
#CONSTRE gen acc
#CONSTRE acc gen
CONSTRI conj1 conj2
CONSTRI conj2 conj1
#CONSTR cmpl_g ~cmpl_a
#CONSTR cmpl_a ~cmpl_g
#CONSTR cmpl_inf ~cmpl_g ~cmpl_d ~cmpl_a ~cmpl_p ~cmpl_ez ~cmpl_s
@ -366,79 +227,47 @@ CONSTRI conj2 conj1
#CONSTR cmpl_i_copred => cmpl_i
#CONSTR cmpl_d_copred => cmpl_d
#====================================================================================================
#====================================================================================================
# LONG
#====================================================================================================
#====================================================================================================
#====================================================================================================
# ncoord
#====================================================================================================
#==================================================================================================== ncoord
LONG ncoord ^conj,ccmpl
LONG ncoord ^conj2,ccmpl
AGR ncoord C
AGR ncoord N
LINK N N ncoord
#====================================================================================================
# vcoord
#====================================================================================================
#==================================================================================================== vcoord
LONG vcoord ^conj,ccmpl
AGR vcoord P
AGR vcoord N
AGR vcoord A
AGR vcoord G
LINK V V vcoord
#====================================================================================================
# adjcoord
#====================================================================================================
#==================================================================================================== adjcoord
LONG adjcoord ^conj,ccmpl
AGR adjcoord C
AGR adjcoord N
AGR adjcoord G
LINK ADJ ADJ ncoord
#====================================================================================================
# advcoord
#====================================================================================================
#==================================================================================================== advcoord
LONG advcoord ^conj,ccmpl
AGR ncoord C
AGR ncoord N
LINK ADV ADV ncoord
#====================================================================================================
# relagr
#====================================================================================================
#==================================================================================================== predagr
LONG predagr subj^pred
AGR predagr N
AGR predagr G
LINK N * predagr
#==================================================================================================== relagr
LONG relagr subj,rel^
LONG relagr poss,cmpl_a,rel^
LONG relagr cmpl_a,rel^
LONG relagr cmpl_g,rel^
LONG relagr pcmpl,rel^
LONG relagr poss,acc,rel^
LONG relagr obj,rel^
LONG relagr dat,rel^
LONG relagr instr,rel^
LONG relagr pcmpl,mod,rel^
AGR relagr N
AGR relagr G
LINK NPRO/Zqr N relagr
#====================================================================================================
#====================================================================================================
# FLAG
@ -452,17 +281,17 @@ LINK NPRO/Zqr N relagr
SET NPRO/Zrq RQ
SET ADJPRO/Zrq RQ
SET ADVPRO/Zqr RQ
SET NEG NEG
SET CZY RQ
PASS subj RQ
PASS cmpl_g RQ
PASS cmpl_d RQ
PASS cmpl_a RQ
PASS cmpl_i RQ
PASS dat RQ
PASS obj RQ
PASS instr RQ
PASS mod RQ
PASS pcmpl RQ
PASS prep RQ
PASS pp RQ
PASS poss RQ
SET NEG NEG
PASS neg NEG

View File

@ -140,6 +140,8 @@ _ 85
* 93
+ 94
Ö 95
< 96
> 97
EOF

View File

@ -145,6 +145,8 @@ _ 85
* 93
+ 94
Ö 95
< 96
> 97
EOF

View File

@ -111,6 +111,8 @@ _ 85
* 93
+ 94
Ö 95
< 96
> 97
EOF
cat $1 | fstrmepsilon | fstdeterminize | fstminimize | fstprint --acceptor --isymbols=$alphabet | fsm2aut | aut2fsa > $2

View File

@ -104,6 +104,7 @@ statement : statement1 ";" { $item[1] }
statement1: /cat/i acat { ['cat', { cat=>$item{acat}, catexp=>attr::parse($item{acat}) }, $item{acat}] }
| /flag/i flag { ['flag', { flag=>$item{flag} }, $item{flag}] }
| /role/i role role { ['role', { role=>$item[2], super=>$item[3] }, $item{role}] }
| /role/i role { ['role', { role=>$item{role} }, $item{role}] }
| /left/i role { ['left', { role=>$item{role} }, 0] }
| /right/i role { ['right', { role=>$item{role} }, 0] }
@ -126,7 +127,7 @@ statement1: /cat/i acat { ['cat', { cat=>$item{acat}, catex
role=>$item[6], props=>$item[7] }, 0] }
| /long/i role role(s? /,/) '^' role(s? /,/)
{ ['long', { rel=>$item[2], up=>$item[3], down=>$item[5] }, 0] }
{ ['long', { rel=>$item[2], up=>$item[3], down=>$item[5] }, $item[2]] }
| /class/i classname '=' xcat { ['class', { name=>$item{classname}, cats=>$item{xcat} }, $item{classname}] }
@ -142,11 +143,11 @@ flag: /\w+/
optflags: "//" flagconstr { $item[2] }
flagconstr: /\w+[+-]/
flagconstr: /(\w+[+-])+/
prop: '&' /\w+/ { $item[2] }
classname: /\$\w+[+-]/
classname: /\$\w+[+-]?/
classexpr : classexpr1 '|' classexpr { main::union($item[1],$item[3]) }
| classexpr1 '~' classexpr { main::intersection( $item[1], main::complement($item[3]) ) }
@ -213,7 +214,6 @@ while(<INPUT>)
# print "#input line $inputlineno\n";
# print Dumper($result);
if($result) { register($_, @{$result}) } else { print STDERR "ERROR at line $inputlineno\n" }
}
@ -225,22 +225,24 @@ my $outline = 0;
# print Dumper($idx{gov}->{subj});
# print Dumper(%idx);
#role closure
for my $x (@{$in{role}})
{
print Dumper($x),"\n";
}
exit;
for my $x (@{$in{cat}}) { print_outin("CAT $x->{cat}", $x); }
for my $x (@{$in{flag}}) { print_outin("FLAG $x->{flag}", $x); }
for my $x (@{$in{role}}) { print_outin("ROLE $x->{role}", $x); }
for my $x (@{$in{derivedrole}}) { print_outin("ROLE $x->{role}", $x); }
for my $x (@{$in{long}}) { print_outin("LONG $x->{rel} " . join(",",@{$x->{up}}) . "^" . join(",",@{$x->{down}}), $x) }
for my $x (@{$in{left}}) { print_outin("LEFT $x->{role}", $x) if chk_role($x->{role}, $x) }
for my $x (@{$in{right}}) { print_outin("RIGHT $x->{role}", $x) if chk_role($x->{role}, $x) }
for my $x (@{$in{sgl}}) { print_outin("SGL $x->{role}", $x) if chk_role($x->{role}, $x) }
for my $x (@{$in{req}})
{
if( chk_role($x->{role}, $x) )
@ -251,15 +253,10 @@ for my $x (@{$in{req}})
}
}
}
for my $x (@{$in{initr}}) { print_outin("INITR $x->{role}", $x) if chk_role($x->{role}, $x) }
for my $x (@{$in{finr}}) { print_outin("FINR $x->{role}", $x) if chk_role($x->{role}, $x) }
for my $x (@{$in{initf}}) { print_outin("INITF $x->{flag}", $x) } # SPRAWDZIÆ CZY FLAGA JEST ZADEKLAROWANA
for my $x (@{$in{finf}}) { print_outin("FINF $x->{flag}", $x); } # SPRAWDZIÆ CZY FLAGA JEST ZADEKLAROWANA
for my $x (@{$in{set}})
{
for my $atomcat (map{$_->{cat}} @{$x->{cats}})
@ -267,15 +264,13 @@ for my $x (@{$in{set}})
print_outin("SET $atomcat $x->{flag}", $x);
}
}
for my $x (@{$in{pass}}) { print_outin("PASS $x->{role} $x->{flag}", $x); }
for my $x (@{$in{constre}}) { print_outin("CONSTRE $x->{role1} $x->{role2}", $x) if chk_role($x->{role1}, $x) & chk_role($x->{role2}, $x) }
for my $x (@{$in{constri}}) { print_outin("CONSTRI $x->{role1} $x->{role2}", $x) if chk_role($x->{role1}, $x) & chk_role($x->{role2}, $x) }
for my $x (@{$in{link}})
{
next unless chk_role($x->{role},$x);
my @agrs = @{ $idx{agr}->{$x->{role} } or [] };
my @govs = @{ $idx{gov}->{$x->{role} } or [] };
@ -303,7 +298,7 @@ for my $x (@{$in{link}})
sub chk_role
{
($role, $statement_details) = @_;
if($idx{role}{$role}) { 1; } else { print_error("undefined role", $statement_details); 0; }
if($idx{role}{$role} || $idx{long}{$role}) { 1; } else { print_error("undefined role", $statement_details); 0; }
}
sub print_outin

1556
src/dgp/cmdline.cc Normal file

File diff suppressed because it is too large Load Diff

1
src/dgp/cmdline.d Normal file
View File

@ -0,0 +1 @@
cmdline.o cmdline.d : cmdline.cc cmdline.h

52
src/dgp/cmdline.ggo Normal file
View File

@ -0,0 +1,52 @@
package "dgp"
version "0.1"
option "grammar" g "Grammar file"
string no typestr="filename"
option "long" l "Long output"
flag off
option "debug" d "Debug mode."
flag off
option "time" - "Print parse time."
flag off
option "info" - "Print info.
h - heads d - dependents
s - sets
c - constraints n - node/arc counts"
string no default="h"
#section "Common UTT options"
option "input" f "Input file" string no
option "output" o "Output file" string no
option "only-fail" - "Print only segments the program failed to process" flag off hidden
option "no-fail" - "Print only segments the program processed" flag off hidden
option "copy" c "Copy succesfully processed segments to output" flag off
option "process" p "Process segments of this type only" string no multiple
option "select" s "Select only segments containing this field" string no multiple
option "ignore" S "Select only segments, which doesn't contain this field" string no multiple
option "output-field" O "Output field name (default: program name)" string no
option "input-field" I "Input field name (default: the FORM field)" string no multiple
option "interactive" i "Toggle interactive mode" flag off
option "config" - "Configuration file" string typestr="FILENAME" no
option "one-field" 1 "Print all alternative results in one field (creates compact ambiguous annotation)" flag off
option "one-line" - "Print annotation alternatives as additional fields in the same segment" flag off
option "language" - "Language." string no

294
src/dgp/cmdline.h Normal file
View File

@ -0,0 +1,294 @@
/** @file cmdline.h
* @brief The header file for the command line option parser
* generated by GNU Gengetopt version 2.22.6
* http://www.gnu.org/software/gengetopt.
* DO NOT modify this file, since it can be overwritten
* @author GNU Gengetopt by Lorenzo Bettini */
#ifndef CMDLINE_H
#define CMDLINE_H
/* If we use autoconf. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> /* for FILE */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef CMDLINE_PARSER_PACKAGE
/** @brief the program name (used for printing errors) */
#define CMDLINE_PARSER_PACKAGE "dgp"
#endif
#ifndef CMDLINE_PARSER_PACKAGE_NAME
/** @brief the complete program name (used for help and version) */
#define CMDLINE_PARSER_PACKAGE_NAME "dgp"
#endif
#ifndef CMDLINE_PARSER_VERSION
/** @brief the program version */
#define CMDLINE_PARSER_VERSION "0.1"
#endif
/** @brief Where the command line options are stored */
struct gengetopt_args_info
{
const char *help_help; /**< @brief Print help and exit help description. */
const char *full_help_help; /**< @brief Print help, including hidden options, and exit help description. */
const char *version_help; /**< @brief Print version and exit help description. */
char * grammar_arg; /**< @brief Grammar file. */
char * grammar_orig; /**< @brief Grammar file original value given at command line. */
const char *grammar_help; /**< @brief Grammar file help description. */
int long_flag; /**< @brief Long output (default=off). */
const char *long_help; /**< @brief Long output help description. */
int debug_flag; /**< @brief Debug mode. (default=off). */
const char *debug_help; /**< @brief Debug mode. help description. */
int time_flag; /**< @brief Print parse time. (default=off). */
const char *time_help; /**< @brief Print parse time. help description. */
char * info_arg; /**< @brief Print info.
h - heads d - dependents
s - sets
c - constraints n - node/arc counts (default='h'). */
char * info_orig; /**< @brief Print info.
h - heads d - dependents
s - sets
c - constraints n - node/arc counts original value given at command line. */
const char *info_help; /**< @brief Print info.
h - heads d - dependents
s - sets
c - constraints n - node/arc counts help description. */
char * input_arg; /**< @brief Input file. */
char * input_orig; /**< @brief Input file original value given at command line. */
const char *input_help; /**< @brief Input file help description. */
char * output_arg; /**< @brief Output file. */
char * output_orig; /**< @brief Output file original value given at command line. */
const char *output_help; /**< @brief Output file help description. */
int only_fail_flag; /**< @brief Print only segments the program failed to process (default=off). */
const char *only_fail_help; /**< @brief Print only segments the program failed to process help description. */
int no_fail_flag; /**< @brief Print only segments the program processed (default=off). */
const char *no_fail_help; /**< @brief Print only segments the program processed help description. */
int copy_flag; /**< @brief Copy succesfully processed segments to output (default=off). */
const char *copy_help; /**< @brief Copy succesfully processed segments to output help description. */
char ** process_arg; /**< @brief Process segments of this type only. */
char ** process_orig; /**< @brief Process segments of this type only original value given at command line. */
unsigned int process_min; /**< @brief Process segments of this type only's minimum occurreces */
unsigned int process_max; /**< @brief Process segments of this type only's maximum occurreces */
const char *process_help; /**< @brief Process segments of this type only help description. */
char ** select_arg; /**< @brief Select only segments containing this field. */
char ** select_orig; /**< @brief Select only segments containing this field original value given at command line. */
unsigned int select_min; /**< @brief Select only segments containing this field's minimum occurreces */
unsigned int select_max; /**< @brief Select only segments containing this field's maximum occurreces */
const char *select_help; /**< @brief Select only segments containing this field help description. */
char ** ignore_arg; /**< @brief Select only segments, which doesn't contain this field. */
char ** ignore_orig; /**< @brief Select only segments, which doesn't contain this field original value given at command line. */
unsigned int ignore_min; /**< @brief Select only segments, which doesn't contain this field's minimum occurreces */
unsigned int ignore_max; /**< @brief Select only segments, which doesn't contain this field's maximum occurreces */
const char *ignore_help; /**< @brief Select only segments, which doesn't contain this field help description. */
char * output_field_arg; /**< @brief Output field name (default: program name). */
char * output_field_orig; /**< @brief Output field name (default: program name) original value given at command line. */
const char *output_field_help; /**< @brief Output field name (default: program name) help description. */
char ** input_field_arg; /**< @brief Input field name (default: the FORM field). */
char ** input_field_orig; /**< @brief Input field name (default: the FORM field) original value given at command line. */
unsigned int input_field_min; /**< @brief Input field name (default: the FORM field)'s minimum occurreces */
unsigned int input_field_max; /**< @brief Input field name (default: the FORM field)'s maximum occurreces */
const char *input_field_help; /**< @brief Input field name (default: the FORM field) help description. */
int interactive_flag; /**< @brief Toggle interactive mode (default=off). */
const char *interactive_help; /**< @brief Toggle interactive mode help description. */
char * config_arg; /**< @brief Configuration file. */
char * config_orig; /**< @brief Configuration file original value given at command line. */
const char *config_help; /**< @brief Configuration file help description. */
int one_field_flag; /**< @brief Print all alternative results in one field (creates compact ambiguous annotation) (default=off). */
const char *one_field_help; /**< @brief Print all alternative results in one field (creates compact ambiguous annotation) help description. */
int one_line_flag; /**< @brief Print annotation alternatives as additional fields in the same segment (default=off). */
const char *one_line_help; /**< @brief Print annotation alternatives as additional fields in the same segment help description. */
char * language_arg; /**< @brief Language.. */
char * language_orig; /**< @brief Language. original value given at command line. */
const char *language_help; /**< @brief Language. help description. */
unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int full_help_given ; /**< @brief Whether full-help was given. */
unsigned int version_given ; /**< @brief Whether version was given. */
unsigned int grammar_given ; /**< @brief Whether grammar was given. */
unsigned int long_given ; /**< @brief Whether long was given. */
unsigned int debug_given ; /**< @brief Whether debug was given. */
unsigned int time_given ; /**< @brief Whether time was given. */
unsigned int info_given ; /**< @brief Whether info was given. */
unsigned int input_given ; /**< @brief Whether input was given. */
unsigned int output_given ; /**< @brief Whether output was given. */
unsigned int only_fail_given ; /**< @brief Whether only-fail was given. */
unsigned int no_fail_given ; /**< @brief Whether no-fail was given. */
unsigned int copy_given ; /**< @brief Whether copy was given. */
unsigned int process_given ; /**< @brief Whether process was given. */
unsigned int select_given ; /**< @brief Whether select was given. */
unsigned int ignore_given ; /**< @brief Whether ignore was given. */
unsigned int output_field_given ; /**< @brief Whether output-field was given. */
unsigned int input_field_given ; /**< @brief Whether input-field was given. */
unsigned int interactive_given ; /**< @brief Whether interactive was given. */
unsigned int config_given ; /**< @brief Whether config was given. */
unsigned int one_field_given ; /**< @brief Whether one-field was given. */
unsigned int one_line_given ; /**< @brief Whether one-line was given. */
unsigned int language_given ; /**< @brief Whether language was given. */
} ;
/** @brief The additional parameters to pass to parser functions */
struct cmdline_parser_params
{
int override; /**< @brief whether to override possibly already present options (default 0) */
int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
int check_required; /**< @brief whether to check that all required options were provided (default 1) */
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
} ;
/** @brief the purpose string of the program */
extern const char *gengetopt_args_info_purpose;
/** @brief the usage string of the program */
extern const char *gengetopt_args_info_usage;
/** @brief the description string of the program */
extern const char *gengetopt_args_info_description;
/** @brief all the lines making the help output */
extern const char *gengetopt_args_info_help[];
/** @brief all the lines making the full help output (including hidden options) */
extern const char *gengetopt_args_info_full_help[];
/**
* The command line parser
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser (int argc, char **argv,
struct gengetopt_args_info *args_info);
/**
* The command line parser (version with additional parameters - deprecated)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param override whether to override possibly already present options
* @param initialize whether to initialize the option structure my_args_info
* @param check_required whether to check that all required options were provided
* @return 0 if everything went fine, NON 0 if an error took place
* @deprecated use cmdline_parser_ext() instead
*/
int cmdline_parser2 (int argc, char **argv,
struct gengetopt_args_info *args_info,
int override, int initialize, int check_required);
/**
* The command line parser (version with additional parameters)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param params additional parameters for the parser
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_ext (int argc, char **argv,
struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params);
/**
* Save the contents of the option struct into an already open FILE stream.
* @param outfile the stream where to dump options
* @param args_info the option struct to dump
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_dump(FILE *outfile,
struct gengetopt_args_info *args_info);
/**
* Save the contents of the option struct into a (text) file.
* This file can be read by the config file parser (if generated by gengetopt)
* @param filename the file where to save
* @param args_info the option struct to save
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_file_save(const char *filename,
struct gengetopt_args_info *args_info);
/**
* Print the help
*/
void cmdline_parser_print_help(void);
/**
* Print the full help (including hidden options)
*/
void cmdline_parser_print_full_help(void);
/**
* Print the version
*/
void cmdline_parser_print_version(void);
/**
* Initializes all the fields a cmdline_parser_params structure
* to their default values
* @param params the structure to initialize
*/
void cmdline_parser_params_init(struct cmdline_parser_params *params);
/**
* Allocates dynamically a cmdline_parser_params structure and initializes
* all its fields to their default values
* @return the created and initialized cmdline_parser_params structure
*/
struct cmdline_parser_params *cmdline_parser_params_create(void);
/**
* Initializes the passed gengetopt_args_info structure's fields
* (also set default values for options that have a default)
* @param args_info the structure to initialize
*/
void cmdline_parser_init (struct gengetopt_args_info *args_info);
/**
* Deallocates the string fields of the gengetopt_args_info structure
* (but does not deallocate the structure itself)
* @param args_info the structure to deallocate
*/
void cmdline_parser_free (struct gengetopt_args_info *args_info);
/**
* The config file parser (deprecated version)
* @param filename the name of the config file
* @param args_info the structure where option information will be stored
* @param override whether to override possibly already present options
* @param initialize whether to initialize the option structure my_args_info
* @param check_required whether to check that all required options were provided
* @return 0 if everything went fine, NON 0 if an error took place
* @deprecated use cmdline_parser_config_file() instead
*/
int cmdline_parser_configfile (const char *filename,
struct gengetopt_args_info *args_info,
int override, int initialize, int check_required);
/**
* The config file parser
* @param filename the name of the config file
* @param args_info the structure where option information will be stored
* @param params additional parameters for the parser
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_config_file (const char *filename,
struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params);
/**
* Checks that all the required options were specified
* @param args_info the structure to check
* @param prog_name the name of the program that will be used to print
* possible errors
* @return
*/
int cmdline_parser_required (struct gengetopt_args_info *args_info,
const char *prog_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CMDLINE_H */

BIN
src/dgp/cmdline.o Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
#ifndef CONST_HH
#define CONST_HH
#define MAXTYPES 32
#define MAXTYPES 64
#define MAXCATS 4096
#define MAXFLAGS 64
#define MAXPROPS 16

BIN
src/dgp/dgp Executable file

Binary file not shown.

View File

@ -43,8 +43,8 @@ NodeProp compute_head_prop(NodeProp headprop, const Link& link, list<Boubble*> b
if(grammar.is_sgl(link.role))
{
ret.forbidden.set(link.role);
ret.attached.set(link.role);
}
ret.attached.set(link.role);
ret.required.reset(link.role);
ret.required |= (grammar.constr_include(link.role) & ~ret.attached);
@ -154,7 +154,7 @@ int create_new_node(int anc, NodeProp& prop, Edge edge)
nodelist.push_back(newheadind);
copy_links(anc,newheadind);
create_reverse_links(newheadind);
if(debug) sgraph.print_node_debug(stderr,"clone",newheadind,anc);
if(debug) sgraph.print_node_debug(stderr,"clone",newheadind);
// if(debug) print_sets(newheadind);
return newheadind;
}
@ -174,13 +174,17 @@ void connect_left(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles
if( newd < 0 )
{
newd = create_new_node(d,new_dep_prop,new_dep_edge);
sgraph[newd].set_skip_conditional(sgraph[d]);
sgraph[newd].prop.has_head = true;
}
Edge new_head_edge(sgraph[newd].edge,newd);
int newh = find_existing_node(sgraph[h].mnode, new_head_prop, new_head_edge);
if( newh < 0 )
{
newh = create_new_node(h,new_head_prop,new_head_edge);
sgraph[newh].set_skip_false();
}
sgraph[newh].deps.push_back(Arc(newd,l.role,h,d));
sgraph[newd].heads.push_back(Arc(newh,l.role,h,d));
@ -188,8 +192,8 @@ void connect_left(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles
if(debug)
{
sgraph.print_arc(stderr,"link",newh,d,l.role,0);
sgraph.print_node_debug(stderr,"",newh,h);
sgraph.print_node_debug(stderr,"",newd,d);
sgraph.print_node_debug(stderr,"",newh);
sgraph.print_node_debug(stderr,"",newd);
}
}
@ -204,18 +208,22 @@ void connect_right(int h, int d, const Link& l, list<Boubble*>& new_head_boubble
Edge new_head_edge(sgraph[h].edge);
int newh = -1;
if(!new_head_prop.forbidden[l.role]) newh = find_existing_node(sgraph[h].mnode, new_head_prop, new_head_edge);
// if(!new_head_prop.forbidden[l.role])
newh = find_existing_node(sgraph[h].mnode, new_head_prop, new_head_edge);
if( newh < 0 )
{
newh = create_new_node(h,new_head_prop,new_head_edge);
sgraph[newh].set_skip_conditional(sgraph[h]);
sgraph[newh].prop.visible_as_neighbour = false;
}
Edge new_dep_edge;
int newd = d;
if( ! (new_dep_edge == sgraph[d].edge) || ! (old_dep_prop == new_dep_prop) )
// if( ! (new_dep_edge == sgraph[d].edge) || ! (old_dep_prop == new_dep_prop) )
if( ! (old_dep_prop == new_dep_prop) )
{
newd = create_new_node(d,new_dep_prop,new_dep_edge);
sgraph[newd].set_skip_conditional(sgraph[d]);
sgraph[newd].prop.has_head = true;
}
@ -226,8 +234,8 @@ void connect_right(int h, int d, const Link& l, list<Boubble*>& new_head_boubble
if(debug)
{
sgraph.print_arc(stderr,"link",newh,newd,l.role,1);
sgraph.print_node_debug(stderr,"",newh,h);
sgraph.print_node_debug(stderr,"",newd,d);
sgraph.print_node_debug(stderr,"",newh);
sgraph.print_node_debug(stderr,"",newd);
}
}
@ -470,18 +478,24 @@ void dgp1()
set_initial_constraints(basenode);
nodelist.push_back(basenode);
if(debug) sgraph.print_node_debug(stderr,"node",basenode,-1); // STDOUT!!!
if(debug) sgraph.print_node_debug(stderr,"node",basenode); // STDOUT!!!
// if(debug) print_sets(basenode);
list<int>::iterator cursor=processed;
while(++cursor != nodelist.end())
{
if(debug) sgraph.print_node_debug(stderr,"CUR>",*cursor,-1);
if(sgraph[*cursor].skip())
{
if(debug) sgraph.print_node_debug(stderr,"SKIP>",*cursor);
}
else
{
if(debug) sgraph.print_node_debug(stderr,"CUR>",*cursor);
try_connect_dependents(*cursor);
try_connect_heads(*cursor);
}
processed=cursor;
}
}
// reverse_links();
update_sets();

3
src/dgp/dgp1.d Normal file
View File

@ -0,0 +1,3 @@
dgp1.o dgp1.d : dgp1.cc dgp1.hh grammar.hh const.hh thesymbols.hh symbol.hh \
sgraph.hh mgraph.hh ../common/common.h ../common/../lib/const.h \
../common/../dgp/cmdline.h boubble.hh global.hh

BIN
src/dgp/dgp1.o Normal file

Binary file not shown.

1
src/dgp/global.d Normal file
View File

@ -0,0 +1 @@
global.o global.d : global.cc global.hh

BIN
src/dgp/global.o Normal file

Binary file not shown.

View File

@ -62,7 +62,7 @@ void Grammar::add_category(const char* s)
void Grammar::add_type(const char* s)
{
Role::add(s);
if(Role::count() > MAXTYPES) { fprintf(stderr,"ERROR: too many types. Aborting.\n"); exit(1); }
if(lt.size() <= Role::count()) lt.resize(Role::count()+RESIZE_DELTA);
if(gt.size() <= Role::count()) gt.resize(Role::count()+RESIZE_DELTA);
if(pass.size() <= Role::count()) pass.resize(Role::count()+RESIZE_DELTA);
@ -155,15 +155,16 @@ list<Boubble*> Grammar::trigger_boubbles(Cat c, Role r, Dir d)
//====================================================================================================
Flag parse_flags(const char* s, const char* v)
FlagSet parse_flags(const char* s, const char* v)
{
FlagSet ret;
char buf[16][17];
int n=sscanf(s,"%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]%[A-Z]%[+-]",
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7],buf[8],buf[9],buf[10],buf[11],buf[12],buf[13],buf[14],buf[15],buf[16]);
for(int i=2; i<=n; i+=2)
if(strcmp(buf[i-1],v)==0)
return Flag(buf[i-2]);
return Flag("NULL");
ret.set(Flag(buf[i-2]));
return ret;
}
@ -406,18 +407,18 @@ void Grammar::write(ostream& os)
for(Links::const_iterator l = connect1[c][d].begin(); l != connect1[c][d].end(); l++)
{
os << "LINK\t" << c.str();
if(l->hflagplus||l->hflagminus)
if(l->hflagplus.any()||l->hflagminus.any())
{
os << ";";
if(l->hflagplus) os << (l->hflagplus).str() << "+";
if(l->hflagminus) os << (l->hflagminus).str() << "-";
for(Flag f=1; f<Flag::count(); +f) if(l->hflagplus.test(f)) os << "f" << f.str() << "+";
for(Flag f=1; f<Flag::count(); +f) if(l->hflagminus.test(f)) os << "f" << f.str() << "-";
}
os << "\t" << d.str();
if(l->dflagplus||l->dflagminus)
if(l->dflagplus.any()||l->dflagminus.any())
{
os << ";";
if(l->dflagplus) os << (l->dflagplus).str() << "+";
if(l->dflagminus) os << (l->dflagminus).str() << "-";
for(Flag f=1; f<Flag::count(); +f) if(l->dflagplus.test(f)) os << "f" << f.str() << "+";
for(Flag f=1; f<Flag::count(); +f) if(l->dflagminus.test(f)) os << "f" << f.str() << "-";
}
os << "\t" << (l->role).str();
for(Prop p=0; p<Prop::count(); ++p)

3
src/dgp/grammar.d Normal file
View File

@ -0,0 +1,3 @@
grammar.o grammar.d : grammar.cc grammar.hh const.hh thesymbols.hh symbol.hh \
sgraph.hh mgraph.hh ../common/common.h ../common/../lib/const.h \
../common/../dgp/cmdline.h boubble.hh global.hh

View File

@ -27,25 +27,25 @@ const FlagSet EmptyFlagSet = FlagSet();
struct Link
{
// Link(Role r, Flag dfplus="NULL", Flag dfminus="NULL") : role(r), dflagplus(dfplus), dflagminus(dfminus) { }
Link(Role r, PropSet ps=EmptyPropSet, Flag hfp="NULL", Flag hfm="NULL", Flag dfp="NULL", Flag dfm="NULL", int lineno=0)
Link(Role r, PropSet ps, FlagSet hfp, FlagSet hfm, FlagSet dfp, FlagSet dfm, int lineno=0)
: role(r), props(ps), hflagplus(hfp), hflagminus(hfm), dflagplus(dfp), dflagminus(dfm) { }
//Link(Role r) : role(r), dflagplus("NULL") { }
Role role;
Flag hflagplus;
Flag hflagminus;
Flag dflagplus;
Flag dflagminus;
FlagSet hflagplus;
FlagSet hflagminus;
FlagSet dflagplus;
FlagSet dflagminus;
PropSet props;
int lineno;
bool operator<(const Link& l) const
{
if(role < l.role) return true;
if(hflagplus < l.hflagplus) return true;
if(hflagminus < l.hflagminus) return true;
if(dflagplus < l.dflagplus) return true;
if(dflagminus < l.dflagminus) return true;
if(hflagplus.to_ulong() < l.hflagplus.to_ulong()) return true;
if(hflagminus.to_ulong() < l.hflagminus.to_ulong()) return true;
if(dflagplus.to_ulong() < l.dflagplus.to_ulong()) return true;
if(dflagminus.to_ulong() < l.dflagminus.to_ulong()) return true;
if(props.to_ulong() < l.props.to_ulong()) return true;
return false;
}
@ -140,7 +140,7 @@ private:
// void set_connect(Cat c, Cat d, Role r) { connect[c][d].insert(r); }
// void set_connect(Cat c, Cat d, Flag f, Role r) { connect1[c][d].insert(Link(r,f)); }
void set_connect(Cat h, Flag hfp, Flag hfm, Cat d, Flag dfp, Flag dfm, Role r, PropSet ps, int lineno ) { connect1[h][d].insert(Link(r,ps,hfp,hfm,dfp,dfm,lineno)); }
void set_connect(Cat h, FlagSet hfp, FlagSet hfm, Cat d, FlagSet dfp, FlagSet dfm, Role r, PropSet ps, int lineno ) { connect1[h][d].insert(Link(r,ps,hfp,hfm,dfp,dfm,lineno)); }
void set_include(Role r, Role s) { include[r].set(s); }
void set_exclude(Role r, Role s) { exclude[r].set(s); }
@ -161,9 +161,13 @@ list<const Link*> Grammar::connectable2(Cat h, Cat d, FlagSet hfs, FlagSet dfs)
{
list<const Link*> ret;
for(Links::const_iterator l = connect1[h][d].begin(); l != connect1[h][d].end(); l++)
if( (l->hflagplus==0 || hfs[l->hflagplus]) && (l->hflagminus==0 || !hfs[l->hflagminus]) )
if( (l->dflagplus==0 || dfs[l->dflagplus]) && (l->dflagminus==0 || !dfs[l->dflagminus]) )
{
// cout << l->hflagplus.count() << " " << l->hflagminus.count() << " " << hfs.count() << endl;
// cout << l->dflagplus.count() << " " << l->dflagminus.count() << " " << dfs.count() << endl;
if( ((l->hflagplus & hfs) == l->hflagplus) && (l->hflagminus & hfs).none() )
if( ((l->dflagplus & dfs) == l->dflagplus) && (l->dflagminus & dfs).none() )
ret.push_back(&(*l));
}
return ret;
}

BIN
src/dgp/grammar.o Normal file

Binary file not shown.

View File

@ -38,7 +38,7 @@ unsigned int info=0U;
bool printtimeinfo=false;
void output();
void output(unsigned int);
main(int argc, char* argv[])
{
@ -70,6 +70,11 @@ main(int argc, char* argv[])
case 'd': info|=SGraph::DEPS; break;
case 's': info|=SGraph::SETS; break;
case 'c': info|=SGraph::CONSTRAINTS; break;
case 'a': info|=SGraph::ANCESTOR; break;
case 'v': info|=SGraph::VIS_AS_NEIGH; break;
case 'e': info|=SGraph::EDGE; break;
case 'k': info|=SGraph::SKIP; break;
case '*': info|=0b1111111111111111U; break;
}
gettimeofday(&readgrammar_starttime,NULL);
@ -114,7 +119,7 @@ main(int argc, char* argv[])
dgp1(); // parametry!!! MGraph, SGraph, Grammar
gettimeofday(&afterparse,NULL);
output();
output(info);
gettimeofday(&endtime,NULL);
if(printtimeinfo)
@ -138,7 +143,7 @@ main(int argc, char* argv[])
exit(0);
}
void output()
void output(unsigned int info)
{
for(int si=0; si<segcount; ++si)
{

3
src/dgp/main.d Normal file
View File

@ -0,0 +1,3 @@
main.o main.d : main.cc global.hh mgraph.hh const.hh thesymbols.hh symbol.hh \
../common/common.h ../common/../lib/const.h ../common/../dgp/cmdline.h \
sgraph.hh boubble.hh grammar.hh dgp1.hh cmdline.h

BIN
src/dgp/main.o Normal file

Binary file not shown.

2
src/dgp/mgraph.d Normal file
View File

@ -0,0 +1,2 @@
mgraph.o mgraph.d : mgraph.cc mgraph.hh const.hh thesymbols.hh symbol.hh \
../common/common.h ../common/../lib/const.h ../common/../dgp/cmdline.h

BIN
src/dgp/mgraph.o Normal file

Binary file not shown.

View File

@ -61,8 +61,8 @@ int SGraph::clone(int ancind, NodeProp newprop, Edge edge)
newnode.prop = newprop;
newnode.edge = edge;
newnode.mnode = ancnode.mnode;
newnode.anc = ancind;
mgraph[newnode.mnode].snodes.push_back(lastnodeind());
return lastnodeind();
}
@ -71,16 +71,16 @@ int SGraph::clone(int ancind, NodeProp newprop, Edge edge)
int SGraph::print_node(FILE* f, int n, unsigned int info)
{
char buf[50000];
sprint_node(buf,n,-1,info);
sprint_node(buf,n,info);
fputs(buf,f);
}
//----------------------------------------------------------------------------------------------------
int SGraph::print_node_debug(FILE* f, const char* pref, int n, int anc)
int SGraph::print_node_debug(FILE* f, const char* pref, int n)
{
char buf[50000];
sprint_node_debug(buf,pref,n,anc);
sprint_node_debug(buf,pref,n);
fputs(buf,f);
}
@ -96,14 +96,14 @@ void SGraph::print_arc(FILE* f, const char* msg, int head, int dep, Role role, i
//====================================================================================================
int SGraph::sprint_node(char* buf, int nodeind, int anc, unsigned int info)
int SGraph::sprint_node(char* buf, int nodeind, unsigned int info)
{
char* buf0=buf;
SNode &node=nodes[nodeind];
buf+=sprintf(buf," dgp:%d",nodeind);
if(anc>=0) buf+=sprintf(buf,"(%d)",anc);
if(node.anc>=0 && info&ANCESTOR) buf+=sprintf(buf,"(%d)",node.anc);
buf+=sprintf(buf, saturated(nodeind) ? ";s" : ";u");
if (info&HEADS || info&DEPS)
@ -162,13 +162,30 @@ int SGraph::sprint_node(char* buf, int nodeind, int anc, unsigned int info)
buf+=sprintf(buf,oss.str().c_str());
}
if(info&VIS_AS_NEIGH)
buf += sprintf(buf,nodes[nodeind].prop.visible_as_neighbour ? "(van=1)" : "(van=0)");
if(info&EDGE)
{
buf += sprintf(buf,"(edge=");
for(list<int>::iterator e = nodes[nodeind].edge.others().begin(); e != nodes[nodeind].edge.others().end(); e++ )
buf += sprintf(buf,"%d ", *e);
if(nodes[nodeind].edge.self())
buf += sprintf(buf,"* ");
buf += sprintf(buf,")");
}
if(info&SKIP)
if(nodes[nodeind].skip()) buf += sprintf(buf,"(skip)");
// buf+=sprintf(buf,"\n");
return buf-buf0;
}
int SGraph::sprint_node_debug(char* buf, const char* pref, int n, int anc)
int SGraph::sprint_node_debug(char* buf, const char* pref, int n)
{
char *buf0 = buf;
buf+=sprintf(buf,"%-8s",pref);
@ -176,14 +193,8 @@ int SGraph::sprint_node_debug(char* buf, const char* pref, int n, int anc)
buf+=sprintf(buf,";");
buf+=sprintf(buf,"%s ",cat(n).str());
while(buf-buf0<40) buf+=sprintf(buf," ");
buf+=sprint_node(buf,n,anc,HEADS|DEPS|CONSTRAINTS);
buf+=sprintf(buf,"/");
buf+=sprintf(buf,nodes[n].prop.visible_as_neighbour ? "o" : "x");
if(nodes[n].edge.self())
buf += sprintf(buf,"* ");
for(list<int>::iterator e = nodes[n].edge.others().begin(); e != nodes[n].edge.others().end(); e++ )
buf += sprintf(buf,"%d ", *e);
buf+=sprint_node(buf,n,HEADS|DEPS|CONSTRAINTS|ANCESTOR|VIS_AS_NEIGH|EDGE|SKIP);
buf+=sprintf(buf,"\n");
return buf-buf0;

3
src/dgp/sgraph.d Normal file
View File

@ -0,0 +1,3 @@
sgraph.o sgraph.d : sgraph.cc sgraph.hh const.hh mgraph.hh thesymbols.hh symbol.hh \
../common/common.h ../common/../lib/const.h ../common/../dgp/cmdline.h \
boubble.hh global.hh grammar.hh

View File

@ -168,9 +168,10 @@ private:
struct SNode
{
SNode() { prop.clear(); }
SNode() : _skip(false), anc(-1) { prop.clear(); }
int mnode;
int anc;
NodeProp prop;
Edge edge;
@ -184,8 +185,21 @@ struct SNode
vector<Arc> deps;
void clear() { prop.clear(), LV.reset(), LD.reset(), LH.reset(), heads.clear(), deps.clear(); }
bool saturated() { return prop.required.none(); }
bool saturated() const { return prop.required.none(); }
void skip(bool b) { _skip=b; }
bool skip() { return _skip; }
void set_skip_false() { skip(false); }
void set_skip_conditional(const SNode& ancnode)
{
if(saturated() && !ancnode.saturated()) skip(false);
else if((prop.flags & ancnode.prop.flags) != ancnode.prop.flags) skip(false);
else skip(true);
}
private:
bool _skip;
// void edge_clear() { edge.clear(); edge_contains_self=false;}
// void edge_set(int i) { edge.clear(); edge_contains_self=false; edge.push_back(i); }
@ -204,7 +218,7 @@ class SGraph
{
public:
enum Output { HEADS=1, DEPS=2, SETS=4, CONSTRAINTS=8, BOUBBLES=16 };
enum Output { HEADS=1, DEPS=2, SETS=4, CONSTRAINTS=8, BOUBBLES=16, ANCESTOR=32, VIS_AS_NEIGH=64, EDGE=128, SKIP=256 };
SGraph(MGraph& mg) : mgraph(mg) { clear(); }
@ -223,7 +237,7 @@ public:
char* form(int i) const { return mgraph[nodes[i].mnode].form; }
int print_node(FILE* f, int n, unsigned int info);
int print_node_debug(FILE* f, const char* pref, int n, int anc);
int print_node_debug(FILE* f, const char* pref, int n);
void print_arc(FILE* f, const char* msg, int left, int right, Role role, int dir); // 0 - left, 1 - right
@ -245,8 +259,8 @@ private:
int lastnodeind() { return nodes.size()-1; }
SNode& makenewnode() { nodes.push_back(SNode()); nodes.back().clear(); return nodes.back(); }
int sprint_node(char* buf, int n, int anc, unsigned int info);
int sprint_node_debug(char* buf, const char* pref, int n, int anc);
int sprint_node(char* buf, int n, unsigned int info);
int sprint_node_debug(char* buf, const char* pref, int n);
};
//----------------------------------------------------------------------------------------------------
@ -332,7 +346,7 @@ inline int LViterator::next()
{
if(waydown.empty())
{
if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,-1);
return -1; //
}
else
@ -343,7 +357,7 @@ inline int LViterator::next()
push_ln(k);
if(wayup.empty())
{
if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,-1);
return -1; // k NIE MA POPRZEDNIKÓW, NIE MO¯E TE¯ ZATEM MIEÆ LEWOSTRONNYCH PODRZÊDNIKÓW
}
else
@ -351,7 +365,7 @@ inline int LViterator::next()
int i = wayup.top();
wayup.pop();
push_lh(i);
if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,i);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,i);
return i;
}
}
@ -362,7 +376,7 @@ inline int LViterator::next()
int i = wayup.top();
wayup.pop();
push_lh(i);
if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,i);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\treturn %d\n",snode,i);
return i;
};
}
@ -374,7 +388,7 @@ inline void LViterator::push_ld(int i)
if(mgraph[sgraph[a->dst].mnode].pos < mgraph[sgraph[i].mnode].pos)
{
push(waydown,a->dst);
if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LD waydown %d\n",snode,a->dst);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LD waydown %d\n",snode,a->dst);
}
}
@ -385,7 +399,7 @@ inline void LViterator::push_lh(int i)
if(mgraph[sgraph[a->dst].mnode].pos < mgraph[sgraph[i].mnode].pos)
{
push(wayup,a->dst);
if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LH wayup %d\n",snode,a->dst);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LH wayup %d\n",snode,a->dst);
}
}
@ -399,7 +413,7 @@ inline void LViterator::push_ln(int i)
if(sgraph[*sp].prop.visible_as_neighbour || !strict)
{
push(wayup,*sp);
if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LN wayup %d\n",snode, *sp);
//if(debug) fprintf(stderr,"\t\tLViterator(%d)\tPUSH_LN wayup %d\n",snode, *sp);
}
}
}
@ -433,14 +447,14 @@ inline int LNiterator::next()
{
if(wayup.empty())
{
if(debug) fprintf(stderr,"\t\tLNiterator(%d)\treturn %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLNiterator(%d)\treturn %d\n",snode,-1);
return -1;
}
else
{
int i = wayup.top();
wayup.pop();
if(debug) fprintf(stderr,"\t\tLNiterator(%d)\treturn %d\n",snode,i);
//if(debug) fprintf(stderr,"\t\tLNiterator(%d)\treturn %d\n",snode,i);
return i;
};
}
@ -454,7 +468,7 @@ inline void LNiterator::push_ln(int i)
for(vector<int>::iterator sp = spredecessors.begin(); sp != spredecessors.end(); ++sp )
{
wayup.push(*sp);
if(debug) fprintf(stderr,"\t\tLNiterator(%d)\tPUSH %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLNiterator(%d)\tPUSH %d\n",snode,-1);
}
}
}
@ -504,7 +518,7 @@ inline void LHiterator::push_lh(int i)
if(mgraph[sgraph[a->dst].mnode].pos < mgraph[sgraph[i].mnode].pos)
{
wayup.push(a->dst);
if(debug) fprintf(stderr,"\t\tLHiterator(%d)\tPUSH %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLHiterator(%d)\tPUSH %d\n",snode,-1);
}
}
@ -552,7 +566,7 @@ inline void LDiterator::push_ld(int i)
if(mgraph[sgraph[a->dst].mnode].pos < mgraph[sgraph[snode].mnode].pos)
{
waydown.push(a->dst);
if(debug) fprintf(stderr,"\t\tLDiterator(%d)\tPUSH %d\n",snode,-1);
//if(debug) fprintf(stderr,"\t\tLDiterator(%d)\tPUSH %d\n",snode,-1);
}
}

BIN
src/dgp/sgraph.o Normal file

Binary file not shown.

1
src/dgp/symbol.d Normal file
View File

@ -0,0 +1 @@
symbol.o symbol.d : symbol.cc symbol.hh

BIN
src/dgp/symbol.o Normal file

Binary file not shown.

16
src/rat/Makefile Normal file
View File

@ -0,0 +1,16 @@
include ../../config.mak
rat:
.PHONY: install
install:
ifdef BIN_DIR
install -m 0755 rat $(BIN_DIR)
endif
.PHONY: uninstall
uninstall:
ifdef BIN_DIR
rm $(BIN_DIR)/rat
endif
clean:

43
src/rat/rat Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env ruby
# encoding: UTF-8
require 'attr'
require 'getoptlong'
Help = <<END
Usage:
rmattr [OPTION]... infile
Options:
--help -h Help.
--output=PATH -o PATH Automatic choice.
--multi -m Put all trees to separate latex files.
END
$rm = []
$pos = nil
opts = GetoptLong.new(
[ "--attr", "-a", GetoptLong::REQUIRED_ARGUMENT ],
[ "--pos", "-p", GetoptLong::REQUIRED_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
opts.each do |o,a|
case o
when '--attr'
$rm << a.to_sym
when '--pos'
$pos = a
when '--help'
print Help
exit
end
end
while l=gets
print l.gsub(/#{$pos or POS}\/#{AVLIST}/){|c| Cat.new(c) - $rm }
end

View File

@ -144,12 +144,14 @@ def tre(input)
$pref = "#{seg[1]} #{seg[2]} SYN *"
parsegraph(nodes)
set_ord #(0...(nodes.length)).each{|i| set_distance_from_i i }
printgraph if $DEBUG
printgraph_debug if $DEBUG
if $GRAPH
if $FORMAT =~ /c/
printconll
elsif $FORMAT =~ /dot/
printdot
else
printground
printgraph
end
else
thetrees = $FOREST ? genforest : gentrees
@ -298,22 +300,6 @@ def par_output(tree)
output_left = ldeps.map{|arc| ' (' + (($INFO =~ /l/) ? arc[2].upcase : '') + par_output([arc[1],arcs]) + ')'}.join
output_right = rdeps.map{|arc| ' (' + (($INFO =~ /l/) ? arc[2].upcase : '') + par_output([arc[1],arcs]) + ')'}.join
# for arc in ldeps
# output += ' ('
# output += arc[2].upcase if $INFO =~ /l/
# output += par_output(arc[1],arcs)
# output += ')'
# end
# print ' ',nodeinfo(root)
# for arc in rdeps
# print ' ('
# print arc[2].upcase if $INFO =~ /l/
# printpar(arc[1],arcs)
# print ')'
# end
output_left + ' ' + nodeinfo(root) + output_right
end
@ -372,21 +358,10 @@ end
#NOWE-START
def successors i
$succ.select{|e| e[0]==i}.map{|e| e[1]}
end
def predecessors i
$succ.select{|e| e[1]==i}.map{|e| e[0]}
end
def start_nodes
$succ.map{|e| e[1]}.map{|e| predecessors(e)}.uniq.map{|e| e[0]}
end
def end_nodes
$succ.map{|e| e[0]}.map{|e| successors(e)}.uniq.map{|e| e[0]}
end
def successors i; $succ.select{|e| e[0]==i}.map{|e| e[1]} end
def predecessors i; $succ.select{|e| e[1]==i}.map{|e| e[0]} end
def start_nodes; $succ.map{|e| e[1]}.map{|e| predecessors(e)}.uniq.map{|e| e[0]} end
def end_nodes; $succ.map{|e| e[0]}.map{|e| successors(e)}.uniq.map{|e| e[0]} end
def set_ord
positions = $pos.uniq.sort
@ -496,17 +471,21 @@ def buildL(min,max,tree)
end
def printgraph()
def printgraph_debug
print "N: #{$n}\n"
print "FORM: #{$form.inspect}\n"
print "POS: #{$pos.inspect}\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"
puts "ORD: #{$ord.inspect}"
puts "ORD1: #{$ord1.inspect}"
end
def printground
def printgraph
for i in 1...($form.length-1)
print "#{$ord1[i]} #{$form[i]} #{$lem[i]} "
print $arcs.select{|a| $ord1[$gphid[a[1]]] == $ord1[i]}.map{|a| "#{a[2]}:#{$ord1[$gphid[a[0]]]}"}.sort.uniq.join(' ')
@ -514,6 +493,22 @@ def printground
end
end
def printdot
# printgraph_debug
dgprange = 1..($n-2)
puts "digraph g {"
puts "rankdir=LR"
words = $form[1..-2].uniq
puts "{ " + (0...(words.length)).map{|i| "w#{i}"}.join(" -> ") + " }"
(0...(words.length)).each{|i| puts "w#{i} [label=\"#{words[i]}\"]"}
dgprange.each{|i| puts "#{i} [label=< <b>#{i}.#{nodeinfo(i)} </b> >]"}
$arcs.each{|a| puts "#{a[0]} -> #{a[1]} [label=\"#{a[2]}\"]" }
for wi in (0...(words.length))
puts "{ rank=same; w#{wi}; " + dgprange.select{|i| $ord[i]==wi}.map{|x| " #{x};"}.join + " }"
end
puts "}"
end
def printconll
for i in 1...($form.length-1)
id = $ord1[i]