static void process_linkage(Linkage linkage, Command_Options* copts) { char * string; ConstituentDisplayStyle mode; if (!linkage) return; /* Can happen in timeout mode */ if (copts->display_bad) { string = linkage_print_pp_msgs(linkage); fprintf(stdout, "%s\n", string); linkage_free_pp_msgs(string); } if (copts->display_on) { string = linkage_print_diagram(linkage, copts->display_walls, copts->screen_width); fprintf(stdout, "%s", string); linkage_free_diagram(string); } if ((mode = copts->display_constituents)) { string = linkage_print_constituent_tree(linkage, mode); if (string != NULL) { fprintf(stdout, "%s\n", string); linkage_free_constituent_tree_str(string); } else { copts->display_constituents = 0; prt_error("Error: Can't generate constituents.\n" "Constituent processing has been turned off.\n"); } } if (copts->display_links) { string = linkage_print_links_and_domains(linkage); fprintf(stdout, "%s", string); linkage_free_links_and_domains(string); } if (copts->display_senses) { string = linkage_print_senses(linkage); fprintf(stdout, "%s", string); linkage_free_senses(string); } if (copts->display_disjuncts) { string = linkage_print_disjuncts(linkage); fprintf(stdout, "%s\n", string); linkage_free_disjuncts(string); } if (copts->display_postscript) { string = linkage_print_postscript(linkage, copts->display_walls, copts->display_ps_header); fprintf(stdout, "%s\n", string); linkage_free_postscript(string); } }
/* * Class: LinkGrammar * Method: constituentString * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_linkgrammar_LinkGrammar_getConstituentString(JNIEnv *env, jclass cls) { per_thread_data *ptd = get_ptd(env, cls); /* mode 1 prints a lisp-style string, nicely indented. * mode 2 prints a lisp-style string, but with square brackets. * mode 3 prints a lisp-style string, one one single line. */ /* char *s = linkage_print_constituent_tree(linkage, 1); */ char *s = linkage_print_constituent_tree(ptd->linkage, 3); jstring j = (*env)->NewStringUTF(env, s); linkage_free_constituent_tree_str(s); return j; }
void process_linkage(Linkage linkage, Parse_Options opts) { char * string; int j, mode, first_sublinkage; if (parse_options_get_display_union(opts)) { linkage_compute_union(linkage); first_sublinkage = linkage_get_num_sublinkages(linkage)-1; } else { first_sublinkage = 0; } for (j=first_sublinkage; j<linkage_get_num_sublinkages(linkage); ++j) { linkage_set_current_sublinkage(linkage, j); if (parse_options_get_display_on(opts)) { string = linkage_print_diagram(linkage); fprintf(stdout, "%s", string); string_delete(string); } if (parse_options_get_display_links(opts)) { string = linkage_print_links_and_domains(linkage); fprintf(stdout, "%s", string); string_delete(string); } if (parse_options_get_display_postscript(opts)) { string = linkage_print_postscript(linkage, FALSE); fprintf(stdout, "%s\n", string); string_delete(string); } } if ((mode=parse_options_get_display_constituents(opts))) { string = linkage_print_constituent_tree(linkage, mode); if (string != NULL) { fprintf(stdout, "%s\n", string); string_delete(string); } else { fprintf(stderr, "Can't generate constituents.\n"); fprintf(stderr, "Constituent processing has been turned off.\n"); } } }
//############################################################################################## static void process_linkage(Linkage linkage, Parse_Options opts,char * tmp_path,char * file_name) //############################################################################################## { char * string; int j, mode, first_sublinkage; int nlink; if (!linkage) return; /* Can happen in timeout mode */ if (parse_options_get_display_union(opts)) { linkage_compute_union(linkage); first_sublinkage = linkage_get_num_sublinkages(linkage)-1; } else { first_sublinkage = 0; } nlink = linkage_get_num_sublinkages(linkage); for (j=first_sublinkage; j<nlink; ++j) { linkage_set_current_sublinkage(linkage, j); if (parse_options_get_display_on(opts)) { string = linkage_print_diagram(linkage); //######################################## // fprintf(stdout, "%s", string); //######################################### linkage_free_diagram(string); } if (parse_options_get_display_links(opts)) { string = linkage_print_links_and_domains(linkage); fprintf(stdout, "%s", string); linkage_free_links_and_domains(string); } if (parse_options_get_display_senses(opts)) { string = linkage_print_senses(linkage); fprintf(stdout, "%s", string); linkage_free_senses(string); } if (parse_options_get_display_disjuncts(opts)) { string = linkage_print_disjuncts(linkage); fprintf(stdout, "%s", string); linkage_free_disjuncts(string); } if (parse_options_get_display_postscript(opts)) { //######################################################################## string = linkage_print_postscript(linkage, FALSE,tmp_path,file_name); // fprintf(stdout, "%s\n", string); //######################################################################## linkage_free_postscript(string); /*string = linkage_print_postscript(linkage, FALSE); fprintf(stdout, "%s\n", string); linkage_free_postscript(string);*/ } } if ((mode = parse_options_get_display_constituents(opts))) { string = linkage_print_constituent_tree(linkage, mode); if (string != NULL) { /*###########################################*/ // fprintf(stdout, "%s\n", string); /*##########################################*/ linkage_free_constituent_tree_str(string); } else { fprintf(stderr, "Can't generate constituents.\n"); fprintf(stderr, "Constituent processing has been turned off.\n"); } } }