Skip to content

Commit

Permalink
Fix bugs the seed score computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
taku910 committed Apr 15, 2023
1 parent 518c57c commit d9a2b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/unigram_model_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ TrainerModel::SentencePieces Trainer::MakeSeedSentencePiecesInternal() {

// character-wise coverage is the default score.
const node_int_type freq = R[i] - L[i];
const node_int_type score = freq * freq;
const node_int_type score = freq * len;

const auto w = string_util::UnicodeTextToUTF8(uw);
queue.push(w, score);
Expand Down
11 changes: 6 additions & 5 deletions src/unigram_model_trainer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ TEST(UnigramTrainerTest, BasicTest) {

// Check final pieces.
EXPECT_EQ(
"Overly Pineapple magnanimity Available ▁an a ▁ b A t g r P O v m y p n "
"l d e h i",
"Overly Pineapple magnanimity Available ▁an ▁ a b A t g r P O v m y p n "
"l h d e i",
res.sentence_pieces);
}

Expand Down Expand Up @@ -192,11 +192,12 @@ TEST(UnigramTrainerTest, EndToEndTest) {
.ok());
// TODO(taku): Temporally disable this test on Windows.
#ifndef OS_WIN
LOG(INFO) << "[" << absl::StrJoin(tok, " ") << std::endl;
EXPECT_EQ(
WS
" 吾輩 《 わ が は い 》 は猫である 。 名前は まだ 無 い 。 どこ で 生れ "
" か とん と 見当 《 けん とう 》 が つか ぬ 。 何でも 薄 暗 い じめ "
"じめ した 所で ニャーニャー 泣 い ていた 事 だけ は記憶している",
" 吾輩 《 わ が は い 》 は猫である 。 名前はまだ 無 い 。 どこ で "
"れた か とん と 見当 《 けん とう 》 が つか ぬ 。 何でも 薄 暗 い じめ "
"じめ した 所で ニャーニャー 泣 い ていた 事 だけは 記憶 している",
absl::StrJoin(tok, " "));
#endif
}
Expand Down

0 comments on commit d9a2b21

Please sign in to comment.