int tree_grandparent_head(TreeHist* treeh) { InputTree* tree = treeh->tree; InputTree* pt = tree->parent(); static int topInt = -1; if(topInt < 0) { ECString temp("^^"); topInt = Pst::get(temp)->toInt(); } if(!pt) return topInt; pt = pt->parent(); if(!pt) return topInt; char temp[1024]; ECString wrdStr(langAwareToLower(pt->head().c_str(),temp)); const WordInfo* wi = Pst::get(wrdStr); if(!wi) { cerr << *tree << endl; assert(wi); } int ans = wi->toInt(); assert(ans >= 0); return ans; }
int tree_parent_pos(TreeHist* treeh) { static int stopint = 0; InputTree* tree = treeh->tree; if(!stopint) { ECString stopnm("STOP"); stopint = Term::get(stopnm)->toInt(); } InputTree* par = tree->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()); } int ans = trm->toInt(); if(ans < 2 && toBe(par->head())) return 48; return ans; }