本文整理汇总了C++中TNode::ch方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::ch方法的具体用法?C++ TNode::ch怎么用?C++ TNode::ch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNode
的用法示例。
在下文中一共展示了TNode::ch方法的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()];
}
示例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;
}
}
示例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;
}