当前位置: 首页>>代码示例>>C++>>正文


C++ TNode::bon方法代码示例

本文整理汇总了C++中TNode::bon方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::bon方法的具体用法?C++ TNode::bon怎么用?C++ TNode::bon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TNode的用法示例。


在下文中一共展示了TNode::bon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

/**
* return value as the model suggested. The history state must be historified
* or the history's level should be 0. when level == 0 but idx != 0, the
* history is a psuedo unigram state used for this model to combine another
* bigram cache language model
*/
double
CThreadSlm::rawTransfer(TState history, unsigned int wid, TState& result)
{
    unsigned int lvl = history.getLevel();
    unsigned int pos = history.getIdx();

    double cost = (m_UseLogPr)?0.0:1.0;

    // NON_Word id must be dealed with special, let it transfer to root
    // without any cost
    if (ID_NOT_WORD == wid) {
        result = 0;
        return cost;
    }

    while (true) {
        //for psuedo cache model unigram state
        TNode* pn = ((TNode *)m_Levels[lvl]) + ((lvl)?pos:0);

        unsigned int t = (pn+1)->ch();

        if (lvl < m_N-1) {
            TNode* pBase =(TNode*)m_Levels[lvl+1];
            unsigned int idx = find_id(pBase, pn->ch(), t, wid);
            if (idx != t) {
                result.setIdx(idx);
                result.setLevel(lvl+1);
                double pr = m_prTable[pBase[idx].pr()];
                return (m_UseLogPr)?(cost+pr):(cost*pr);
            }

        } else {
            TLeaf* pBase =(TLeaf*)m_Levels[lvl+1];
            unsigned int idx = find_id(pBase, pn->ch(), t, wid);
            if (idx != t) {
                result.setIdx(idx);
                result.setLevel(lvl+1);
                double pr = m_prTable[pBase[idx].pr()];
                return (m_UseLogPr)?(cost+pr):(cost*pr);
            }

        }

        if (m_UseLogPr)
            cost += m_bowTable[pn->bow()];
        else
            cost *= m_bowTable[pn->bow()];
        if (lvl == 0)
            break;
        lvl = pn->bol();
        pos = pn->bon();
    }
    result.setLevel(0);
    result.setIdx(0);
    if (m_UseLogPr)
        return cost + m_prTable[((TNode *)m_Levels[0])->pr()];
    else
        return cost * m_prTable[((TNode *)m_Levels[0])->pr()];
}
开发者ID:XueWei,项目名称:sunpinyin,代码行数:65,代码来源:slm.cpp

示例2: TState

CThreadSlm::TState
CThreadSlm::history_state_of(TState st)
{
    if (st.getLevel() >= m_N) {
        TLeaf* pl = ((TLeaf *)m_Levels[m_N]) + st.getIdx();
        return TState(pl->bol(), pl->bon());
    } else {
        TNode* pn = ((TNode *)m_Levels[st.getLevel()]) + st.getIdx();
        if (pn->ch() == (pn+1)->ch())
            return TState(pn->bol(), pn->bon());
        else
            return st;
    }
}
开发者ID:XueWei,项目名称:sunpinyin,代码行数:14,代码来源:slm.cpp

示例3:

CThreadSlm::TState&
CThreadSlm::historify(TState& st)
{
    if (st.getLevel() >= m_N) {
        TLeaf* pl = ((TLeaf *)m_Levels[m_N]) + st.getIdx();
        st.setLevel(pl->bol());
        st.setIdx(pl->bon());
    } else {
        TNode* pn = ((TNode *)m_Levels[st.getLevel()]) + st.getIdx();
        if (pn->ch() == (pn+1)->ch()) {
            st.setLevel(pn->bol());
            st.setIdx(pn->bon());
        }
    }
    return st;
}
开发者ID:XueWei,项目名称:sunpinyin,代码行数:16,代码来源:slm.cpp


注:本文中的TNode::bon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。