Exemple #1
0
struct ast * mk_import(struct path * chemin){
    struct ast * e = mk_node();
    e->type = IMPORT;
    e->node->chemin = chemin;
    return e;
}
Exemple #2
0
struct ast * mk_word(char * str){
    struct ast * e = mk_node();
    e->type = WORD;
    e->node->str = str;
    return e;
}
Exemple #3
0
struct ast * mk_binop(enum binop binop){
    struct ast * e = mk_node();
    e->type = BINOP;
    e->node->binop = binop;
    return e;
}
Exemple #4
0
struct ast * mk_unaryop(enum unaryop unaryop){
    struct ast * e = mk_node();
    e->type = UNARYOP;
    e->node->unaryop = unaryop;
    return e;
}
Exemple #5
0
dtree_t *
mk_tree(float32 ****mixw,
        float32 ****means,
        float32 ****vars,
        uint32  *veclen,
	uint32 n_model,
	uint32 n_state,
	uint32 n_stream,
	uint32 n_density,
	float32 *stwt,
	
	uint32 *id,
	uint32 n_id,

	quest_t *all_q,
	uint32 n_all_q,
	pset_t *pset,

	uint32 **dfeat,
	uint32 n_dfeat,

	uint32 split_min,
	uint32 split_max,
	float32 split_thr,

	float32 mwfloor)
{
    dtree_t *s_tree;
    uint32 i;
    dtree_node_t *b_n, *root;

    s_tree = ckd_calloc(1, sizeof(dtree_t));
    s_tree->node = ckd_calloc(2*split_max + 1, sizeof(dtree_node_t));
    s_tree->n_node = 0;

    s_tree->node[0].node_id = 0;
    s_tree->n_node = 1;

    root = &s_tree->node[0];

    mk_node(root, 0,
	    id, n_id,
	    mixw,
            means,
            vars,
            veclen,
	    n_model,
	    n_state,
	    n_stream,
	    n_density,
	    stwt,
	    mwfloor);

    set_best_quest(root,
		   mixw,
                   means,
                   vars,
                   veclen,
		   n_model,
		   n_state,
		   n_stream,
		   n_density,
		   stwt,
		   all_q,
		   n_all_q,
		   pset,
		   dfeat, n_dfeat,
		   mwfloor);

    if (root->q == NULL) {
	/* No question found that is able to split node;
	   can't go any further */
	free_tree(s_tree);

	return NULL;
    }

    for (i = 0; i < split_max; i++) {
	b_n = best_leaf_node(root);

	if (b_n == NULL) {
	    E_INFO("stop. leaf nodes are specific\n");

	    break;
	}

/* DDDDDBUG The following criteria will fail if we use only likelihood and no
    likelihood increase */

	if (b_n->wt_ent_dec <= 0) {
	    E_INFO("stop. b_n->wt_ent_dec (%.3e) <= 0\n",
		   b_n->wt_ent_dec);
	    break;
	}

	if ((i > split_min) &&
	    (b_n->wt_ent_dec < split_thr * b_n->wt_ent)) {

	    E_INFO("stop. b_n->wt_ent_dec (%.3e) < split_thr * b_n->wt_ent (%.3e)\n",
		   b_n->wt_ent_dec, b_n->wt_ent * split_thr);

	    break;
	}

	split_node(s_tree, b_n->node_id,
		   mixw,
                   means,
                   vars,
                   veclen,
		   n_model,
		   n_state,
		   n_stream,
		   n_density,
		   stwt,
		   all_q, n_all_q, pset,
		   dfeat, n_dfeat,
		   mwfloor);
    }

#if 1
    E_INFO("Final simple tree\n");
    print_tree(stderr, "|", root, pset, 0);
    fprintf(stderr, "\n");
#endif

    return s_tree;
}
Exemple #6
0
void make_picker(QSP_ARG_DECL  Screen_Obj *sop)
{
#ifdef HAVE_MOTIF
	int	j;
	Arg	al[20];
	int	ac = 0;
	Screen_Obj *b_sop;	/* button ptr */
	char buf[6];
	int n;
	const char **stringlist;

	if( SOB_N_CYLINDERS(sop) != 1 ){
		sprintf(ERROR_STRING,"picker %s needs %d components, but we're only implementing 1!?",
			SOB_NAME(sop),SOB_N_CYLINDERS(sop));
		WARN(ERROR_STRING);
	}
	n= SOB_N_SELECTORS_AT_IDX(sop,/*component*/ 0 );

	sop->so_frame = generic_frame(curr_panel->po_panel_obj,
		sop, XmSHADOW_IN);

	XtSetArg(al[ac], XmNentryClass, xmToggleButtonWidgetClass); ac++;
	strcpy(buf,"name");
	sop->so_obj = XmCreateRadioBox(sop->so_frame,
		buf, al, ac);

	XtManageChild(sop->so_obj);

#ifdef CAUTIOUS
	if( sop->so_children != NO_LIST ){
		sprintf(ERROR_STRING,"CAUTIOUS:  Picker %s already has a child list!?",SOB_NAME(sop));
		ERROR1(ERROR_STRING);
	}
#endif /* CAUTIOUS */

	SET_SOB_CHILDREN(sop,new_list());

	stringlist = SOB_SELECTORS_AT_IDX(sop,0);

	// The choices are created as screen_objs, we
	// need to create a special context for them so that we
	// can have the same choices in multiple pickers and choosers
	// The context name should be the concatenation of the current
	// scrnobj context, and the name of this widget...

	push_widget_context(QSP_ARG  sop);

	for(j=0; j<n; j++) {
		b_sop = simple_object(QSP_ARG  stringlist[j]);
		if( b_sop==NO_SCREEN_OBJ ) return;
		b_sop->so_action_text = savestr(stringlist[j]);
		b_sop->so_parent = sop;
		b_sop->so_flags |= SOT_MENU_ITEM;

		/* The choices need to be part of the panel list (so we can find them
		 * with find_object), but also on the parent list, so we can find them
		 * through it...
		 */

		addHead(curr_panel->po_children,mk_node(b_sop));
		addTail(sop->so_children,mk_node(b_sop));

		b_sop->so_obj = XtCreateManagedWidget(
			b_sop->so_name,			/* widget name */
			xmToggleButtonWidgetClass,	/* widget class */
			sop->so_obj,			/* parent widget */
			NULL, 0);
		fix_names(QSP_ARG  b_sop,sop);
										/* client data */
		XtAddCallback(b_sop->so_obj, XmNvalueChangedCallback, chooser_func, NULL);
		XtManageChild(b_sop->so_obj);
	}

	pop_scrnobj_context(SINGLE_QSP_ARG);

	SET_SOB_HEIGHT(sop, CHOOSER_HEIGHT + CHOOSER_ITEM_HEIGHT*n );
#endif /* HAVE_MOTIF */
}
Exemple #7
0
void add_to_panel(Panel_Obj *po, Screen_Obj *sop)	// for X11
{
	addHead(PO_CHILDREN(po),mk_node(sop));
	SET_SOB_PARENT(sop, po);
}
/* Create a node that is basically a parent for other elements */
node * mk_list(int key, node *list) {
	node *result;
	result = mk_node(key);
	result->children = reverse_list(list);
	return result;
}
Exemple #9
0
ast* mk_statblock ( const void* loc, ast_list* revstat )
{
    ast* r = mk_node(loc, stat_node, reverse(revstat));
    return r;
}
Exemple #10
0
ast* mk_noder ( const void* locl, const void* locr, const ast_kind tag, ast_list* args )
{
    return mk_node(comb_loc(locl, locr), tag, args);
}
Exemple #11
0
// add
ast* mk_unaryexp ( const void* loc, const ast_kind tag, ast* val )
{
    ast_list* children = cons(val, NULL);
    ast* r = mk_node(loc, tag, children);
    return r;
}
Exemple #12
0
struct expr *mk_int(int k){
  struct expr *e = mk_node();
  e->type=NUM;
  e->expr->num = k;
  return e;
}
Exemple #13
0
struct expr *mk_op(enum op op){
  struct expr *e = mk_node();
  e->type=OP;
  e->expr->op = op;
  return e;
}
Exemple #14
0
struct ast * mk_integer(int n){
    struct ast * e = mk_node();
    e->type = INTEGER;
    e->node->num = n;
    return e;
}
Exemple #15
0
void add_to_navp(Nav_Panel *np_p, Screen_Obj *sop)	// for X11
{
	addHead(PO_CHILDREN(np_p->np_po),mk_node(sop));
	SET_SOB_PARENT(sop, np_p->np_po);
}
/* Create a new node in the parse tree, and store str */
node * mk_str(char *string) {
	node *result = mk_node(STR);
	assert(string != NULL);
	result->str = strdup(string);
	return result;
}
Exemple #17
0
void
split_node(dtree_t *tr,
	   uint32 node_id,
	   float32 ****mixw,
/* ADDITION FOR CONTINUOUS_TREES */
           float32 ****means,
           float32 ****vars,
           uint32 *veclen,
/* END ADDITION FOR CONTINUOUS_TREES */
	   uint32 n_model,
	   uint32 n_state,
	   uint32 n_stream,
	   uint32 n_density,
	   float32 *stwt,

	   quest_t *all_q,
	   uint32 n_all_q,
	   pset_t *pset,
	   
	   uint32 **dfeat,
	   uint32 n_dfeat,

	   float32 mwfloor)
{
    uint32 *id, n_id;
    uint32 *id_yes, n_yes;
    uint32 *id_no, n_no;
    dtree_node_t *node;
    uint32 node_id_yes;
    uint32 node_id_no;
    uint32 ii, i;

    node = &tr->node[node_id];

    id = node->id;
    n_id = node->n_id;

    for (ii = 0, n_yes = 0, n_no = 0; ii < n_id; ii++) {
	i = id[ii];

	if (eval_quest((quest_t *)node->q, dfeat[i], n_dfeat)) {
	    ++n_yes;
	}
	else {
	    ++n_no;
	}
    }

#if 0
    fprintf(stderr, "Split: (");
    print_quest(stderr, pset, (quest_t *)node->q);
    fprintf(stderr, ") %u/%u %.3e\n", n_yes, n_no, node->wt_ent_dec);
#endif

    id_yes = ckd_calloc(n_yes, sizeof(uint32));
    id_no = ckd_calloc(n_no, sizeof(uint32));

    for (ii = 0, n_yes = 0, n_no = 0; ii < n_id; ii++) {
	i = id[ii];

	if (eval_quest((quest_t *)node->q, dfeat[i], n_dfeat)) {
	    id_yes[n_yes] = i;
	    ++n_yes;
	}
	else {
	    id_no[n_no] = i;
	    ++n_no;
	}
    }

    node_id_yes = tr->n_node++;
    node_id_no = tr->n_node++;

    node->y = &tr->node[node_id_yes];
    node->n = &tr->node[node_id_no];
    node->y->p = node;
    node->n->p = node;

/* MODIFICATION FOR CONTINUOUS_TREES; Pass means, vars and veclen also */
    mk_node(node->y,
	    node_id_yes,
	    id_yes, n_yes,
	    mixw, means, vars, veclen,
            n_model, n_state, n_stream, n_density, stwt, mwfloor);

    set_best_quest(node->y,
		   mixw,
                   means,
                   vars,
                   veclen,
		   n_model,
		   n_state,
		   n_stream,
		   n_density,
		   stwt,
		   all_q, n_all_q, pset,
		   dfeat, n_dfeat,
		   mwfloor);

    mk_node(node->n,
	    node_id_no,
	    id_no, n_no,
	    mixw, means, vars, veclen,
            n_model, n_state, n_stream, n_density, stwt, mwfloor);

    set_best_quest(node->n,
		   mixw,
                   means,
                   vars,
                   veclen,
		   n_model,
		   n_state,
		   n_stream,
		   n_density,
		   stwt,
		   all_q, n_all_q, pset,
		   dfeat, n_dfeat,
		   mwfloor);
/* END MODIFICATION FOR CONTINUOUS_TREES */
}
Exemple #18
0
dtree_t *
mk_tree_comp(float32 ****mixw,
             float32 ****means, 
             float32 ****vars, 
             uint32  *veclen,
	     uint32 n_model,
	     uint32 n_state,
	     uint32 n_stream,
	     uint32 n_density,
	     float32 *stwt,
	
	     uint32 *id,
	     uint32 n_id,

	     quest_t *all_q,
	     uint32 n_all_q,
	     pset_t *pset,
	     uint32 n_base_phone,
	     
	     uint32 **dfeat,
	     uint32 n_dfeat,

	     uint32  split_min,
	     uint32  split_max,
	     float32 split_thr,

	     uint32  split_min_comp,
	     uint32  split_max_comp,
	     float32 split_thr_comp,

	     float32 mwfloor)
{
    dtree_t *comp_tree;
    dtree_node_t *root, *b_n;
    uint32 i;

    comp_tree = ckd_calloc(1, sizeof(dtree_t));
    comp_tree->node = ckd_calloc(2*split_max_comp+1, sizeof(dtree_node_t));
    comp_tree->n_node = 0;

    comp_tree->node[0].node_id = 0;
    comp_tree->n_node = 1;
    
    root = &comp_tree->node[0];

    mk_node(root, 0,
	    id, n_id,
	    mixw, means, vars, veclen,
            n_model, n_state, n_stream, n_density, stwt, mwfloor);

    root->q = (void *)mk_comp_quest(&root->wt_ent_dec,
				    mixw, means, vars, veclen, 
                                    n_model, n_state, n_stream, n_density, stwt,
				    id, n_id,
				    all_q, n_all_q, pset, n_base_phone,
				    dfeat, n_dfeat,
				    split_min, split_max, split_thr,
				    mwfloor);
    
    for (i = 0; i < split_max_comp; i++) {
	b_n = best_leaf_node(root);

	E_INFO("Comp split %u\n", i);

	if (b_n == NULL) {
	    E_INFO("stop. leaf nodes are specific\n");

	    break;
	}

	if (b_n->wt_ent_dec <= 0) {
	    E_INFO("stop. b_n->wt_ent_dec (%.3e) <= 0\n",
		   b_n->wt_ent_dec);
	    break;
	}
	if ((i > split_min_comp) &&
	    (b_n->wt_ent_dec < split_thr_comp * b_n->wt_ent)) {
	    E_INFO("stop. b_n->wt_ent_dec <= split_thr_comp * b_n->wt_ent. %.3e <= %.3e\n",
		   b_n->wt_ent_dec, split_thr_comp * b_n->wt_ent);
	    break;
	}
		   
	split_node_comp(comp_tree, b_n->node_id,
			mixw, means, vars, veclen, 
                        n_model, n_state, n_stream, n_density, stwt,
			all_q, n_all_q, pset, n_base_phone,
			dfeat, n_dfeat,
			split_min, split_max, split_thr, mwfloor);

#if 0
	printf("Comp Split %u:\n", i);
	print_tree_comp(stderr, "*", root, pset, 0);
	fprintf(stderr, "\n");
#endif
    }

#if 0
    E_INFO("Final Comp Tree %u:\n", i);
    print_tree_comp(stderr, "", root, pset, 0);
    fprintf(stderr, "\n");
#endif

    return comp_tree;
}
Exemple #19
0
static COMMAND_FUNC( do_chng_one )
{
	Param *p;
	const char **pnlist;
	int nlist=0;
	int i=0;
	const char *s;

	p=theptbl;

	/* count the number of parameters */
	while( p->p_type != NULL_P_TYPE ) {
		nlist++;
		p++;
	}

	pnlist = (const char **) getbuf( (nlist+1) * sizeof(char *) );
	if( pnlist == NULL ) mem_err("do_chng_one");

#ifdef HAVE_HISTORY

	if( intractive(SINGLE_QSP_ARG) && IS_TRACKING_HISTORY(THIS_QSP) ){
		List *lp;
		Node *np;

		lp = new_list();
		for(i=0;i<nlist;i++){
			pnlist[i] = theptbl[i].p_name;
			np = mk_node(&theptbl[i]);
			addTail(lp,np);
		}
		pnlist[i]="all";
		np = mk_node(&pnlist[i]);
		addTail(lp,np);

		if( intractive(SINGLE_QSP_ARG) ){
			char pline[LLEN];
			make_prompt(QSP_ARG  pline,PNAME_PMPT);
			new_defs(QSP_ARG  pline);		/* is this needed? */
			init_hist_from_item_list(QSP_ARG  PNAME_PMPT,lp);
		}

		dellist(lp);
	}

#else /* ! HAVE_HISTORY */
	for(i=0;i<nlist;i++)
		pnlist[i] = theptbl[i].p_name;
#endif /* ! HAVE_HISTORY */

	s=NAMEOF(PNAME_PMPT);
	if( !strcmp(s,"all") ){
		p=theptbl;
		while( p->p_type != NULL_P_TYPE ) {
			getparm(QSP_ARG  p);
			showparm(QSP_ARG  p);
			p++;
		}
		return;
	} else if( get_pval(QSP_ARG  s,theptbl) == -1 ){
		sprintf(ERROR_STRING,"Unknown parameter \"%s\"",s);
		WARN(ERROR_STRING);
	}
}
Exemple #20
0
void
split_node_comp(dtree_t *tr,
		uint32 node_id,
		float32 ****mixw,
                float32 ****means,
                float32 ****vars,
                uint32  *veclen,
		uint32 n_model,
		uint32 n_state,
		uint32 n_stream,
		uint32 n_density,
		float32 *stwt,
		quest_t *all_q,
		uint32 n_all_q,
		pset_t *pset,
		uint32 n_base_phone,
		uint32 **dfeat,
		uint32 n_dfeat,
		uint32  split_min,
		uint32  split_max,
		float32 split_thr,
		float32 mwfloor)
{
    uint32 *id, n_id;
    uint32 *id_yes, n_yes;
    uint32 *id_no, n_no;
    dtree_node_t *node;
    uint32 node_id_yes;
    uint32 node_id_no;
    uint32 ii, i;

    node = &tr->node[node_id];
    id = node->id;
    n_id = node->n_id;

    for (ii = 0, n_yes = 0, n_no = 0; ii < n_id; ii++) {
	i = id[ii];

	if (eval_comp_quest((comp_quest_t *)node->q, dfeat[i], n_dfeat)) {
	    ++n_yes;
	}
	else {
	    ++n_no;
	}
    }

#if 0
    fprintf(stderr, "Comp Split: ");
    print_comp_quest(stderr, pset, (comp_quest_t *)node->q);
    fprintf(stderr, " %u/%u %.3e\n", n_yes, n_no, node->wt_ent_dec);
#endif
    
    id_yes = ckd_calloc(n_yes, sizeof(uint32));
    id_no = ckd_calloc(n_no, sizeof(uint32));

    for (ii = 0, n_yes = 0, n_no = 0; ii < n_id; ii++) {
	i = id[ii];

	if (eval_comp_quest((comp_quest_t *)node->q, dfeat[i], n_dfeat)) {
	    id_yes[n_yes] = i;
	    ++n_yes;
	}
	else {
	    id_no[n_no] = i;
	    ++n_no;
	}
    }

    node_id_yes = tr->n_node++;
    node_id_no = tr->n_node++;

    node->y = &tr->node[node_id_yes];
    node->n = &tr->node[node_id_no];
    node->y->p = node;
    node->n->p = node;

    mk_node(node->y,
	    node_id_yes,
	    id_yes, n_yes,
	    mixw, means, vars, veclen,
            n_model, n_state, n_stream, n_density, stwt, mwfloor);

    node->y->q = (void *)mk_comp_quest(&(node->y->wt_ent_dec),
				       mixw, means, vars, veclen,
                                       n_model, n_state, n_stream, n_density, 
                                       stwt, id_yes, n_yes,
				       all_q, n_all_q, pset, n_base_phone,
				       dfeat, n_dfeat,
				       split_min, split_max, split_thr, mwfloor);

    mk_node(node->n,
	    node_id_no,
	    id_no, n_no,
	    mixw, means, vars, veclen,
            n_model, n_state, n_stream, n_density, stwt, mwfloor);

    node->n->q = (void *)mk_comp_quest(&(node->n->wt_ent_dec),
				       mixw, means, vars, veclen, 
                                       n_model, n_state, n_stream, n_density, 
                                       stwt, id_no, n_no,
				       all_q, n_all_q, pset, n_base_phone,
				       dfeat, n_dfeat,
				       split_min, split_max, split_thr, mwfloor);
}
Exemple #21
0
void make_chooser(QSP_ARG_DECL  Screen_Obj *sop, int n, const char **stringlist)
{
#ifdef HAVE_MOTIF
	int	j;
	Arg	al[20];
	int	ac = 0;
	Screen_Obj *b_sop;	/* button ptr */
	char buf[6];

	sop->so_frame = generic_frame(curr_panel->po_panel_obj,
		sop, XmSHADOW_IN);

	XtSetArg(al[ac], XmNentryClass, xmToggleButtonWidgetClass); ac++;
	strcpy(buf,"name");
	sop->so_obj = XmCreateRadioBox(sop->so_frame,
		buf, al, ac);

	XtManageChild(sop->so_obj);

#ifdef CAUTIOUS
	if( sop->so_children != NO_LIST ){
		sprintf(ERROR_STRING,"CAUTIOUS:  Chooser %s already has a child list!?",SOB_NAME(sop));
		ERROR1(ERROR_STRING);
	}
#endif /* CAUTIOUS */

	SET_SOB_CHILDREN(sop,new_list());

	push_widget_context(QSP_ARG  sop);

	for(j=0; j<n; j++)
	{
		b_sop = simple_object(QSP_ARG  stringlist[j]);
		if( b_sop==NO_SCREEN_OBJ ) return;
		b_sop->so_action_text = savestr(stringlist[j]);
		b_sop->so_parent = sop;
		b_sop->so_flags |= SOT_MENU_ITEM;

		/* The choices need to be part of the panel list (so we can find them
		 * with find_object), but also on the parent list, so we can find them
		 * through it...
		 */

		addHead(curr_panel->po_children,mk_node(b_sop));
		addTail(sop->so_children,mk_node(b_sop));

		b_sop->so_obj = XtCreateManagedWidget(
			b_sop->so_name,			/* widget name */
			xmToggleButtonWidgetClass,	/* widget class */
			sop->so_obj,			/* parent widget */
			NULL, 0);
		fix_names(QSP_ARG  b_sop,sop);
										/* client data */
		XtAddCallback(b_sop->so_obj, XmNvalueChangedCallback, chooser_func, NULL);
		XtManageChild(b_sop->so_obj);
	}

	pop_scrnobj_context(SINGLE_QSP_ARG);

#endif /* HAVE_MOTIF */

	SET_SOB_HEIGHT(sop, CHOOSER_HEIGHT + CHOOSER_ITEM_HEIGHT*n );
}