int fh_term_after(FullHist* fh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } FullHist* par = fh->back; if(!par) return stopint; int i = 0; for( ; i < par->size ; i++ ) { FullHist* st = par->fharray[i]; if(st != fh) continue; i++; if(i == par->size) { return stopint; } st = par->fharray[i]; assert(st); return st->term; } error("Should never get here fh_term_after"); return -1; }
int tree_grandparent_pos(TreeHist* treeh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } InputTree* tree = treeh->tree; InputTree* par1 = tree->parent(); if(!par1) return stopint; InputTree* par = par1->parent(); if(!par) return stopint; const ECString& trmStr = par->hTag(); const Term* trm = Term::get(trmStr); assert(trm); if(!trm->terminal_p()) { cerr << "Bad head Part of Speech: " << *trm << " in " <<endl; cerr << *tree << endl; assert(trm->terminal_p()); } return trm->toInt(); }
int tree_term_after(TreeHist* treeh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } InputTree* tree = treeh->tree; InputTree* par = tree->parent(); if(!par) return stopint; InputTreesIter iti = par->subTrees().begin(); for( ; iti != par->subTrees().end() ; iti++ ) { InputTree* st = *iti; if(st != tree) continue; iti++; if(iti == par->subTrees().end()) return stopint; st = *iti; const ECString& trmStr = st->term(); const Term* trm = Term::get(trmStr); assert(trm); return trm->toInt(); } error("Should never get here"); return -1; }
int fh_parent_pos(FullHist* fh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } FullHist* par = fh->back; if(!par) return stopint; int ans = par->preTerm; if(ans < 2 && toBe(par->hd->lexeme())) return 48; return ans; }
int fh_grandparent_pos(FullHist* fh) { static int stopint = 0; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } FullHist* par = fh->back; if(!par) return stopint; par = par->back; if(!par) return stopint; return par->preTerm; }