Commit 2432386c by xiaotong

fix the bug of checking complete hypotheses

parent e4e51628
...@@ -470,9 +470,13 @@ void T2TSearch::Collect(T2TStateBundle * beam) ...@@ -470,9 +470,13 @@ void T2TSearch::Collect(T2TStateBundle * beam)
CheckNTErrors(state.pid >= 0 && state.pid < batchSize, CheckNTErrors(state.pid >= 0 && state.pid < batchSize,
"Invalid sample id!"); "Invalid sample id!");
/* check if this is the first end symbol. It is false
if there have been end symbols in previously generated words. */
bool isComplted = state.isCompleted && (state.last == NULL || !state.last->isCompleted);
/* we push the hypothesis into the heap when it is completed */ /* we push the hypothesis into the heap when it is completed */
if(state.isEnd) if(state.isEnd && isComplted)
fullHypos[state.pid].Push(HeapNode<float>(&state, state.modelScore)); fullHypos[state.pid].Push(HeapNode<float>(&state, state.modelScore));
} }
} }
...@@ -494,9 +498,13 @@ void T2TSearch::FillHeap(T2TStateBundle * beam) ...@@ -494,9 +498,13 @@ void T2TSearch::FillHeap(T2TStateBundle * beam)
CheckNTErrors(state.pid >= 0 && state.pid < batchSize, CheckNTErrors(state.pid >= 0 && state.pid < batchSize,
"Invalid sample id!"); "Invalid sample id!");
/* check if this is the first end symbol. It is false
if there have been end symbols in previously generated words. */
bool isComplted = state.isCompleted && (state.last == NULL || !state.last->isCompleted);
/* we push the imcomplete hypothesis into the heap */ /* we push the imcomplete hypothesis into the heap */
if (emptyFlags[state.pid] && state.isEnd == 0) if (emptyFlags[state.pid] && state.isEnd && isComplted)
fullHypos[state.pid].Push(HeapNode<float>(&state, state.modelScore)); fullHypos[state.pid].Push(HeapNode<float>(&state, state.modelScore));
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论