Linkage linkage_create(int k, Sentence sent, Parse_Options opts) { Linkage linkage; assert((k < sent->num_linkages_post_processed) && (k >= 0), "index out of range"); /* Using exalloc since this is external to the parser itself. */ linkage = (Linkage) exalloc(sizeof(struct Linkage_s)); linkage->num_words = sent->length; linkage->word = (char **) exalloc(linkage->num_words*sizeof(char *)); linkage->current = 0; linkage->num_sublinkages=0; linkage->sublinkage = NULL; linkage->unionized = FALSE; linkage->sent = sent; linkage->opts = opts; linkage->info = sent->link_info[k]; extract_links(sent->link_info[k].index, sent->null_count, sent->parse_info); compute_chosen_words(sent, linkage); if (set_has_fat_down(sent)) { extract_fat_linkage(sent, opts, linkage); } else { extract_thin_linkage(sent, opts, linkage); } if (sent->dict->postprocessor != NULL) { linkage_post_process(linkage, sent->dict->postprocessor); } return linkage; }
static char * print_flat_constituents(con_context_t *ctxt, Linkage linkage) { int num_words; Sentence sent; Postprocessor * pp; int s, numcon_total, numcon_subl, num_subl; char * q; sent = linkage_get_sentence(linkage); ctxt->phrase_ss = string_set_create(); pp = linkage->sent->dict->constituent_pp; numcon_total = 0; count_words_used(ctxt, linkage); num_subl = linkage->num_sublinkages; if(num_subl > MAXSUBL) { num_subl=MAXSUBL; if(verbosity>=2) printf("Number of sublinkages exceeds maximum: only considering first %d sublinkages\n", MAXSUBL); } if(linkage->unionized==1 && num_subl>1) num_subl--; for (s=0; s<num_subl; s++) { linkage_set_current_sublinkage(linkage, s); linkage_post_process(linkage, pp); num_words = linkage_get_num_words(linkage); generate_misc_word_info(ctxt, linkage); numcon_subl = read_constituents_from_domains(ctxt, linkage, numcon_total, s); numcon_total = numcon_total + numcon_subl; } numcon_total = merge_constituents(ctxt, linkage, numcon_total); numcon_total = last_minute_fixes(ctxt, linkage, numcon_total); q = exprint_constituent_structure(ctxt, linkage, numcon_total); string_set_delete(ctxt->phrase_ss); ctxt->phrase_ss = NULL; return q; }