Esempio n. 1
0
/*
	Output test for HAM internal structure.
	Print-out internal HAM results for one sentence.
	If (mode->outmode != OUTMODE_ALL) then most plausible
		candidates are printed. ---> strongly recommended!!!
	mode->outmode == OUTMODE_ALL is used only for debugging.
*/
void hamout_HAM(
	FILE *fp,	/* output file */
	HAM_PMORES p,	/* HAM result for input sentence */
	HAM_PRUNMODE mode
) {
	HAM_SHORT i, j, n;
	HAM_PWORD pw;
	HAM_PRESULT pr;

	if (mode->echosent)
		fprintf(fp, "[[%s]]\n", p->phon);	/* echo input sentence */
	if (mode->err_code)
		error_analysis(mode->err_code, mode->err_word);	/* error message */

	for (i = 0; i < p->nword; i++) {
		pw = (p->word)+i;	/* i-th word in a setence */
		if (mode->echoword)	/* echo input word */
			echo_input_word(fp, pw->phon, pw->retcode, mode);

		if (pw->nresult > MAXRESULT)	/* ERROR: overflow max. HAM results */
			fprintf(stderr, "ERROR: [%s] more than maximum(%d) HAM results!!!\n",
				pw->phon, MAXRESULT);

		n = (mode->outmode == OUTMODE_ALL) ? pw->nresult : (int) pw->gr[0];
		if (mode->outlevel == BEST1_ONLY) n = 1;
		else if (mode->outlevel == BEST2_ONLY) n = (n == 1) ? 1: 2;

		for (j = 0; j < n; j++) {	/* for each HAM result */
			if (mode->outmode == OUTMODE_ALL)
				pr = (pw->result)+j;	/* j-th HAM results for word */
			else pr = (pw->result)+(pw->gr[j+1]);	/* j-best HAM results for word */
			put_morph_result(fp, pr, mode);
		}
	}
}
Esempio n. 2
0
void ff_refine_elements(Element *e1, Element *e2, long level, long process_id)
{
    long subdiv_advice ;
    Interaction i12, i21 ;
    Interaction *inter ;

#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
    Patch_Cost *pc1, *pc2 ;
    long cost1, cost2 ;
#endif


    /* Now compute formfactor.
       As the BSP tree is being modified at this moment, don't test
       visibility. */
    compute_formfactor( e1, e2, &i12, process_id ) ;
    compute_formfactor( e2, e1, &i21, process_id ) ;

    /* Analyze the error of FF */
    subdiv_advice = error_analysis( e1, e2, &i12, &i21, process_id ) ;

    /* Execute subdivision procedure */
    if( NO_INTERACTION(subdiv_advice) )
        /* Two elements are mutually invisible. Do nothing */
        return ;

    else if( NO_REFINEMENT_NECESSARY(subdiv_advice) )
        {
            /* Create links and finish the job */
            inter = get_interaction(process_id) ;
            *inter = i12 ;
            inter->visibility = VISIBILITY_UNDEF ;
            insert_vis_undef_interaction( e1, inter, process_id ) ;

            inter = get_interaction(process_id) ;
            *inter = i21 ;
            inter->visibility = VISIBILITY_UNDEF ;
            insert_vis_undef_interaction( e2, inter, process_id ) ;

#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
            /* Update cost variable */
            pc1 = &global->patch_cost[ e1->patch->seq_no ] ;
            pc2 = &global->patch_cost[ e2->patch->seq_no ] ;
            if( pc1->n_total_inter <= 13 )
                cost1 = (long)ceil(e1->area / Area_epsilon) ;
            else
                cost1 = 1 ;

            if( pc2->n_total_inter <= 13 )
                cost2 = (long)ceil(e2->area / Area_epsilon) ;
            else
                cost2 = 1 ;

            LOCK(global->cost_sum_lock);
            pc1->cost_estimate += cost1 ;
            pc1->n_total_inter++ ;
            pc2->cost_estimate += cost2 ;
            pc2->n_total_inter++ ;
            global->cost_estimate_sum += (cost1 + cost2) ;
            global->cost_sum += (cost1 + cost2) ;
            UNLOCK(global->cost_sum_lock);
#endif
        }

    else if( REFINE_PATCH_1(subdiv_advice) )
        {
            /* Refine patch 1 */
            subdivide_element( e1, process_id ) ;

            /* Locally solve it */
            ff_refine_elements( e1->top,    e2, level+1, process_id ) ;
            ff_refine_elements( e1->center, e2, level+1, process_id ) ;
            ff_refine_elements( e1->left,   e2, level+1, process_id ) ;
            ff_refine_elements( e1->right,  e2, level+1, process_id ) ;
        }
    else
        {
            /* Refine patch 2 */
            subdivide_element( e2, process_id ) ;

            /* Locally solve it */
            ff_refine_elements( e1, e2->top,    level+1, process_id ) ;
            ff_refine_elements( e1, e2->center, level+1, process_id ) ;
            ff_refine_elements( e1, e2->left,   level+1, process_id ) ;
            ff_refine_elements( e1, e2->right,  level+1, process_id ) ;
        }
}