提交 0cc1a74c 编写于 作者: Y Yibing Liu

skip scoring the end when using character-based scorer

上级 73c3a602
......@@ -148,11 +148,11 @@ std::vector<std::pair<double, std::string>> ctc_beam_search_decoder(
}
} // end of loop over time
// score the last word/character of each prefix
if (ext_scorer != nullptr) {
// score the last word of each prefix that doesn't end with space
if (ext_scorer != nullptr && !ext_scorer->is_character_based()) {
for (size_t i = 0; i < beam_size && i < prefixes.size(); ++i) {
auto prefix = prefixes[i];
if (prefix->character != space_id && !prefix->is_empty()) {
if (!prefix->is_empty() && prefix->character != space_id) {
float score = 0.0;
std::vector<std::string> ngram = ext_scorer->make_ngram(prefix);
score = ext_scorer->get_log_cond_prob(ngram) * ext_scorer->alpha;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册