Bug fixes: bubbles,props
This commit is contained in:
parent
f924e4be28
commit
519eaf5085
@ -27,6 +27,7 @@ ifdef LANG_DIR
|
||||
install -m 0644 pl_PL.ISO-8859-2/pl_PL.ISO-8859-2.sym $(LANG_DIR)/pl_PL.ISO-8859-2
|
||||
install -m 0644 pl_PL.UTF-8/lem.bin $(LANG_DIR)/pl_PL.UTF-8
|
||||
install -m 0644 gram.dgp $(LANG_DIR)
|
||||
install -m 0644 gram.dgc $(LANG_DIR)
|
||||
install -m 0644 weights.kor $(LANG_DIR)
|
||||
endif
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#====================================================================================================
|
||||
|
||||
FLAG RQ
|
||||
FLAG TESTFLAGGG
|
||||
FLAG init
|
||||
|
||||
#====================================================================================================
|
||||
@ -422,7 +423,6 @@ LINK ADV ADV ncoord
|
||||
LONG relagr subj,rel^
|
||||
LONG relagr cmpl_a,rel^
|
||||
|
||||
AGR relagr C
|
||||
AGR relagr N
|
||||
AGR relagr G
|
||||
|
||||
|
Binary file not shown.
@ -180,4 +180,4 @@ rm -r $tempdir
|
||||
|
||||
echo generating cats file ...
|
||||
|
||||
cat $1 | cut -d ',' -f 2 | sort -u $2.cats
|
||||
cat $1 | cut -d ',' -f 2 | sort -u > $2.cats
|
||||
|
@ -292,7 +292,8 @@ for my $x (@{$in{link}})
|
||||
}
|
||||
my $hflagconstr = @{$x->{hflagconstr}} ? "//@{$x->{hflagconstr}}" : "";
|
||||
my $dflagconstr = @{$x->{dflagconstr}} ? "//@{$x->{dflagconstr}}" : "";
|
||||
my $props = join(map { "\&$_" } $x->{props});
|
||||
my $props = join('',map("\&$_", @{$x->{props}}));
|
||||
|
||||
print_outin("LINK $head->{cat}$hflagconstr $dep->{cat}$dflagconstr $x->{role} $props",$x, @agrs, @govs);
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,24 @@ enum Dir {UP=0,DOWN=1,AT_TARGET=2};
|
||||
class Boubble
|
||||
{
|
||||
public:
|
||||
Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1);
|
||||
Boubble(const char* pathstr, const char* l, int s=-1);
|
||||
// Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; };
|
||||
Boubble() {};
|
||||
Boubble(list<Role> u, list<Role> d, LongRel l, int s=-1, bool r=false);
|
||||
Boubble(const char* pathstr, const char* l, int s=-1, bool r=false);
|
||||
//Boubble(const Boubble& b) {_src=b._src; _upath=b._upath; _dpath=b._dpath; _rel=b._rel; _reverse=b._reverse; };
|
||||
|
||||
Dir dir();
|
||||
LongRel rel();
|
||||
int src();
|
||||
Dir dir() const;
|
||||
LongRel rel() const;
|
||||
int src() const;
|
||||
void src(int s);
|
||||
bool reverse() const;
|
||||
void reverse(bool b);
|
||||
|
||||
Role next();
|
||||
|
||||
Boubble* step(Role r, Dir d);
|
||||
Boubble* reversed();
|
||||
|
||||
bool is_at_target();
|
||||
bool is_at_target() const;
|
||||
|
||||
bool operator==(Boubble const& b) const;
|
||||
bool operator!=(Boubble const& b) const;
|
||||
@ -51,18 +55,20 @@ private:
|
||||
list<Role> _upath;
|
||||
list<Role> _dpath;
|
||||
LongRel _rel;
|
||||
bool _reverse;
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s) : _upath(u), _dpath(d), _rel(l), _src(s) {}
|
||||
Boubble::Boubble(list<Role> u, list<Role> d, LongRel l, int s, bool r)
|
||||
: _upath(u), _dpath(d), _rel(l), _src(s), _reverse(r) {}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
Boubble::Boubble(const char* pathstr, const char* l, int s)
|
||||
Boubble::Boubble(const char* pathstr, const char* l, int s, bool r)
|
||||
{
|
||||
Dir dir = UP;
|
||||
const char* p = pathstr;
|
||||
@ -82,12 +88,13 @@ Boubble::Boubble(const char* pathstr, const char* l, int s)
|
||||
|
||||
_rel = LongRel(l);
|
||||
_src = s;
|
||||
_reverse = r;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
Dir Boubble::dir()
|
||||
Dir Boubble::dir() const
|
||||
{
|
||||
if(!_upath.empty())
|
||||
return UP;
|
||||
@ -99,13 +106,13 @@ Dir Boubble::dir()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
LongRel Boubble::rel()
|
||||
LongRel Boubble::rel() const
|
||||
{ return _rel; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
int Boubble::src()
|
||||
int Boubble::src() const
|
||||
{ return _src; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -116,6 +123,18 @@ void Boubble::src(int s)
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
bool Boubble::reverse() const
|
||||
{ return _reverse; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
void Boubble::reverse(bool b)
|
||||
{ _reverse=b; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
Role Boubble::next()
|
||||
{
|
||||
@ -133,14 +152,14 @@ Boubble* Boubble::step(Role r, Dir d)
|
||||
{
|
||||
if(d==UP && !_upath.empty() && _upath.front() == r)
|
||||
{
|
||||
Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src);
|
||||
Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse);
|
||||
newboubble->_upath.pop_front();
|
||||
return newboubble;
|
||||
}
|
||||
|
||||
if(d==DOWN && _upath.empty() && !_dpath.empty() && _dpath.front() == r)
|
||||
{
|
||||
Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src);
|
||||
Boubble* newboubble = new Boubble(_upath,_dpath,_rel,_src,_reverse);
|
||||
newboubble->_dpath.pop_front();
|
||||
return newboubble;
|
||||
}
|
||||
@ -150,7 +169,19 @@ Boubble* Boubble::step(Role r, Dir d)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
bool Boubble::is_at_target()
|
||||
Boubble* Boubble::reversed()
|
||||
{
|
||||
Boubble* newboubble = new Boubble(_dpath,_upath,_rel,-1,!_reverse);
|
||||
newboubble->_upath.reverse();
|
||||
newboubble->_dpath.reverse();
|
||||
// cout << *this << "-----" << *newboubble << endl;
|
||||
return newboubble;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
bool Boubble::is_at_target() const
|
||||
{ return _upath.empty() && _dpath.empty(); }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -207,6 +238,8 @@ std::ostream& operator<<(std::ostream& o, const Boubble& b)
|
||||
o << ':';
|
||||
o << b._rel.str();
|
||||
o << "]";
|
||||
if(b.reverse()) o << "!";
|
||||
return o;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
204
src/dgp/dgp1.cc
204
src/dgp/dgp1.cc
@ -1,3 +1,6 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#include "dgp0.hh"
|
||||
#include "global.hh"
|
||||
|
||||
@ -78,11 +81,11 @@ int find_existing_node(int mnodeind, NodeProp p, bitset<MAXNODES>& newheadLH, bi
|
||||
if(sgraph[*ps].LH==newheadLH && sgraph[*ps].LV==newheadLV)
|
||||
{
|
||||
ret = *ps;
|
||||
// fprintf(stderr,"FIND EXISTING NODE SUCCEEDED BEACAUSE OF LH/LV equality ()\n");
|
||||
fprintf(stderr,"#\tsucceeded because of LH/LV equality ()\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// fprintf(stderr,"FIND EXISTING NODE FAILED BEACAUSE OF LH/LV inequality\n");
|
||||
fprintf(stderr,"#\tfailed beacause of LH/LV inequality\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,78 +160,72 @@ void create_reverse_links(int n)
|
||||
|
||||
//====================================================================================================
|
||||
|
||||
int create_new_head_node_left(int h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV)
|
||||
int create_new_head_node_left(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV)
|
||||
{
|
||||
int newheadind = sgraph.clone(h,newheadprop);
|
||||
// list<int>::iterator nextit=h; ++nextit;
|
||||
// nodelist.insert(nextit,newheadind);
|
||||
int newheadind = sgraph.clone(anc,prop);
|
||||
nodelist.push_back(newheadind);
|
||||
sgraph[newheadind].LH=newheadLH;
|
||||
sgraph[newheadind].LD = newheadLD;
|
||||
sgraph[newheadind].LH = LH;
|
||||
sgraph[newheadind].LD = LD;
|
||||
sgraph[newheadind].in_LH = true;
|
||||
sgraph[newheadind].LV.reset();
|
||||
|
||||
copy_links(h,newheadind);
|
||||
copy_links(anc,newheadind);
|
||||
create_reverse_links(newheadind);
|
||||
|
||||
if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h);
|
||||
if(debug) sgraph.print_node_debug(stderr,"add new",newheadind,anc);
|
||||
// if(debug) print_sets(newheadind);
|
||||
return newheadind;
|
||||
}
|
||||
|
||||
int create_new_dep_node_left(int d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV)
|
||||
int create_new_dep_node_left(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV)
|
||||
{
|
||||
int newind = sgraph.clone(d,prop);
|
||||
// list<int>::iterator nextit=d; ++nextit;
|
||||
// nodelist.insert(nextit,newind);
|
||||
int newind = sgraph.clone(anc,prop);
|
||||
nodelist.push_back(newind);
|
||||
sgraph[newind].LH.reset();
|
||||
sgraph[newind].LD=LD;
|
||||
sgraph[newind].in_LH=false; //???????
|
||||
sgraph[newind].LV.reset();
|
||||
|
||||
copy_links(d,newind);
|
||||
copy_links(anc,newind);
|
||||
create_reverse_links(newind);
|
||||
|
||||
if(debug) sgraph.print_node_debug(stderr,"C ",newind,d);
|
||||
if(debug) sgraph.print_node_debug(stderr,"add new",newind,anc);
|
||||
// if(debug) print_sets(newind);
|
||||
|
||||
return newind;
|
||||
}
|
||||
|
||||
int create_new_head_node_right(int h, NodeProp& newheadprop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV)
|
||||
int create_new_head_node_right(int anc, NodeProp& prop, bitset<MAXNODES>& newheadLH, bitset<MAXNODES>& newheadLD, bitset<MAXNODES>& newheadLV)
|
||||
{
|
||||
int newheadind = sgraph.clone(h,newheadprop);
|
||||
// list<int>::iterator nextit=h; ++nextit;
|
||||
// nodelist.insert(nextit,newheadind);
|
||||
int newheadind = sgraph.clone(anc,prop);
|
||||
nodelist.push_back(newheadind);
|
||||
sgraph[newheadind].LH=newheadLH;
|
||||
sgraph[newheadind].LD=newheadLD;
|
||||
sgraph[newheadind].in_LH=false;
|
||||
sgraph[newheadind].LV=newheadLV;
|
||||
|
||||
copy_links(h,newheadind);
|
||||
copy_links(anc,newheadind);
|
||||
create_reverse_links(newheadind);
|
||||
|
||||
if(debug) sgraph.print_node_debug(stderr,"C ",newheadind,h);
|
||||
if(debug) sgraph.print_node_debug(stderr,"add new",newheadind,anc);
|
||||
// if(debug) print_sets(newheadind);
|
||||
|
||||
return newheadind;
|
||||
}
|
||||
|
||||
int create_new_dep_node_right(int d, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV)
|
||||
int create_new_dep_node_right(int anc, NodeProp& prop, bitset<MAXNODES>& LH, bitset<MAXNODES>& LD, bitset<MAXNODES>& LV)
|
||||
{
|
||||
int newind = sgraph.clone(d,prop);
|
||||
int newind = sgraph.clone(anc,prop);
|
||||
nodelist.push_back(newind);
|
||||
sgraph[newind].LH=LH;
|
||||
sgraph[newind].LD=LD;
|
||||
sgraph[newind].in_LH=true; //???????
|
||||
sgraph[newind].LV.reset();
|
||||
|
||||
copy_links(d,newind);
|
||||
copy_links(anc,newind);
|
||||
create_reverse_links(newind);
|
||||
|
||||
if(debug) sgraph.print_node_debug(stderr,"C ",newind,d);
|
||||
if(debug) sgraph.print_node_debug(stderr,"ADD NEW",newind,anc);
|
||||
// if(debug) print_sets(newind);
|
||||
|
||||
return newind;
|
||||
@ -253,8 +250,6 @@ void connect_left(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles
|
||||
bitset<MAXNODES> newheadLV = sgraph[d].LV;
|
||||
bitset<MAXNODES> newheadLD = sgraph[h].LD;
|
||||
|
||||
// vector<int> newedge;
|
||||
|
||||
newheadind = find_existing_node(sgraph[h].mnode, newheadprop, newheadLH, newheadLV);
|
||||
if( newheadind >= 0) // W£¡CZONE
|
||||
sgraph[newheadind].LD |= newheadLD;
|
||||
@ -301,10 +296,10 @@ void connect_left(int h, int d, const Link& l, list<Boubble*>& new_head_boubbles
|
||||
sgraph[newheadind].LD.set(d);
|
||||
if(sgraph[d].saturated()) sgraph[newheadind].LD |= sgraph[d].LD;
|
||||
|
||||
if(debug) sgraph.print_arc(stderr,newheadind,d,l.role,0);
|
||||
if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h);
|
||||
if(debug) sgraph.print_arc(stderr,"new link",newheadind,d,l.role,0);
|
||||
if(debug) sgraph.print_node_debug(stderr,"update",newheadind,h);
|
||||
// if(debug) print_sets(newheadind);
|
||||
if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d);
|
||||
if(debug) sgraph.print_node_debug(stderr,"update",newdepind,d);
|
||||
// if(debug) print_sets(newdepind);
|
||||
}
|
||||
|
||||
@ -379,26 +374,105 @@ void connect_right(int h, int d, const Link& l, list<Boubble*>& new_head_boubble
|
||||
|
||||
if(sgraph[newheadind].saturated()) sgraph[newdepind].LH |= sgraph[newheadind].LH;
|
||||
|
||||
if(debug) sgraph.print_arc(stderr,newheadind,newdepind,l.role,1);
|
||||
if(debug) sgraph.print_node_debug(stderr,"U ",newheadind,h);
|
||||
if(debug) sgraph.print_node_debug(stderr,"U ",newdepind,d);
|
||||
if(debug) sgraph.print_arc(stderr,"new link",newheadind,newdepind,l.role,1);
|
||||
if(debug) sgraph.print_node_debug(stderr,"update",newheadind,h);
|
||||
if(debug) sgraph.print_node_debug(stderr,"update",newdepind,d);
|
||||
|
||||
}
|
||||
|
||||
//====================================================================================================
|
||||
|
||||
// bool check_meeting_boubles(list<Boubble*>& hboubbles, list<Boubble*>& dboubbles)
|
||||
// {
|
||||
// bool hremove=false; // czy usun±æ ostatnio sprawdzany b±bel
|
||||
// bool dremove=false; // czy usun±æ ostatnio sprawdzany b±bel
|
||||
|
||||
// for(list<Boubble*>::iterator hb = hboubbles.begin(); hb != hboubbles.end(); hb = hremove ? hboubbles.erase(hb) : ++hb )
|
||||
// {
|
||||
// hremove=false;
|
||||
// for(list<Boubble*>::iterator db = dboubbles.begin(); db != dboubbles.end(); db = dremove ? dboubbles.erase(db) : ++db )
|
||||
// {
|
||||
// dremove=false;
|
||||
// if( (*hb)->rel()==(*db)->rel() && (*hb)->dir()==DOWN && (*db)->dir()==UP && (*hb)->reverse()!=(*db)->reverse() )
|
||||
// {
|
||||
// int srcnode,dstnode;
|
||||
// if( (*hb)->reverse()==false )
|
||||
// srcnode = (*hb)->src(), dstnode = (*db)->src();
|
||||
// else
|
||||
// srcnode = (*db)->src(), dstnode = (*hb)->src();
|
||||
// if( grammar.check_longrel(sgraph.cat(srcnode), sgraph.cat(dstnode), (*hb)->rel()) )
|
||||
// {
|
||||
// hremove=dremove=true;
|
||||
// if(debug) fprintf(stderr,"BOUBBLES MET!!!\n");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(debug) fprintf(stderr,"BOUBBLES' MEETING FAILED!!!\n");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
//====================================================================================================
|
||||
|
||||
bool check_meeting_boubles(list<Boubble*>& boubbles)
|
||||
{
|
||||
bool hremove=false; // czy usun±æ ostatnio sprawdzany b±bel
|
||||
bool dremove=false; // czy usun±æ ostatnio sprawdzany b±bel
|
||||
|
||||
for(list<Boubble*>::iterator hb = boubbles.begin(); hb != boubbles.end(); hb = hremove ? boubbles.erase(hb) : ++hb )
|
||||
{
|
||||
cout << endl << "hb:" << **hb ;
|
||||
hremove=false;
|
||||
for(list<Boubble*>::iterator db = hb; db != boubbles.end(); db = dremove ? boubbles.erase(db) : ++db )
|
||||
{
|
||||
cout << " db:" << **db;
|
||||
dremove=false;
|
||||
if( (*hb)->rel()==(*db)->rel() && (*hb)->reverse()!=(*db)->reverse() )
|
||||
{
|
||||
cout << "Z";
|
||||
int srcnode,dstnode;
|
||||
if( (*hb)->reverse()==false )
|
||||
srcnode = (*hb)->src(), dstnode = (*db)->src();
|
||||
else
|
||||
srcnode = (*db)->src(), dstnode = (*hb)->src();
|
||||
if( grammar.check_longrel(sgraph.cat(srcnode), sgraph.cat(dstnode), (*hb)->rel()) )
|
||||
{
|
||||
cout << " REMOVE ";
|
||||
hremove=dremove=true;
|
||||
if(debug) fprintf(stderr,"BOUBBLES MET!!!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << " FAIL ";
|
||||
if(debug) fprintf(stderr,"BOUBBLES' MEETING FAILED!!!\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//====================================================================================================
|
||||
|
||||
// sprawdza czy te, spo¶ród b±bli, które dotar³y do celu node
|
||||
// daj± wynik prawdziwy, dodatkowo - usuwa je z listy boubbles
|
||||
|
||||
bool check_boubbles_at_target(list<Boubble*>& boubbles, int node)
|
||||
{
|
||||
list<Boubble*>::iterator last; // ostatnio sprawdzany b±bel
|
||||
bool remove=false; // czy usun±æ ostatnio sprawdzany b±bel
|
||||
|
||||
for(list<Boubble*>::iterator b = boubbles.begin(); b != boubbles.end(); b = remove ? boubbles.erase(b) : ++b )
|
||||
if( (*b)->is_at_target() )
|
||||
if( grammar.check_longrel(sgraph.cat((*b)->src()), sgraph.cat(node), (*b)->rel()) )
|
||||
{
|
||||
cout << endl << "REMOVE ChBatT " << **b << endl;
|
||||
remove=true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
else
|
||||
@ -411,14 +485,15 @@ bool check_boubbles_at_target(list<Boubble*>& boubbles, int node)
|
||||
|
||||
void try_connect_dependents(int j)
|
||||
{
|
||||
// for(list<int>::iterator i(j); i!=nodelist.begin(); --i)
|
||||
// if(sgraph.visible(*i,*j) && sgraph.saturated(*i))
|
||||
LViterator lvi(sgraph,j);
|
||||
int i;
|
||||
while((i=lvi.next()) >= 0)
|
||||
{
|
||||
//if(debug) sgraph.print_node_debug(stderr,"D-CUR>",i,-1);
|
||||
|
||||
if(sgraph.saturated(i))
|
||||
{
|
||||
if(debug) {fprintf(stderr,"## %d <-- %d ... ",i,j); }
|
||||
if(debug) {fprintf(stderr,"%d <--",i); }
|
||||
|
||||
list<const Link*> ji_links = grammar.connectable2( sgraph.cat(j), sgraph.cat(i), sgraph[j].prop.flags, sgraph[i].prop.flags); // ref do Roles!!!
|
||||
list<const Link*>::iterator ri = ji_links.begin();
|
||||
@ -426,39 +501,45 @@ void try_connect_dependents(int j)
|
||||
else
|
||||
{
|
||||
for(; ri != ji_links.end(); ++ri )
|
||||
{
|
||||
if(debug) fprintf(stderr," %s",(*ri)->role.str());
|
||||
if(!grammar.check_constr2(sgraph[j].prop,sgraph[i].prop,0,**ri ))
|
||||
{ if(debug) fprintf(stderr,"constraints failed\n"); }
|
||||
{ if(debug) fprintf(stderr," ...constraints failed\n"); }
|
||||
else
|
||||
{
|
||||
list<Boubble*> new_head_boubbles = collect_head_boubbles(j,i,(*ri)->role);
|
||||
list<Boubble*> new_dep_boubbles = collect_dep_boubbles(j,i,(*ri)->role);
|
||||
|
||||
if( !(check_boubbles_at_target(new_head_boubbles,j) && check_boubbles_at_target(new_dep_boubbles,i)) )
|
||||
{ if(debug) fprintf(stderr,"boubbles failed\n"); }
|
||||
else
|
||||
if( check_meeting_boubles(new_head_boubbles) &&
|
||||
check_meeting_boubles(new_dep_boubbles) &&
|
||||
check_boubbles_at_target(new_head_boubbles,j) &&
|
||||
check_boubbles_at_target(new_dep_boubbles,i) )
|
||||
{
|
||||
if(debug) fprintf(stderr,"success\n");
|
||||
if(debug) fprintf(stderr," ...SUCCESS!\n");
|
||||
connect_left( j, i, **ri, new_head_boubbles, new_dep_boubbles);
|
||||
}
|
||||
else
|
||||
{ if(debug) fprintf(stderr," ...boubbles failed\n"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if(debug) {fprintf(stderr,"%d <-- unsaturated\n",i); }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
void try_connect_heads(int j)
|
||||
{
|
||||
// for(list<int>::iterator i(j); i!=nodelist.begin(); --i)
|
||||
// if(sgraph.visible(*i,*j) && sgraph.saturated(*j))
|
||||
|
||||
LViterator lvi(sgraph,j);
|
||||
int i;
|
||||
while((i=lvi.next()) >= 0)
|
||||
{
|
||||
// if(debug) sgraph.print_node_debug(stderr,"H-CUR> ",i,-1);
|
||||
if(sgraph.saturated(j))
|
||||
{
|
||||
if(debug) fprintf(stderr, "## %d --> %d ... ",i,j);
|
||||
if(debug) fprintf(stderr, "%d -->",i);
|
||||
|
||||
list<const Link*> ij_links = grammar.connectable2( sgraph.cat(i), sgraph.cat(j), sgraph[i].prop.flags, sgraph[j].prop.flags );
|
||||
list<const Link*>::iterator ri = ij_links.begin();
|
||||
@ -466,24 +547,33 @@ void try_connect_heads(int j)
|
||||
else
|
||||
{
|
||||
for(; ri != ij_links.end(); ++ri )
|
||||
{
|
||||
if(debug) fprintf(stderr," %s",(*ri)->role.str());
|
||||
if( !grammar.check_constr2( sgraph[i].prop, sgraph[j].prop, 1, **ri ) )
|
||||
{ if(debug) fprintf(stderr,"constraints failed\n"); }
|
||||
{ if(debug) fprintf(stderr," ...constraints failed\n"); }
|
||||
else
|
||||
{
|
||||
list<Boubble*> new_head_boubbles = collect_head_boubbles(i,j,(*ri)->role);
|
||||
list<Boubble*> new_dep_boubbles = collect_dep_boubbles(i,j,(*ri)->role);
|
||||
|
||||
if( !(check_boubbles_at_target(new_head_boubbles,i) && check_boubbles_at_target(new_dep_boubbles,j)) )
|
||||
{ if(debug) fprintf(stderr,"boubbles failed\n"); }
|
||||
else
|
||||
if( check_meeting_boubles(new_head_boubbles) &&
|
||||
check_meeting_boubles(new_dep_boubbles) &&
|
||||
check_boubbles_at_target(new_head_boubbles,i) &&
|
||||
check_boubbles_at_target(new_dep_boubbles,j) )
|
||||
{
|
||||
if(debug) fprintf(stderr,"success\n");
|
||||
if(debug) fprintf(stderr," ...SUCCESS!\n");
|
||||
connect_right( i, j, **ri, new_head_boubbles, new_dep_boubbles );
|
||||
}
|
||||
else
|
||||
{ if(debug) fprintf(stderr," ...bubbles failed\n",i); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if(debug) {fprintf(stderr,"%d <-- unsaturated\n",j); }
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================================================
|
||||
|
||||
@ -570,13 +660,13 @@ void dgp1()
|
||||
set_initial_constraints(basenode);
|
||||
nodelist.push_back(basenode);
|
||||
|
||||
if(debug) sgraph.print_node_debug(stderr,"B ",basenode,-1); // STDOUT!!!
|
||||
if(debug) print_sets(basenode);
|
||||
if(debug) sgraph.print_node_debug(stderr,"add base",basenode,-1); // STDOUT!!!
|
||||
// if(debug) print_sets(basenode);
|
||||
|
||||
list<int>::iterator cursor=processed;
|
||||
while(++cursor != nodelist.end())
|
||||
{
|
||||
if(debug) sgraph.print_node_debug(stderr,"> ",*cursor,-1);
|
||||
if(debug) sgraph.print_node_debug(stderr,"MAIN-CUR> ",*cursor,-1);
|
||||
try_connect_dependents(*cursor);
|
||||
try_connect_heads(*cursor);
|
||||
processed=cursor;
|
||||
|
@ -125,7 +125,8 @@ private:
|
||||
void add_category(const char* s);
|
||||
void add_type(const char* s);
|
||||
void add_flag(const char* s) { Flag::add(s); }
|
||||
void add_long(const char* l, const char* p) { LongRel::add(l); boubbles.push_back( new Boubble(p,l) ); }
|
||||
void add_long(const char* l, const char* p) { LongRel::add(l); boubbles.push_back( new Boubble(p,l) );
|
||||
boubbles.push_back( (new Boubble(p,l))->reversed() ); }
|
||||
void add_triggers(Cat h, Cat d, LongRel l);
|
||||
|
||||
void set_sgl(Role r) { sgl.set(r); }
|
||||
|
@ -29,6 +29,8 @@ int SGraph::add_base_snode(int mnodeind)
|
||||
|
||||
newnode.edge.push_back(lastnodeind());
|
||||
|
||||
newnode.edge_contains_self = true ;
|
||||
|
||||
return lastnodeind();
|
||||
}
|
||||
|
||||
@ -84,12 +86,12 @@ int SGraph::print_node_debug(FILE* f, const char* pref, int n, int anc)
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
void SGraph::print_arc(FILE* f, int head, int dep, Role role, int dir) // 0 - left, 1 - right
|
||||
void SGraph::print_arc(FILE* f, const char* msg, int head, int dep, Role role, int dir) // 0 - left, 1 - right
|
||||
{
|
||||
if(dir==0)
|
||||
fprintf(f,"#A %s:%d <-- %d\n", role.str(), dep, head);
|
||||
fprintf(f,"%s %s:%d <-- %d\n", msg, role.str(), dep, head);
|
||||
else
|
||||
fprintf(f,"#A %s:%d --> %d\n", role.str(), head, dep);
|
||||
fprintf(f,"%s %s:%d --> %d\n", msg, role.str(), head, dep);
|
||||
}
|
||||
|
||||
//====================================================================================================
|
||||
@ -112,20 +114,13 @@ int SGraph::sprint_node(char* buf, int nodeind, int anc, unsigned int info)
|
||||
if (info&HEADS)
|
||||
for(vector<Arc>::iterator h=node.heads.begin(); h!=node.heads.end(); ++h)
|
||||
{
|
||||
// if(cont) buf+=sprintf(buf,","); else cont=true;
|
||||
buf+=sprintf(buf,"(++%s:%d)",h->role.str(),h->dst);
|
||||
// buf+=sprintf(buf,"++%s-%d(%d~%d)",h->role.str(),h->dst,h->headanc,h->depanc);
|
||||
// buf+=sprintf(buf,"(<-%s-%d)",h->role.str(),h->dst);
|
||||
}
|
||||
|
||||
if (info&DEPS)
|
||||
for(vector<Arc>::iterator d=node.deps.begin(); d!=node.deps.end(); ++d)
|
||||
{
|
||||
// if(! nodes[d->dst].saturated()) continue; // NIE DRUKUJ NIENASYCONYCH PODRZEDNIKOW
|
||||
// if(cont) buf+=sprintf(buf,","); else cont=true;
|
||||
buf+=sprintf(buf,"(--%s:%d)",d->role.str(),d->dst);
|
||||
// buf+=sprintf(buf,"--%s-%d(%d~%d)",d->role.str(),d->dst,d->headanc,d->depanc);
|
||||
// buf+=sprintf(buf,"(-%s->%d)",d->role.str(),d->dst);
|
||||
}
|
||||
|
||||
if (info&SETS)
|
||||
@ -176,15 +171,16 @@ int SGraph::sprint_node(char* buf, int nodeind, int anc, unsigned int info)
|
||||
int SGraph::sprint_node_debug(char* buf, const char* pref, int n, int anc)
|
||||
{
|
||||
char *buf0 = buf;
|
||||
buf+=sprintf(buf,"#%s",pref);
|
||||
|
||||
buf+=sprintf(buf,"%-16s",form(n));
|
||||
|
||||
buf+=sprintf(buf,"%-10s",pref);
|
||||
buf+=sprintf(buf,"%d.%s",n,form(n));
|
||||
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|SETS|CONSTRAINTS);
|
||||
|
||||
buf+=sprintf(buf,"/");
|
||||
for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ )
|
||||
buf += sprintf(buf,"%d ", *e);
|
||||
// buf+=sprintf(buf,"/");
|
||||
// for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ )
|
||||
// buf += sprintf(buf,"%d ", *e);
|
||||
|
||||
buf+=sprintf(buf,"\n");
|
||||
return buf-buf0;
|
||||
|
@ -227,7 +227,7 @@ public:
|
||||
int print_node(FILE* f, int n, unsigned int info);
|
||||
int print_node_debug(FILE* f, const char* pref, int n, int anc);
|
||||
|
||||
void print_arc(FILE* f, int left, int right, Role role, int dir); // 0 - left, 1 - right
|
||||
void print_arc(FILE* f, const char* msg, int left, int right, Role role, int dir); // 0 - left, 1 - right
|
||||
|
||||
//private:
|
||||
|
||||
@ -326,11 +326,6 @@ inline LViterator::LViterator(SGraph& sg, int n, bool s=true) : sgraph(sg), mgra
|
||||
}
|
||||
|
||||
}
|
||||
// if(!strict)
|
||||
// {
|
||||
// push_ld(n);
|
||||
// push_ln(n);
|
||||
// }
|
||||
}
|
||||
|
||||
inline int LViterator::next()
|
||||
|
Loading…
Reference in New Issue
Block a user