skip scoring the end when using character-based scorer

pull/2/head
Yibing Liu 8 years ago
parent 921c6d0cc1
commit 4b20a7029c

@ -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;

Loading…
Cancel
Save