link-grammar-5.8.0/link-grammar/parse/prune.c
/**
 * This takes two connectors (and the two words that these came from) and
 * returns TRUE if it is possible for these two to match based on local
 * considerations.
 */
This takes two connectors (and the two words that these came from) and
returns TRUE if it is possible for these two to match based on local
considerations.
This takes two connectors ( and the two words that these came from ) and returns TRUE if it is possible for these two to match based on local considerations .
static bool possible_connection(prune_context *pc,
                                Connector *lc, Connector *rc,
                                int lword, int rword)
{
	int dist = rword - lword;
#ifdef DEBUG
	assert(0 < dist, "Bad word order in possible connection.");
#endif
	if (!lc_easy_match(lc->desc, rc->desc)) return false;
	if ((lc->nearest_word > rword) || (rc->nearest_word < lword)) return false;
	if (1 == dist)
	{
		if ((lc->next != NULL) || (rc->next != NULL))
			return false;
		return true;
	}
	if ((rword > lc->farthest_word) || (lword < rc->farthest_word))
		return false;
	if ((lc->next == NULL) && (rc->next == NULL) &&
	    (!lc->multi || (lc->nearest_word == rword)) &&
	    (!rc->multi || (rc->nearest_word == lword)) &&
	    more_nulls_than_allowed(pc, lword, rword))
	{
		return false;
	}
	if ((lc->next != NULL) && (rc->next != NULL))
	{
		if (lc->next->nearest_word > rc->next->nearest_word)
			return false; 
	}
	if (is_cross_mlink(pc, lc, rc, lword, rword))
		return false;
	return true;
}
static bool possible_connection ( prune_context * pc , Connector * lc , Connector * rc , int lword , int rword ) { int dist = rword - lword ; #ifdef DEBUG assert ( 0 < dist , " " ) ; #endif if ( ! lc_easy_match ( lc -> desc , rc -> desc ) ) return false ; if ( ( lc -> nearest_word > rword ) || ( rc -> nearest_word < lword ) ) return false ; if ( 1 == dist ) { if ( ( lc -> next != NULL ) || ( rc -> next != NULL ) ) return false ; return true ; } if ( ( rword > lc -> farthest_word ) || ( lword < rc -> farthest_word ) ) return false ; if ( ( lc -> next == NULL ) && ( rc -> next == NULL ) && ( ! lc -> multi || ( lc -> nearest_word == rword ) ) && ( ! rc -> multi || ( rc -> nearest_word == lword ) ) && more_nulls_than_allowed ( pc , lword , rword ) ) { return false ; } if ( ( lc -> next != NULL ) && ( rc -> next != NULL ) ) { if ( lc -> next -> nearest_word > rc -> next -> nearest_word ) return false ; } if ( is_cross_mlink ( pc , lc , rc , lword , rword ) ) return false ; return true ; }
This takes two connectors (and the two words that these came from) and
 returns TRUE if it is possible for these two to match based on local
 considerations.
This takes two connectors ( and the two words that these came from ) and returns TRUE if it is possible for these two to match based on local considerations .
/* Word range constraints. */ /* We arrive here if the words are NOT next to each other. Say the
	 * gap between them contains W non-optional words. We also know
	 * that we are going to parse with N null-links (which involves
	 * sub-parsing with the range of [0, N] null-links).
	 * If there is not at least one intervening connector that can
	 * connect to an intermediate word, then:
	 * islands_ok=false:
	 * There will be W null-linked words, and W must be <= N.
	 * islands_ok=true:
	 * There will be at least one island.
	 */ /* Cross link. */