Skip to content

Commit cb0b430

Browse files
taku910hiroyuki-komatsu
authored andcommitted
Stop concatenating last LRU entry and committed punctuation.
This feature is not enabled on mobile. PiperOrigin-RevId: 763701429
1 parent ea56700 commit cb0b430

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

src/prediction/user_history_predictor.cc

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,42 +1847,6 @@ void UserHistoryPredictor::Finish(const ConversionRequest &request,
18471847

18481848
RevertEntries revert_entries;
18491849

1850-
// If user inputs a punctuation just after some long sentence,
1851-
// we make a new candidate by concatenating the top element in LRU and
1852-
// the punctuation user input. The top element in LRU is supposed to be
1853-
// the long sentence user input before.
1854-
// This is a fix for http://b/issue?id=2216838
1855-
//
1856-
// Note: We don't make such candidates for mobile.
1857-
if (!request.request().zero_query_suggestion() && !dic_->empty() &&
1858-
dic_->Head()->value.last_access_time() + 5 > last_access_time &&
1859-
// Check if the current value is a punctuation.
1860-
segments.conversion_segments_size() == 1 &&
1861-
segments.conversion_segment(0).candidates_size() > 0 &&
1862-
IsPunctuation(segments.conversion_segment(0).candidate(0).value) &&
1863-
// Check if the previous value looks like a sentence.
1864-
!segments.history_segments().empty() &&
1865-
segments.history_segments().back().candidates_size() > 0 &&
1866-
IsSentenceLikeCandidate(
1867-
segments.history_segments().back().candidate(0))) {
1868-
const Entry *entry = &(dic_->Head()->value);
1869-
DCHECK(entry);
1870-
absl::string_view last_value =
1871-
segments.history_segments().back().candidate(0).value;
1872-
// Check if the head value in LRU ends with the candidate value in history
1873-
// segments.
1874-
if (entry->value().ends_with(last_value)) {
1875-
const Segment::Candidate &candidate =
1876-
segments.conversion_segment(0).candidate(0);
1877-
// Uses the same last_access_time stored in the top element
1878-
// so that this item can be grouped together.
1879-
TryInsert(request, absl::StrCat(entry->key(), candidate.key),
1880-
absl::StrCat(entry->value(), candidate.value),
1881-
entry->description(), is_suggestion, {},
1882-
entry->last_access_time(), &revert_entries);
1883-
}
1884-
}
1885-
18861850
InsertHistory(request, is_suggestion, last_access_time, segments,
18871851
&revert_entries);
18881852

src/prediction/user_history_predictor_test.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,9 +1394,8 @@ TEST_F(UserHistoryPredictorTest, HistoryToPunctuation) {
13941394
const ConversionRequest convreq6 =
13951395
SetUpInputForPrediction("おつかれ", &composer_, &segments);
13961396
results = predictor->Predict(convreq6);
1397-
ASSERT_FALSE(results.empty());
1397+
ASSERT_EQ(results.size(), 1);
13981398
EXPECT_EQ(results[0].value, "お疲れ様です");
1399-
EXPECT_EQ(results[1].value, "お疲れ様です。");
14001399
}
14011400

14021401
TEST_F(UserHistoryPredictorTest, UserHistoryPredictorPrecedingPunctuation) {
@@ -4559,8 +4558,6 @@ TEST_F(UserHistoryPredictorTest, PunctuationLinkDesktop) {
45594558
WaitForSyncer(predictor);
45604559

45614560
{
4562-
// Note that "よろしくお願いします:よろしくおねがいします" is the sentence
4563-
// like candidate. Please refer to user_history_predictor.cc
45644561
const ConversionRequest convreq1 = SetUpInputForConversion(
45654562
"よろしくおねがいします", &composer_, &segments);
45664563
AddCandidate(0, "よろしくお願いします", &segments);
@@ -4577,7 +4574,7 @@ TEST_F(UserHistoryPredictorTest, PunctuationLinkDesktop) {
45774574
"よろしくおねがいします", &composer_, &segments);
45784575
results = predictor->Predict(convreq2);
45794576
EXPECT_FALSE(results.empty());
4580-
EXPECT_TRUE(FindCandidateByValue("よろしくお願いします", results));
4577+
EXPECT_TRUE(FindCandidateByValue("よろしくお願いします", results));
45814578
}
45824579
}
45834580

0 commit comments

Comments
 (0)