link-grammar-5.8.0/link-grammar/dict-common/print-dict.c
/**
 * Display the information about the given word.
 * If the word can split, display the information about each part.
 * Note that the splits may be invalid grammatically.
 *
 * Wild-card search is supported; the command-line user can type in !!word* or
 * !!word*.sub and get a list of all words that match up to the wild-card.
 * In this case no split is done.
 *
 * @arg arg[0] specifies the display type. If it is equal to &do_display_expr
 * than this is request to display expressions. Else it is a request to
 * display disjuncts. arg[2] specifies the request flags.
 */
Display the information about the given word.
If the word can split, display the information about each part.
Note that the splits may be invalid grammatically.

Wild-card search is supported; the command-line user can type in !!word* or
word*.sub and get a list of all words that match up to the wild-card.
In this case no split is done.

@arg arg[0] specifies the display type. If it is equal to &do_display_expr
than this is request to display expressions. Else it is a request to
display disjuncts. arg[2] specifies the request flags.
Display the information about the given word . If the word can split display the information about each part . Note that the splits may be invalid grammatically . Wild - card search is supported ; the command - line user can type in !!word * or word * . sub and get a list of all words that match up to the wild - card . In this case no split is done . @arg arg [ 0 ] specifies the display type . If it is equal to &do_display_expr than this is request to display expressions . Else it is a request to display disjuncts . arg [ 2 ] specifies the request flags .
static char *display_word_split(Dictionary dict,
               const char * word, Parse_Options opts,
               char * (*display)(Dictionary, const char *, const void **),
               const char **arg)
{
	Sentence sent;
	if ('\0' == *word) return NULL; 
	char *pword = strdupa(word);
	patch_subscript(pword);
	dyn_str *s = dyn_str_new();
	int spell_option = parse_options_get_spell_guess(opts);
	parse_options_set_spell_guess(opts, 0);
	sent = sentence_create(pword, dict);
	if (pword[0] == '<' && (strchr(pword, '>') != NULL) &&
	    ((strchr(pword, '>')[1] == '\0') ||
	     (strchr(pword, '>')[1] == SUBSCRIPT_MARK)))
	{
		if (!word0_set(sent, pword, opts)) goto display_word_split_error;
	}
	else
	{
		if (0 != sentence_split(sent, opts)) goto display_word_split_error;
	}
	print_sentence_word_alternatives(s, sent, false, NULL, NULL, NULL);
	const void *carg[3] = { NULL, NULL, opts };
	Regex_node *rn = NULL;
	if (arg != NULL)
	{
		if (NULL != arg[1])
		{
			if (!validate_flags(arg[0], arg[1]))
			{
				dyn_strcat(s, " "); 
				goto display_word_split_error;
			}
		}
		carg[1] = arg[1]; 
		if (arg[0] == &do_display_expr)
		{
			carg[0] = &do_display_expr;
		}
		else if (arg[0] != NULL)
		{
			if (arg[0][0] != '\0')
			{
				rn = make_disjunct_pattern(arg[0], arg[1]);
				if (NULL == rn)
				{
					dyn_strcat(s, " "); 
					goto display_word_split_error;
				}
				carg[0] = rn;
			}
		}
	}
	print_sentence_word_alternatives(s, sent, false, display, carg, NULL);
	if (rn != NULL) free_regexs(rn);
display_word_split_error:
	sentence_delete(sent);
	parse_options_set_spell_guess(opts, spell_option);
	char *out = dyn_str_take(s);
	if ('\0' != out[0]) return out;
	free(out);
	return NULL; 
}
static char * display_word_split ( Dictionary dict , const char * word , Parse_Options opts , char * ( * display ) ( Dictionary , const char * , const void * * ) , const char * * arg ) { Sentence sent ; if ( ' \0 ' == * word ) return NULL ; char * pword = strdupa ( word ) ; patch_subscript ( pword ) ; dyn_str * s = dyn_str_new ( ) ; int spell_option = parse_options_get_spell_guess ( opts ) ; parse_options_set_spell_guess ( opts , 0 ) ; sent = sentence_create ( pword , dict ) ; if ( pword [ 0 ] == ' ' && ( strchr ( pword , ' ' ) != NULL ) && ( ( strchr ( pword , ' ' ) [ 1 ] == ' \0 ' ) || ( strchr ( pword , ' ' ) [ 1 ] == SUBSCRIPT_MARK ) ) ) { if ( ! word0_set ( sent , pword , opts ) ) goto display_word_split_error ; } else { if ( 0 != sentence_split ( sent , opts ) ) goto display_word_split_error ; } print_sentence_word_alternatives ( s , sent , false , NULL , NULL , NULL ) ; const void * carg [ 3 ] = { NULL , NULL , opts } ; Regex_node * rn = NULL ; if ( arg != NULL ) { if ( NULL != arg [ 1 ] ) { if ( ! validate_flags ( arg [ 0 ] , arg [ 1 ] ) ) { dyn_strcat ( s , " " ) ; goto display_word_split_error ; } } carg [ 1 ] = arg [ 1 ] ; if ( arg [ 0 ] == & do_display_expr ) { carg [ 0 ] = & do_display_expr ; } else if ( arg [ 0 ] != NULL ) { if ( arg [ 0 ] [ 0 ] != ' \0 ' ) { rn = make_disjunct_pattern ( arg [ 0 ] , arg [ 1 ] ) ; if ( NULL == rn ) { dyn_strcat ( s , " " ) ; goto display_word_split_error ; } carg [ 0 ] = rn ; } } } print_sentence_word_alternatives ( s , sent , false , display , carg , NULL ) ; if ( rn != NULL ) free_regexs ( rn ) ; display_word_split_error : sentence_delete ( sent ) ; parse_options_set_spell_guess ( opts , spell_option ) ; char * out = dyn_str_take ( s ) ; if ( ' \0 ' != out [ 0 ] ) return out ; free ( out ) ; return NULL ; }
Display the information about the given word.
Display the information about the given word .
/* avoid trying null strings */ /* SUBSCRIPT_DOT in a sentence word is not interpreted as SUBSCRIPT_MARK,
	 * and hence a subscripted word that is found in the dict will not
	 * get found in the dict if it can split. E.g: 's.v (the info for s.v
	 * will not be shown). Fix it by replacing it to SUBSCRIPT_MARK. */ /* Dictionary macro - don't split. */ /* List the splits */ /* List the expression / disjunct information */ /* Initialize the callback arguments */ /*regex*/ /*flags*/ /* avoid no-expression error */ /* flags */ /* A pattern is specified, which means displaying disjuncts. */ /* avoid a no-match error */ /* no dict entry */