Skip to content

Commit

Permalink
Clean up experimental flag: apply_user_segment_history_rewriter_for_p…
Browse files Browse the repository at this point in the history
…rediction, user_segment_history_rewriter_use_inner_segments

#codehealth

PiperOrigin-RevId: 670113068
  • Loading branch information
Toshiyuki Hanaoka authored and hiroyuki-komatsu committed Sep 2, 2024
1 parent 19f2e31 commit 1157a24
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Enable IME
SEND_KEY ON

MERGE_DECODER_EXPERIMENT_PARAMS apply_user_segment_history_rewriter_for_prediction: true

# Switch to 12keys-hiragana keyboard layout.
UPDATE_MOBILE_KEYBOARD FLICK_TO_HIRAGANA SPACE_OR_CONVERT_KEEPING_COMPOSITION
SWITCH_INPUT_MODE HIRAGANA
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# Enable IME
SEND_KEY ON

SET_MOBILE_REQUEST

# Switch to 12keys-hiragana keyboard layout.
UPDATE_MOBILE_KEYBOARD FLICK_TO_HIRAGANA SPACE_OR_CONVERT_KEEPING_COMPOSITION
SWITCH_INPUT_MODE HIRAGANA


# Check if the user history is working for suggestion
# 1. "" is the top candidate for "あい"
# 1. "合い" is the top candidate for "あい"
# 2. Submit "あい"
# 3. "あい" should be the top candidate by user history learning
RESET_CONTEXT
SEND_KEYS 1_
EXPECT_PREEDIT あい
EXPECT_CANDIDATE 0 相
EXPECT_IN_ALL_CANDIDATE_WORDS 相
EXPECT_CANDIDATE 0 合い
EXPECT_IN_ALL_CANDIDATE_WORDS あい
SUBMIT_CANDIDATE_BY_VALUE あい
EXPECT_RESULT あい
Expand All @@ -27,13 +24,13 @@ EXPECT_PREEDIT あい
EXPECT_CANDIDATE 0 あい

# Check if the CLEAR_USER_PREDICTION is working
# "" should be the top candidate after CLEAR_USER_PREDICTION command
# "合い" should be the top candidate after CLEAR_USER_PREDICTION command
CLEAR_USER_PREDICTION

RESET_CONTEXT
SEND_KEYS 1_
EXPECT_PREEDIT あい
EXPECT_CANDIDATE 0
EXPECT_CANDIDATE 0 合い

# Check if the REVERT by BACKSPACE is working
# 1. "相" is the top candidate for "あい"
Expand All @@ -43,8 +40,7 @@ EXPECT_CANDIDATE 0 相
RESET_CONTEXT
SEND_KEYS 1_
EXPECT_PREEDIT あい
EXPECT_CANDIDATE 0 相
EXPECT_IN_ALL_CANDIDATE_WORDS 相
EXPECT_CANDIDATE 0 合い
EXPECT_IN_ALL_CANDIDATE_WORDS あい
SUBMIT_CANDIDATE_BY_VALUE あい
EXPECT_RESULT あい
Expand All @@ -53,6 +49,6 @@ SEND_KEY BACKSPACE
RESET_CONTEXT
SEND_KEYS 1_
EXPECT_PREEDIT あい
EXPECT_CANDIDATE 0
EXPECT_CANDIDATE 0 合い

CLEAR_USER_PREDICTION
6 changes: 1 addition & 5 deletions src/prediction/dictionary_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1134,11 +1134,7 @@ void DictionaryPredictor::SetPredictionCostForMixedConversion(
MOZC_WORD_LOG(result, absl::StrCat("SetPredictionCost: ", result.cost));
}

if (request.request()
.decoder_experiment_params()
.apply_user_segment_history_rewriter_for_prediction()) {
MaybeFixRealtimeTopCost(input_key, *results);
}
MaybeFixRealtimeTopCost(input_key, *results);
}

