Item* Bchart:: in_chart(int b, const Term* trm, bool& wasThere) { Item* itm; itm = addtochart(trm); wasThere = false; return itm; }
Item* Bchart:: add_item2(int b, const Term* trm, int wInt, ECString wrdstr) { //cerr << "AI " << b << " " << *trm << " " << wInt << endl; Item* ans = NULL; Wrd* wrd = NULL; bool wasthere; ans = addtochart(trm); newWord(wrdstr, wInt, ans); return ans; }
Item* Bchart:: add_item(int b, const Term* trm, int wInt ) { //cerr << "AI " << b << " " << *trm << " " << wInt << endl; Item* ans = NULL; Wrd* wrd = NULL; bool wasthere; if(!trm->terminal_p()) return in_chart(b,trm,wasthere); if(wInt < 0) return in_chart(b,trm, wasthere); ans = addtochart(trm); newWord(intToW(wInt), wInt,ans); return ans; }
void Bchart:: addFinishedEdge(Edge* newEdge) { if(guided && !inGuide(newEdge)) return; if(printDebug() > 250) cerr << "addFinishedEdge " << *newEdge << endl; if(newEdge->finishedParent() && (newEdge->finishedParent()->term()->terminal_p())) { add_reg_item(newEdge->finishedParent()); return; } Item *regi; regi = in_chart( NULL, newEdge->lhs(), newEdge->start(), newEdge->loc()); if(regi) { /* redoP is a crucial function. It uses the probability of the edge to see what the new prob of regi should be, and if it is over the threshold for propogating probs, it will recursively do this up the chart. */ redoP(regi, newEdge->prob()); } else { //regi = new Item(newEdge->lhs(), // newEdge->start(), newEdge->loc()); regi = addtochart(newEdge->lhs()); regi->start() = newEdge->start(); regi->finish() = newEdge->loc(); regi->prob() = newEdge->prob(); //regi->headp() = newEdge->headp(); add_reg_item(regi); } if(newEdge->finishedParent()) { assert(newEdge->finishedParent() == regi); } else { newEdge->setFinishedParent( regi ); } regi->ineed().push_back( newEdge ); /* setFinishedParent tells newEdge that the consitutent that it build is regi */ }