int sentence_parse(Sentence sent, Parse_Options opts) { int rc; sent->num_valid_linkages = 0; /* If the sentence has not yet been split, do so now. * This is for backwards compatibility, for existing programs * that do not explicitly call the splitter. */ if (0 == sent->length) { rc = sentence_split(sent, opts); if (rc) return -1; } else { /* During a panic parse, we enter here a second time, with leftover * garbage. Free it. We really should make the code that is panicking * do this free, but right now, they have no API for it, so we do it * as a favor. XXX FIXME someday. */ free_sentence_disjuncts(sent); } /* Check for bad sentence length */ if (MAX_SENTENCE <= sent->length) { prt_error("Error: sentence too long, contains more than %d words\n", MAX_SENTENCE); return -2; } resources_reset(opts->resources); /* Expressions were set up during the tokenize stage. * Prune them, and then parse. */ expression_prune(sent, opts); print_time(opts, "Finished expression pruning"); if (opts->use_sat_solver) { sat_parse(sent, opts); } else { classic_parse(sent, opts); } print_time(opts, "Finished parse"); if ((verbosity > 0) && (PARSE_NUM_OVERFLOW < sent->num_linkages_found)) { prt_error("Warning: Combinatorial explosion! nulls=%zu cnt=%d\n" "Consider retrying the parse with the max allowed disjunct cost set lower.\n" "At the command line, use !cost-max\n", sent->null_count, sent->num_linkages_found); } return sent->num_valid_linkages; }
void parse_options_reset_resources(Parse_Options opts) { resources_reset(opts->resources); }