From 1157a24ac2d0c0953d145a0b08250585854a62fc Mon Sep 17 00:00:00 2001 From: Toshiyuki Hanaoka Date: Mon, 2 Sep 2024 08:01:55 +0000 Subject: [PATCH] Clean up experimental flag: apply_user_segment_history_rewriter_for_prediction, user_segment_history_rewriter_use_inner_segments #codehealth PiperOrigin-RevId: 670113068 --- ...le_apply_user_segment_history_rewriter.txt | 2 -- .../mobile_revert_user_history_learning.txt | 16 ++++++---------- src/prediction/dictionary_predictor.cc | 6 +----- src/prediction/dictionary_predictor_test.cc | 2 -- src/protocol/commands.proto | 5 ----- src/rewriter/user_segment_history_rewriter.cc | 4 +--- .../user_segment_history_rewriter_test.cc | 3 +-- src/session/session_handler_scenario_test.cc | 19 +++---------------- 8 files changed, 12 insertions(+), 45 deletions(-) diff --git a/src/data/test/session/scenario/mobile_apply_user_segment_history_rewriter.txt b/src/data/test/session/scenario/mobile_apply_user_segment_history_rewriter.txt index b43045e49..207e16cad 100644 --- a/src/data/test/session/scenario/mobile_apply_user_segment_history_rewriter.txt +++ b/src/data/test/session/scenario/mobile_apply_user_segment_history_rewriter.txt @@ -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 diff --git a/src/data/test/session/scenario/mobile_revert_user_history_learning.txt b/src/data/test/session/scenario/mobile_revert_user_history_learning.txt index 9a1d26642..ccfcafae0 100644 --- a/src/data/test/session/scenario/mobile_revert_user_history_learning.txt +++ b/src/data/test/session/scenario/mobile_revert_user_history_learning.txt @@ -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 あい @@ -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 "あい" @@ -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 あい @@ -53,6 +49,6 @@ SEND_KEY BACKSPACE RESET_CONTEXT SEND_KEYS 1_ EXPECT_PREEDIT あい -EXPECT_CANDIDATE 0 相 +EXPECT_CANDIDATE 0 合い CLEAR_USER_PREDICTION diff --git a/src/prediction/dictionary_predictor.cc b/src/prediction/dictionary_predictor.cc index a01c5a8ee..46e231fb8 100644 --- a/src/prediction/dictionary_predictor.cc +++ b/src/prediction/dictionary_predictor.cc @@ -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 diff --git a/src/prediction/dictionary_predictor_test.cc b/src/prediction/dictionary_predictor_test.cc index 0a7e1b6f9..e949a8c98 100644 --- a/src/prediction/dictionary_predictor_test.cc +++ b/src/prediction/dictionary_predictor_test.cc @@ -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(); diff --git a/src/protocol/commands.proto b/src/protocol/commands.proto index 3d942f0eb..d43363a0f 100644 --- a/src/protocol/commands.proto +++ b/src/protocol/commands.proto @@ -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]; diff --git a/src/rewriter/user_segment_history_rewriter.cc b/src/rewriter/user_segment_history_rewriter.cc index abd557e52..4275ad091 100644 --- a/src/rewriter/user_segment_history_rewriter.cc +++ b/src/rewriter/user_segment_history_rewriter.cc @@ -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 { diff --git a/src/rewriter/user_segment_history_rewriter_test.cc b/src/rewriter/user_segment_history_rewriter_test.cc index ac1ff4119..4bbc0620d 100644 --- a/src/rewriter/user_segment_history_rewriter_test.cc +++ b/src/rewriter/user_segment_history_rewriter_test.cc @@ -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 rewriter( CreateUserSegmentHistoryRewriter()); diff --git a/src/session/session_handler_scenario_test.cc b/src/session/session_handler_scenario_test.cc index 9ac75721e..c4a9075b5 100644 --- a/src/session/session_handler_scenario_test.cc +++ b/src/session/session_handler_scenario_test.cc @@ -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", @@ -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 }; @@ -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) {