Skip to content

Commit

Permalink
Automated g4 rollback of changelist 575114935.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

This rollback turned out to be conflicting, and we will retry rollback steps.

*** Original change description ***

Automated g4 rollback of changelist 568386718.

*** Reason for rollback ***

This CL in A release will cause unintended regression because corresponding CL is also rollbacked.

Because the CL is working perfectly with another CLs, this will be rollbacked again after cherry-picked into A release.

*** Original change description ***

Remove special treatment of 'サジェストのみ(SUGGESTION_ONLY)' from Android User Dictionary files.

This implementation is introduced in cl/424818781 to provid...

***

PiperOrigin-RevId: 575153063
  • Loading branch information
ensan-hcl authored and coooooooozy committed Nov 25, 2023
1 parent 0d4cdb6 commit 408ce37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
14 changes: 0 additions & 14 deletions src/dictionary/user_dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ class UserDictionary::TokensIndex {
continue;
}

const bool is_shortcuts =
(dic.name() == "__auto_imported_android_shortcuts_dictionary");

for (const UserDictionaryStorage::UserDictionaryEntry &entry :
dic.entries()) {
if (!UserDictionaryUtil::IsValidEntry(*user_pos_, entry)) {
Expand Down Expand Up @@ -217,17 +214,6 @@ class UserDictionary::TokensIndex {
absl::StripAsciiWhitespace(entry.comment());
for (auto &token : tokens) {
strings::Assign(token.comment, comment);
if (is_shortcuts &&
token.has_attribute(UserPos::Token::SUGGESTION_ONLY)) {
// Words fed by Android shortcut are registered as SUGGESTION_ONLY
// POS in order to minimize the side-effect of extremely short
// reading. However, user expect that they should appear in the
// normal conversion. Here we replace the attribute from
// SUGGESTION_ONLY to SHORTCUT, which has more adaptive cost based
// on the length of the key.
token.remove_attribute(UserPos::Token::SUGGESTION_ONLY);
token.add_attribute(UserPos::Token::SHORTCUT);
}
user_pos_tokens_.push_back(std::move(token));
}
}
Expand Down
17 changes: 14 additions & 3 deletions src/dictionary/user_dictionary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,18 @@ TEST_F(UserDictionaryTest, TestLookupWithShortCut) {
entry->set_value("noun");
entry->set_pos(user_dictionary::UserDictionary::NOUN);

// SUGGESTION ONLY word is handled as SHORTCUT word.
// SUGGESTION ONLY word is not handled as SHORTCUT word.
entry = dic->add_entries();
entry->set_key("key");
entry->set_value("suggest_only");
entry->set_pos(user_dictionary::UserDictionary::SUGGESTION_ONLY);

// NO POS word is handled as SHORTCUT word.
entry = dic->add_entries();
entry->set_key("key");
entry->set_value("no_pos");
entry->set_pos(user_dictionary::UserDictionary::NO_POS);

user_dic->Load(storage.GetProto());
}

Expand All @@ -601,13 +607,18 @@ TEST_F(UserDictionaryTest, TestLookupWithShortCut) {
const uint16_t kUnknownId = pos_matcher.GetUnknownId();
const Entry kExpected2[] = {
{"key", "noun", kNounId, kNounId},
{"key", "no_pos", kUnknownId, kUnknownId},
};
const Entry kExpectedPrediction[] = {
{"key", "noun", kNounId, kNounId},
{"key", "no_pos", kUnknownId, kUnknownId},
{"key", "suggest_only", kUnknownId, kUnknownId},
};

EXPECT_TRUE(TestLookupExactHelper(kExpected2, std::size(kExpected2), "key", 3,
*user_dic));
EXPECT_TRUE(TestLookupPredictiveHelper(kExpected2, std::size(kExpected2),
"ke", *user_dic));
EXPECT_TRUE(TestLookupPredictiveHelper(kExpectedPrediction,
std::size(kExpectedPrediction), "ke", *user_dic));
EXPECT_TRUE(TestLookupPrefixHelper(kExpected2, std::size(kExpected2),
"keykey", 3, *user_dic));
}
Expand Down

0 comments on commit 408ce37

Please sign in to comment.