void WordTag::find_matches(int w, const char* C, char dir, std::vector<PositionConnector*>& matches) { // cout << "Look connection on: ." << _word << ". ." << w << ". " << C << dir << endl; Connector search_cntr; init_connector(&search_cntr); search_cntr.label = NORMAL_LABEL; search_cntr.priority = THIN_priority; search_cntr.string = C; set_connector_length_limit(&search_cntr); std::vector<PositionConnector>* connectors; switch(dir) { case '+': connectors = &_left_connectors; break; case '-': connectors = &_right_connectors; break; default: throw std::string("Unknown connector direction: ") + dir; } bool conjunction = sentence_contains_conjunction(_sent); std::vector<PositionConnector>::iterator i; for (i = connectors->begin(); i != connectors->end(); i++) { if (WordTag::match(w, search_cntr, dir, (*i).word, *((*i).connector), conjunction)) { matches.push_back(&(*i)); } } }
void free_sentence_disjuncts(Sentence sent) { int i; for (i=0; i<sent->length; ++i) { free_disjuncts(sent->word[i].d); sent->word[i].d = NULL; } if (sentence_contains_conjunction(sent)) free_AND_tables(sent); }
void my_prepare_to_parse(Sentence sent, Parse_Options opts) { /* assumes that the sentence expression lists have been generated */ /* this does all the necessary pruning and building of and */ /* structures. */ int i, has_conjunction; // build_sentence_disjuncts(sent, opts->disjunct_cost); // if (verbosity > 2) { //printf("After expanding expressions into disjuncts:") ; //print_disjunct_counts(sent); // } print_time(opts, "Built disjuncts"); for (i=0; i<sent->length; i++) { sent->word[i].d = eliminate_duplicate_disjuncts(sent->word[i].d); } print_time(opts, "Eliminated duplicate disjuncts"); if (verbosity > 2) { printf("\nAfter expression pruning and duplicate elimination:\n"); print_disjunct_counts(sent); } null_links = (opts->min_null_count > 0); has_conjunction = sentence_contains_conjunction(sent); set_connector_length_limits(sent, opts); build_deletable(sent, has_conjunction); build_effective_dist(sent, has_conjunction); /* why do we do these here instead of in first_prepare_to_parse() only? The reason is that the deletable region depends on if null links are in use. with null_links everything is deletable */ if (!has_conjunction) { pp_and_power_prune(sent, RUTHLESS, opts); } else { pp_and_power_prune(sent, GENTLE, opts); /*if (verbosity > 2) { printf("\nAfter Gentle power pruning:\n"); print_disjunct_counts(sent); } */ /*print_time(opts, "Finished gentle power pruning"); */ conjunction_prune(sent, opts); if (verbosity > 2) { printf("\nAfter conjunction pruning:\n"); print_disjunct_counts(sent); print_statistics(); } print_time(opts, "Done conjunction pruning"); build_conjunction_tables(sent); install_fat_connectors(sent); install_special_conjunctive_connectors(sent); if (verbosity > 2) { printf("After conjunctions, disjuncts counts:\n"); print_disjunct_counts(sent); } set_connector_length_limits(sent, opts); /* have to do this again cause of the new fat connectors and disjuncts */ print_time(opts, "Constructed fat disjuncts"); prune(sent); print_time(opts, "Pruned fat disjuncts"); for (i=0; i<sent->length; i++) { sent->word[i].d = eliminate_duplicate_disjuncts(sent->word[i].d); } if (verbosity > 2) { printf("After pruning and duplicate elimination:\n"); print_disjunct_counts(sent); } print_time(opts, "Eliminated duplicate disjuncts (again)"); if (verbosity > 2) print_AND_statistics(sent); power_prune(sent, RUTHLESS, opts); } /* if (verbosity > 2) { printf("\nAfter RUTHLESS power-pruning:\n"); print_disjunct_counts(sent); } */ /* print time for power pruning used to be here */ /* now done in power_prune itself */ print_time(opts, "Initialized fast matcher and hash table"); }