link-grammar-5.8.0/link-grammar/tokenize/wordgraph.c
/**
 * Insert the gword into the path queue in reverse order of its hier_depth.
 *
 * The deepest wordgraph alternatives must be scanned first.
 * Otherwise, this sentence causes a flattening mess:
 * "T" this is a flattening test
 * (The mess depends on both "T" and "T matching EMOTICON, and any
 * 5 words after "T".)
 *
 * Parameters:
 *   same_word: mark that the same word is queued again.
 * For validation code only (until the wordgraph version is mature):
 *   used: mark that the word has already been issued into the 2D-array.
 *   diff_alternative: validate we don't queue words from the same alternative.
 */
Insert the gword into the path queue in reverse order of its hier_depth.
The deepest wordgraph alternatives must be scanned first.

mark that the same word is queued again.
For validation code only (until the wordgraph version is mature):
used: mark that the word has already been issued into the 2D-array.
diff_alternative: validate we don't queue words from the same alternative.
Insert the gword into the path queue in reverse order of its hier_depth . The deepest wordgraph alternatives must be scanned first . mark that the same word is queued again . For validation code only ( until the wordgraph version is mature ) : used : mark that the word has already been issued into the 2D - array . diff_alternative : validate we don ' t queue words from the same alternative .
bool wordgraph_pathpos_add(Wordgraph_pathpos **wp, Gword *p, bool used,
                              bool same_word, bool diff_alternative)
{
	size_t n = wordgraph_pathpos_len(*wp);
	Wordgraph_pathpos *wpt;
	size_t insert_here = n;
	assert(NULL != p);
#ifdef DEBUG
	if (verbosity_level(+9)) print_hier_position(p);
#endif
	if (NULL != *wp)
	{
		for (wpt = *wp; NULL != wpt->word; wpt++)
		{
			if (p == wpt->word)
				return false; 
			if ((n == insert_here) && (p->hier_depth >= wpt->word->hier_depth))
				insert_here = wpt - *wp;
			if (diff_alternative)
			{
				assert(same_word||wpt->same_word||!in_same_alternative(p,wpt->word),
				       "wordgraph_pathpos_add(): "
				       "Word%zu '%s' is from same alternative of word%zu '%s'",
				       p->node_num, p->subword,
				       wpt->word->node_num, wpt->word->subword);
			}
		}
	}
	*wp = wordgraph_pathpos_resize(*wp, n+1);
	if (insert_here < n)
	{
		memmove(&(*wp)[insert_here+1], &(*wp)[insert_here],
		        (n+1 - insert_here) * sizeof (*wpt));
	}
	(*wp)[insert_here].word = p;
	(*wp)[insert_here].same_word = same_word;
	(*wp)[insert_here].used = used;
	(*wp)[insert_here].next_ok = false;
	return true;
}
bool wordgraph_pathpos_add ( Wordgraph_pathpos * * wp , Gword * p , bool used , bool same_word , bool diff_alternative ) { size_t n = wordgraph_pathpos_len ( * wp ) ; Wordgraph_pathpos * wpt ; size_t insert_here = n ; assert ( NULL != p ) ; #ifdef DEBUG if ( verbosity_level ( +9 ) ) print_hier_position ( p ) ; #endif if ( NULL != * wp ) { for ( wpt = * wp ; NULL != wpt -> word ; wpt ++ ) { if ( p == wpt -> word ) return false ; if ( ( n == insert_here ) && ( p -> hier_depth >= wpt -> word -> hier_depth ) ) insert_here = wpt - * wp ; if ( diff_alternative ) { assert ( same_word || wpt -> same_word || ! in_same_alternative ( p , wpt -> word ) , " " " " , p -> node_num , p -> subword , wpt -> word -> node_num , wpt -> word -> subword ) ; } } } * wp = wordgraph_pathpos_resize ( * wp , n + 1 ) ; if ( insert_here < n ) { memmove ( & ( * wp ) [ insert_here + 1 ] , & ( * wp ) [ insert_here ] , ( n + 1 - insert_here ) * sizeof ( * wpt ) ) ; } ( * wp ) [ insert_here ] . word = p ; ( * wp ) [ insert_here ] . same_word = same_word ; ( * wp ) [ insert_here ] . used = used ; ( * wp ) [ insert_here ] . next_ok = false ; return true ; }
Insert the gword into the path queue in reverse order of its hier_depth.
Insert the gword into the path queue in reverse order of its hier_depth .
/* already in the pathpos queue - nothing to do */ /* Insert in reverse order of hier_depth. */ /* Validate that there are no words in the pathpos queue from the same
			 * alternative. This can be commented out when the wordgraph code is
			 * mature. FIXME */ /* n+1 because n is the length of the array, not including the
		 * terminating null entry. We need to protect the terminating null.
		 */