link-grammar-5.8.0/link-grammar/parse/prune.c
/**
 * Find if the sentence contains more than pc->null_links nulls.
 * This function is called when we know that the gap (w1, w2) creates one
 * or more null links. Only non-optional words are counted here (optional
 * words are always allowed to be null-linked).
 *
 * Algo: First determine null_allowed - the number of nulls which is
 * allowed in the gap. If the gap includes more than null_allowed nulls
 * this implies that the sentence would include more than the desired null
 * links (pc->null_links) so true is returned to signify that the proposed
 * link cannot be done.
 * If islands_ok==true, the whole gap may be one island, so it is counted
 * only as a single null. Also, since only null words are counted here,
 * the number of the total null links may be under-estimated (efficiency
 * effect only).
 * Note: Existing null words in the gap are just skipped as they have
 * already taken into account in null_allowed.
 *
 * @return \c true only if the sentence contains more than pc->null_links
 * nulls. With \c islands_ok=true, \c false may still be returned in that
 * case because only null words are counted here.
 */
Find if the sentence contains more than pc->null_links nulls.
This function is called when we know that the gap (w1, w2) creates one
or more null links. Only non-optional words are counted here (optional
words are always allowed to be null-linked).

First determine null_allowed - the number of nulls which is
allowed in the gap. If the gap includes more than null_allowed nulls
this implies that the sentence would include more than the desired null
links (pc->null_links) so true is returned to signify that the proposed
link cannot be done.
If islands_ok==true, the whole gap may be one island, so it is counted
only as a single null. Also, since only null words are counted here,
the number of the total null links may be under-estimated (efficiency
effect only).
Note: Existing null words in the gap are just skipped as they have
already taken into account in null_allowed.

@return \c true only if the sentence contains more than pc->null_links
nulls. With \c islands_ok=true, \c false may still be returned in that
case because only null words are counted here.
Find if the sentence contains more than pc - > null_links nulls . This function is called when we know that the gap ( w1 w2 ) creates one or more null links . Only non - optional words are counted here ( optional words are always allowed to be null - linked ) . First determine null_allowed - the number of nulls which is allowed in the gap . If the gap includes more than null_allowed nulls this implies that the sentence would include more than the desired null links ( pc - > null_links ) so true is returned to signify that the proposed link cannot be done . If islands_ok == true the whole gap may be one island so it is counted only as a single null . Also since only null words are counted here the number of the total null links may be under - estimated ( efficiency effect only ) . Note : Existing null words in the gap are just skipped as they have already taken into account in null_allowed . @return \ c true only if the sentence contains more than pc - > null_links nulls . With \ c islands_ok = true \ c false may still be returned in that case because only null words are counted here .
static bool more_nulls_than_allowed(prune_context *pc, int w1, int w2)
{
	int null_allowed = pc->null_links - pc->null_words;
	if (pc->islands_ok)
	{
		if (null_allowed > 0) return false;
	}
	else
	{
		if (null_allowed > w2 - w1 - 1) return false;
	}
	for (int w = w1+1; w < w2; w++)
	{
		if (pc->sent->word[w].optional) continue;
		if (pc->is_null_word[w]) continue;
		if (null_allowed == 0) return true;
		null_allowed--;
	}
	return false;
}
static bool more_nulls_than_allowed ( prune_context * pc , int w1 , int w2 ) { int null_allowed = pc -> null_links - pc -> null_words ; if ( pc -> islands_ok ) { if ( null_allowed > 0 ) return false ; } else { if ( null_allowed > w2 - w1 - 1 ) return false ; } for ( int w = w1 + 1 ; w < w2 ; w ++ ) { if ( pc -> sent -> word [ w ] . optional ) continue ; if ( pc -> is_null_word [ w ] ) continue ; if ( null_allowed == 0 ) return true ; null_allowed -- ; } return false ; }
Find if the sentence contains more than pc->null_links nulls.
Find if the sentence contains more than pc - > null_links nulls .