link-grammar-5.8.0/link-grammar/post-process/constituents.c
/******************************************************
 * These functions are called once, after constituents
 * have been generated, to merge them together and fix up
 * some other things.
 *
 ********************************************************/
These functions are called once, after constituents
have been generated, to merge them together and fix up
some other things.
These functions are called once after constituents have been generated to merge them together and fix up some other things .
static int merge_constituents(con_context_t *ctxt, Linkage linkage, int numcon_total)
{
	int c1, c2=0;
	for (c1 = 0; c1 < numcon_total; c1++)
	{
		ctxt->constituent[c1].valid = true;
		ctxt->constituent[c1].canon = c1;
		for (c2 = c1 + 1; c2 < numcon_total; c2++)
		{
			if ((ctxt->constituent[c1].left == ctxt->constituent[c2].left) &&
				(ctxt->constituent[c1].right == ctxt->constituent[c2].right) &&
				(strcmp(ctxt->constituent[c1].type, ctxt->constituent[c2].type) == 0))
			{
				ctxt->constituent[c2].canon = c1;
			}
		}
	}
	for (c1 = 0; c1 < numcon_total; c1++)
	{
		for (c2 = c1 + 1; c2 < numcon_total; c2++)
		{
			if (ctxt->constituent[c2].canon == ctxt->constituent[c1].canon)
				ctxt->constituent[c2].valid = false;
		}
	}
	return numcon_total;
}
static int merge_constituents ( con_context_t * ctxt , Linkage linkage , int numcon_total ) { int c1 , c2 = 0 ; for ( c1 = 0 ; c1 < numcon_total ; c1 ++ ) { ctxt -> constituent [ c1 ] . valid = true ; ctxt -> constituent [ c1 ] . canon = c1 ; for ( c2 = c1 + 1 ; c2 < numcon_total ; c2 ++ ) { if ( ( ctxt -> constituent [ c1 ] . left == ctxt -> constituent [ c2 ] . left ) && ( ctxt -> constituent [ c1 ] . right == ctxt -> constituent [ c2 ] . right ) && ( strcmp ( ctxt -> constituent [ c1 ] . type , ctxt -> constituent [ c2 ] . type ) == 0 ) ) { ctxt -> constituent [ c2 ] . canon = c1 ; } } } for ( c1 = 0 ; c1 < numcon_total ; c1 ++ ) { for ( c2 = c1 + 1 ; c2 < numcon_total ; c2 ++ ) { if ( ctxt -> constituent [ c2 ] . canon == ctxt -> constituent [ c1 ] . canon ) ctxt -> constituent [ c2 ] . valid = false ; } } return numcon_total ; }
These functions are called once, after constituents
 have been generated, to merge them together and fix up
 some other things.
These functions are called once after constituents have been generated to merge them together and fix up some other things .
/* First go through and give each constituent a canonical number
	   (the index number of the lowest-numbered constituent
	   identical to it) */ /* Now go through and find duplicates; if a pair is found,
	 * mark one as invalid.
	 */