// static
Expand Down
2 changes: 0 additions & 2 deletions src/prediction/dictionary_predictor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,6 @@ TEST_F(DictionaryPredictorTest, FixSRealtimeTopCandidatesCostOnMobile) {
data_and_predictor->predictor();
// turn on mobile mode
request_test_util::FillMobileRequest(request_.get());
request_->mutable_decoder_experiment_params()
->set_apply_user_segment_history_rewriter_for_prediction(true);

{
MockAggregator *aggregator = data_and_predictor->mutable_aggregator();
Expand Down
5 changes: 0 additions & 5 deletions src/protocol/commands.proto
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,6 @@ message DecoderExperimentParams {
optional bool enable_findability_oriented_order = 42 [default = false];
optional int32 findability_oriented_order_top_size = 43 [default = 10];

optional bool apply_user_segment_history_rewriter_for_prediction = 44
[default = false];
optional bool user_segment_history_rewriter_use_inner_segments = 54
[default = false];

// Changes the size of history with character coverage.
optional int32 user_history_prediction_max_char_coverage = 82 [default = 0];

Expand Down
4 changes: 1 addition & 3 deletions src/rewriter/user_segment_history_rewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ bool IsNumberStyleLearningEnabled(const ConversionRequest &request) {
}

bool UseInnerSegments(const ConversionRequest &request) {
return request.request()
.decoder_experiment_params()
.user_segment_history_rewriter_use_inner_segments();
return request.request().mixed_conversion();
}

class FeatureValue {
Expand Down
3 changes: 1 addition & 2 deletions src/rewriter/user_segment_history_rewriter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,7 @@ TEST_F(UserSegmentHistoryRewriterTest, AnnotationAfterLearning) {
}

TEST_F(UserSegmentHistoryRewriterTest, SupportInnerSegmentsOnLearning) {
request_->mutable_decoder_experiment_params()
->set_user_segment_history_rewriter_use_inner_segments(true);
request_test_util::FillMobileRequest(request_.get());
Segments segments;
std::unique_ptr<UserSegmentHistoryRewriter> rewriter(
CreateUserSegmentHistoryRewriter());
Expand Down
19 changes: 3 additions & 16 deletions src/session/session_handler_scenario_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ const char *kScenarioFileList[] = {
DATA_DIR "handwriting.txt",
DATA_DIR "insert_characters.txt",
DATA_DIR "mobile_partial_variant_candidates.txt",
DATA_DIR "mobile_revert_user_history_learning.txt",
DATA_DIR "on_off_cancel.txt",
DATA_DIR "partial_suggestion.txt",
DATA_DIR "pending_character.txt",
Expand Down Expand Up @@ -269,12 +268,13 @@ class SessionHandlerScenarioTestForRequest

const char *kScenariosForExperimentParams[] = {
#define DATA_DIR "test/session/scenario/"
DATA_DIR "mobile_apply_user_segment_history_rewriter.txt",
DATA_DIR "mobile_delete_history.txt",
DATA_DIR "mobile_zero_query.txt",
DATA_DIR "mobile_preedit.txt",
DATA_DIR "mobile_apply_user_segment_history_rewriter.txt",
DATA_DIR "mobile_qwerty_transliteration_scenario.txt",
DATA_DIR "mobile_revert_user_history_learning.txt",
DATA_DIR "mobile_t13n_candidates.txt",
DATA_DIR "mobile_zero_query.txt",
#undef DATA_DIR
};

Expand Down Expand Up @@ -302,19 +302,6 @@ INSTANTIATE_TEST_SUITE_P(
request.mutable_decoder_experiment_params()
->set_enable_findability_oriented_order(true);
return request;
}(),
[]() {
auto request = GetMobileRequest();
request.mutable_decoder_experiment_params()
->set_apply_user_segment_history_rewriter_for_prediction(
true);
return request;
}(),
[]() {
auto request = GetMobileRequest();
request.mutable_decoder_experiment_params()
->set_user_segment_history_rewriter_use_inner_segments(true);
return request;
}())));

TEST_P(SessionHandlerScenarioTestForRequest, TestImplBase) {
Expand Down

0 comments on commit 1157a24

Please sign in to comment.