link-grammar-5.8.0/link-grammar/linkage/linkage.c
/*
 * Remap the link array according to discarded links and words.
 *
 * The remap[] elements indicate the new WordIdx of the word.
 * A value which is -1 indicates a discarded word.
 * A NULL link_name indicates a discarded link.
 */
Remap the link array according to discarded links and words.
The remap[] elements indicate the new WordIdx of the word.
A value which is -1 indicates a discarded word.
A NULL link_name indicates a discarded link.
Remap the link array according to discarded links and words . The remap [] elements indicate the new WordIdx of the word . A value which is - 1 indicates a discarded word . A NULL link_name indicates a discarded link .
static void remap_linkages(Linkage lkg, const int *remap)
{
	LinkIdx i, j;
	for (i = 0, j = 0; i < lkg->num_links; i++)
	{
		Link *old_lnk = &lkg->link_array[i];
		if (NULL != old_lnk->link_name &&  
		   (-1 != remap[old_lnk->rw]) && (-1 != remap[old_lnk->lw]))
		{
			Link *new_lnk = &lkg->link_array[j];
			Connector *ctmp;
			new_lnk->lw = remap[old_lnk->lw];
			new_lnk->rw = remap[old_lnk->rw];
			ctmp = new_lnk->lc;
			new_lnk->lc = old_lnk->lc;
			old_lnk->lc = ctmp;
			ctmp = new_lnk->rc;
			new_lnk->rc = old_lnk->rc;
			old_lnk->rc = ctmp;
			new_lnk->link_name = old_lnk->link_name;
			j++;
		}
	}
	lkg->num_links = j;
}
static void remap_linkages ( Linkage lkg , const int * remap ) { LinkIdx i , j ; for ( i = 0 , j = 0 ; i < lkg -> num_links ; i ++ ) { Link * old_lnk = & lkg -> link_array [ i ] ; if ( NULL != old_lnk -> link_name && ( -1 != remap [ old_lnk -> rw ] ) && ( -1 != remap [ old_lnk -> lw ] ) ) { Link * new_lnk = & lkg -> link_array [ j ] ; Connector * ctmp ; new_lnk -> lw = remap [ old_lnk -> lw ] ; new_lnk -> rw = remap [ old_lnk -> rw ] ; ctmp = new_lnk -> lc ; new_lnk -> lc = old_lnk -> lc ; old_lnk -> lc = ctmp ; ctmp = new_lnk -> rc ; new_lnk -> rc = old_lnk -> rc ; old_lnk -> rc = ctmp ; new_lnk -> link_name = old_lnk -> link_name ; j ++ ; } } lkg -> num_links = j ; }
Remap the link array according to discarded links and words.
Remap the link array according to discarded links and words .
/* discarded link */ /* Copy the entire link contents, thunking the word numbers.
			 * Note that j is always <= i so this is always safe. */ /* Unused memory not freed - all of it will be freed in free_linkages(). */