示例#1
0
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;
}
示例#2
0
InputTree*
tree_grandparent_tree(TreeHist* treeh)
{
    InputTree* tree = treeh->tree;
    InputTree* pt = tree->parent();
    if(!pt) return NULL;
    if(pt->headTree() == tree->headTree()) return NULL;
    pt = pt->parent();
    if(!pt) return NULL;
    if(pt->headTree() == tree->headTree()) return NULL;
    return pt;
}
示例#3
0
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();
}
示例#4
0
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;
}
示例#5
0
int
tree_grandparent_term(TreeHist* treeh)
{
    static int s1int = 0;
    if(!s1int)
    {
        ECString s1nm("S1");
        s1int = Term::get(s1nm)->toInt();
    }
    InputTree* tree = treeh->tree;
    InputTree* par = tree->parent();
    if(!par) return s1int;
    InputTree* gpar = par->parent();
    if(!gpar) return s1int;
    const ECString& trmStr  = gpar->term();
    const Term* trm = Term::get(trmStr);
    assert(trm);
    assert(!trm->terminal_p());
    return trm->toInt();
}
示例#6
0
int
tree_ccparent_term(TreeHist* treeh)
{
    static int s1int = 0;
    if(!s1int)
    {
        ECString s1nm("S1");
        s1int = Term::get(s1nm)->toInt();
    }
    assert(treeh);
    InputTree* tree = treeh->tree;
    assert(tree);
    InputTree* par = tree->parent();
    if(!par) return s1int;
    const ECString& trmStr  = par->term();
    const Term* trm = Term::get(trmStr);
    assert(trm);
    int trmInt = trm->toInt();
    if(trmStr != tree->term()) return trmInt; //??? new;
    assert(!trm->terminal_p());
    int ccedtrmInt = ccIndFromTree(par);
    return ccedtrmInt;
}