mirror of
https://github.com/mii443/mozc.git
synced 2025-08-31 04:19:20 +00:00
Remove the WithKey functions from ConverterInterface.
* These methods are not used in production code. * This is a preparation for updates with ConversionRequest in following CLs. #codehealth PiperOrigin-RevId: 699935170
This commit is contained in:
@ -512,8 +512,6 @@ mozc_cc_test(
|
|||||||
":converter_interface",
|
":converter_interface",
|
||||||
":segments",
|
":segments",
|
||||||
"//composer",
|
"//composer",
|
||||||
"//composer:table",
|
|
||||||
"//config:config_handler",
|
|
||||||
"//engine:engine_factory",
|
"//engine:engine_factory",
|
||||||
"//engine:engine_interface",
|
"//engine:engine_interface",
|
||||||
"//protocol:commands_cc_proto",
|
"//protocol:commands_cc_proto",
|
||||||
@ -521,6 +519,7 @@ mozc_cc_test(
|
|||||||
"//testing:gunit_main",
|
"//testing:gunit_main",
|
||||||
"//testing:mozctest",
|
"//testing:mozctest",
|
||||||
"@com_google_absl//absl/log:check",
|
"@com_google_absl//absl/log:check",
|
||||||
|
"@com_google_absl//absl/strings:string_view",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -294,15 +294,6 @@ bool Converter::StartConversion(const ConversionRequest &original_request,
|
|||||||
return Convert(request, conversion_key, segments);
|
return Convert(request, conversion_key, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Converter::StartConversionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const {
|
|
||||||
if (key.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const ConversionRequest default_request;
|
|
||||||
return Convert(default_request, key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Converter::Convert(const ConversionRequest &request,
|
bool Converter::Convert(const ConversionRequest &request,
|
||||||
const absl::string_view key, Segments *segments) const {
|
const absl::string_view key, Segments *segments) const {
|
||||||
SetKey(segments, key);
|
SetKey(segments, key);
|
||||||
@ -430,24 +421,6 @@ bool Converter::StartPrediction(const ConversionRequest &original_request,
|
|||||||
return Predict(request, prediction_key, segments);
|
return Predict(request, prediction_key, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Converter::StartPredictionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const {
|
|
||||||
const ConversionRequest default_request =
|
|
||||||
ConversionRequestBuilder()
|
|
||||||
.SetOptions({.request_type = ConversionRequest::PREDICTION})
|
|
||||||
.Build();
|
|
||||||
return Predict(default_request, key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Converter::StartSuggestionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const {
|
|
||||||
const ConversionRequest default_request =
|
|
||||||
ConversionRequestBuilder()
|
|
||||||
.SetOptions({.request_type = ConversionRequest::SUGGESTION})
|
|
||||||
.Build();
|
|
||||||
return Predict(default_request, key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Converter::StartSuggestion(const ConversionRequest &original_request,
|
bool Converter::StartSuggestion(const ConversionRequest &original_request,
|
||||||
Segments *segments) const {
|
Segments *segments) const {
|
||||||
const ConversionRequest request = CreateConversionRequestWithType(
|
const ConversionRequest request = CreateConversionRequestWithType(
|
||||||
@ -456,15 +429,6 @@ bool Converter::StartSuggestion(const ConversionRequest &original_request,
|
|||||||
return Predict(request, prediction_key, segments);
|
return Predict(request, prediction_key, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Converter::StartPartialSuggestionWithKey(
|
|
||||||
Segments *segments, const absl::string_view key) const {
|
|
||||||
const ConversionRequest default_request =
|
|
||||||
ConversionRequestBuilder()
|
|
||||||
.SetOptions({.request_type = ConversionRequest::PARTIAL_SUGGESTION})
|
|
||||||
.Build();
|
|
||||||
return Predict(default_request, key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Converter::StartPartialSuggestion(
|
bool Converter::StartPartialSuggestion(
|
||||||
const ConversionRequest &original_request, Segments *segments) const {
|
const ConversionRequest &original_request, Segments *segments) const {
|
||||||
const ConversionRequest request = CreateConversionRequestWithType(
|
const ConversionRequest request = CreateConversionRequestWithType(
|
||||||
@ -480,15 +444,6 @@ bool Converter::StartPartialSuggestion(
|
|||||||
return Predict(request, conversion_key, segments);
|
return Predict(request, conversion_key, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Converter::StartPartialPredictionWithKey(
|
|
||||||
Segments *segments, const absl::string_view key) const {
|
|
||||||
const ConversionRequest default_request =
|
|
||||||
ConversionRequestBuilder()
|
|
||||||
.SetOptions({.request_type = ConversionRequest::PARTIAL_PREDICTION})
|
|
||||||
.Build();
|
|
||||||
return Predict(default_request, key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Converter::StartPartialPrediction(
|
bool Converter::StartPartialPrediction(
|
||||||
const ConversionRequest &original_request, Segments *segments) const {
|
const ConversionRequest &original_request, Segments *segments) const {
|
||||||
const ConversionRequest request = CreateConversionRequestWithType(
|
const ConversionRequest request = CreateConversionRequestWithType(
|
||||||
|
@ -66,35 +66,20 @@ class Converter final : public ConverterInterface {
|
|||||||
bool StartConversion(const ConversionRequest &request,
|
bool StartConversion(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
bool StartConversionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const override;
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
bool StartReverseConversion(Segments *segments,
|
bool StartReverseConversion(Segments *segments,
|
||||||
absl::string_view key) const override;
|
absl::string_view key) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
bool StartPrediction(const ConversionRequest &request,
|
bool StartPrediction(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
bool StartPredictionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const override;
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
bool StartSuggestion(const ConversionRequest &request,
|
bool StartSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
bool StartSuggestionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const override;
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
bool StartPartialPrediction(const ConversionRequest &request,
|
bool StartPartialPrediction(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
bool StartPartialPredictionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const override;
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
bool StartPartialSuggestion(const ConversionRequest &request,
|
bool StartPartialSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
bool StartPartialSuggestionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const override;
|
|
||||||
|
|
||||||
void FinishConversion(const ConversionRequest &request,
|
void FinishConversion(const ConversionRequest &request,
|
||||||
Segments *segments) const override;
|
Segments *segments) const override;
|
||||||
|
@ -58,12 +58,6 @@ class ConverterInterface {
|
|||||||
virtual bool StartConversion(const ConversionRequest &request,
|
virtual bool StartConversion(const ConversionRequest &request,
|
||||||
Segments *segments) const = 0;
|
Segments *segments) const = 0;
|
||||||
|
|
||||||
// Start conversion with key.
|
|
||||||
// key is a request written in Hiragana sequence
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
virtual bool StartConversionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const = 0;
|
|
||||||
|
|
||||||
// Start reverse conversion with key.
|
// Start reverse conversion with key.
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
virtual bool StartReverseConversion(Segments *segments,
|
virtual bool StartReverseConversion(Segments *segments,
|
||||||
@ -74,41 +68,21 @@ class ConverterInterface {
|
|||||||
virtual bool StartPrediction(const ConversionRequest &request,
|
virtual bool StartPrediction(const ConversionRequest &request,
|
||||||
Segments *segments) const = 0;
|
Segments *segments) const = 0;
|
||||||
|
|
||||||
// Start prediction with key (request_type = PREDICTION)
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
virtual bool StartPredictionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const = 0;
|
|
||||||
|
|
||||||
// Starts suggestion for given request.
|
// Starts suggestion for given request.
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
virtual bool StartSuggestion(const ConversionRequest &request,
|
virtual bool StartSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const = 0;
|
Segments *segments) const = 0;
|
||||||
|
|
||||||
// Start suggestion with key (request_type = SUGGESTION)
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
virtual bool StartSuggestionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const = 0;
|
|
||||||
|
|
||||||
// Starts partial prediction for given request.
|
// Starts partial prediction for given request.
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
virtual bool StartPartialPrediction(const ConversionRequest &request,
|
virtual bool StartPartialPrediction(const ConversionRequest &request,
|
||||||
Segments *segments) const = 0;
|
Segments *segments) const = 0;
|
||||||
|
|
||||||
// Start prediction with key (request_type = PARTIAL_PREDICTION)
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
virtual bool StartPartialPredictionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const = 0;
|
|
||||||
|
|
||||||
// Starts partial suggestion for given request.
|
// Starts partial suggestion for given request.
|
||||||
ABSL_MUST_USE_RESULT
|
ABSL_MUST_USE_RESULT
|
||||||
virtual bool StartPartialSuggestion(const ConversionRequest &request,
|
virtual bool StartPartialSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const = 0;
|
Segments *segments) const = 0;
|
||||||
|
|
||||||
// Start suggestion with key (request_type = PARTIAL_SUGGESTION)
|
|
||||||
ABSL_MUST_USE_RESULT
|
|
||||||
virtual bool StartPartialSuggestionWithKey(Segments *segments,
|
|
||||||
absl::string_view key) const = 0;
|
|
||||||
|
|
||||||
// Finish conversion.
|
// Finish conversion.
|
||||||
// Segments are cleared. Context is not cleared
|
// Segments are cleared. Context is not cleared
|
||||||
virtual void FinishConversion(const ConversionRequest &request,
|
virtual void FinishConversion(const ConversionRequest &request,
|
||||||
|
@ -314,7 +314,11 @@ bool ExecCommand(const ConverterInterface &converter, const std::string &line,
|
|||||||
NumberUtil::SimpleAtoi(fields[2]), // begin pos
|
NumberUtil::SimpleAtoi(fields[2]), // begin pos
|
||||||
NumberUtil::SimpleAtoi(fields[3]), // end pos
|
NumberUtil::SimpleAtoi(fields[3]), // end pos
|
||||||
fields[4]);
|
fields[4]);
|
||||||
const bool result = converter.StartConversionWithKey(segments, fields[1]);
|
composer::Composer composer;
|
||||||
|
composer.SetPreeditTextForTestOnly(fields[1]);
|
||||||
|
const ConversionRequest convreq =
|
||||||
|
ConversionRequestBuilder().SetComposer(composer).Build();
|
||||||
|
const bool result = converter.StartConversion(convreq, segments);
|
||||||
Lattice::ResetDebugDisplayNode();
|
Lattice::ResetDebugDisplayNode();
|
||||||
return result;
|
return result;
|
||||||
} else if (func == "reverseconversion" || func == "reverse" || func == "r") {
|
} else if (func == "reverseconversion" || func == "reverse" || func == "r") {
|
||||||
|
@ -50,30 +50,20 @@ class StrictMockConverter : public ConverterInterface {
|
|||||||
MOCK_METHOD(bool, StartConversion,
|
MOCK_METHOD(bool, StartConversion,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
MOCK_METHOD(bool, StartConversionWithKey,
|
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
|
||||||
MOCK_METHOD(bool, StartReverseConversion,
|
MOCK_METHOD(bool, StartReverseConversion,
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
(Segments * segments, absl::string_view key), (const, override));
|
||||||
MOCK_METHOD(bool, StartPrediction,
|
MOCK_METHOD(bool, StartPrediction,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
MOCK_METHOD(bool, StartPredictionWithKey,
|
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
|
||||||
MOCK_METHOD(bool, StartSuggestion,
|
MOCK_METHOD(bool, StartSuggestion,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
MOCK_METHOD(bool, StartSuggestionWithKey,
|
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
|
||||||
MOCK_METHOD(bool, StartPartialPrediction,
|
MOCK_METHOD(bool, StartPartialPrediction,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
MOCK_METHOD(bool, StartPartialPredictionWithKey,
|
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
|
||||||
MOCK_METHOD(bool, StartPartialSuggestion,
|
MOCK_METHOD(bool, StartPartialSuggestion,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
MOCK_METHOD(bool, StartPartialSuggestionWithKey,
|
|
||||||
(Segments * segments, absl::string_view key), (const, override));
|
|
||||||
MOCK_METHOD(void, FinishConversion,
|
MOCK_METHOD(void, FinishConversion,
|
||||||
(const ConversionRequest &request, Segments *segments),
|
(const ConversionRequest &request, Segments *segments),
|
||||||
(const, override));
|
(const, override));
|
||||||
|
@ -30,9 +30,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/check.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "composer/composer.h"
|
#include "composer/composer.h"
|
||||||
#include "composer/table.h"
|
|
||||||
#include "config/config_handler.h"
|
|
||||||
#include "converter/converter_interface.h"
|
#include "converter/converter_interface.h"
|
||||||
#include "converter/segments.h"
|
#include "converter/segments.h"
|
||||||
#include "engine/engine_factory.h"
|
#include "engine/engine_factory.h"
|
||||||
@ -45,7 +44,11 @@
|
|||||||
namespace mozc {
|
namespace mozc {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ::mozc::composer::Table;
|
ConversionRequest ConvReq(absl::string_view key) {
|
||||||
|
composer::Composer composer;
|
||||||
|
composer.SetPreeditTextForTestOnly(key);
|
||||||
|
return ConversionRequestBuilder().SetComposer(composer).Build();
|
||||||
|
}
|
||||||
|
|
||||||
class ConverterRegressionTest : public testing::TestWithTempUserProfile {};
|
class ConverterRegressionTest : public testing::TestWithTempUserProfile {};
|
||||||
|
|
||||||
@ -56,16 +59,17 @@ TEST_F(ConverterRegressionTest, QueryOfDeathTest) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "りゅきゅけmぽ"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReq("りゅきゅけmぽ"), &segments));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "5.1,||t:1"));
|
EXPECT_TRUE(converter->StartConversion(ConvReq("5.1,||t:1"), &segments));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
// Converter returns false, but not crash.
|
// Converter returns false, but not crash.
|
||||||
EXPECT_FALSE(converter->StartConversionWithKey(&segments, ""));
|
EXPECT_FALSE(converter->StartConversion(ConvReq(""), &segments));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
@ -81,7 +85,7 @@ TEST_F(ConverterRegressionTest, Regression3323108) {
|
|||||||
Segments segments;
|
Segments segments;
|
||||||
|
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
converter->StartConversionWithKey(&segments, "ここではきものをぬぐ"));
|
converter->StartConversion(ConvReq("ここではきものをぬぐ"), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 3);
|
EXPECT_EQ(segments.conversion_segments_size(), 3);
|
||||||
const ConversionRequest default_request;
|
const ConversionRequest default_request;
|
||||||
EXPECT_TRUE(converter->ResizeSegment(&segments, default_request, 1, 2));
|
EXPECT_TRUE(converter->ResizeSegment(&segments, default_request, 1, 2));
|
||||||
|
@ -163,6 +163,12 @@ class InsertPlaceholderWordsRewriter : public RewriterInterface {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ConversionRequest ConvReqWithKey(absl::string_view key) {
|
||||||
|
composer::Composer composer;
|
||||||
|
composer.SetPreeditTextForTestOnly(key);
|
||||||
|
return ConversionRequestBuilder().SetComposer(composer).Build();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class MockPredictor : public mozc::prediction::PredictorInterface {
|
class MockPredictor : public mozc::prediction::PredictorInterface {
|
||||||
@ -385,11 +391,12 @@ TEST_F(ConverterTest, CanConvertTest) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "-"));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey("-"), &segments));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "おきておきて"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey("おきておきて"), &segments));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +410,7 @@ std::string ContextAwareConvert(const std::string &first_key,
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
|
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, first_key));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(first_key), &segments));
|
||||||
|
|
||||||
std::string converted;
|
std::string converted;
|
||||||
int segment_num = 0;
|
int segment_num = 0;
|
||||||
@ -437,7 +444,8 @@ std::string ContextAwareConvert(const std::string &first_key,
|
|||||||
// TODO(team): Use StartConversionForRequest instead of StartConversion.
|
// TODO(team): Use StartConversionForRequest instead of StartConversion.
|
||||||
const ConversionRequest default_request;
|
const ConversionRequest default_request;
|
||||||
converter->FinishConversion(default_request, &segments);
|
converter->FinishConversion(default_request, &segments);
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, second_key));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey(second_key), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), segment_num + 1);
|
EXPECT_EQ(segments.segments_size(), segment_num + 1);
|
||||||
|
|
||||||
return segments.segment(segment_num).candidate(0).value;
|
return segments.segment(segment_num).candidate(0).value;
|
||||||
@ -799,7 +807,8 @@ TEST_F(ConverterTest, CandidateKeyTest) {
|
|||||||
ConverterInterface *converter = engine->GetConverter();
|
ConverterInterface *converter = engine->GetConverter();
|
||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "わたしは"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey("わたしは"), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), 1);
|
EXPECT_EQ(segments.segments_size(), 1);
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたし");
|
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたし");
|
||||||
@ -819,7 +828,8 @@ TEST_F(ConverterTest, Regression3437022) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Make sure convert result is one segment
|
// Make sure convert result is one segment
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey1 + kKey2));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey(kKey1 + kKey2), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value,
|
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value,
|
||||||
kValue1 + kValue2);
|
kValue1 + kValue2);
|
||||||
@ -827,14 +837,14 @@ TEST_F(ConverterTest, Regression3437022) {
|
|||||||
{
|
{
|
||||||
// Make sure we can convert first part
|
// Make sure we can convert first part
|
||||||
segments.Clear();
|
segments.Clear();
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey1));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(kKey1), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, kValue1);
|
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, kValue1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Make sure we can convert last part
|
// Make sure we can convert last part
|
||||||
segments.Clear();
|
segments.Clear();
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey2));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(kKey2), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, kValue2);
|
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, kValue2);
|
||||||
}
|
}
|
||||||
@ -847,7 +857,8 @@ TEST_F(ConverterTest, Regression3437022) {
|
|||||||
dic->AddEntry(kKey1 + kKey2, kValue1 + kValue2);
|
dic->AddEntry(kKey1 + kKey2, kValue1 + kValue2);
|
||||||
dic->UnLock();
|
dic->UnLock();
|
||||||
|
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey1 + kKey2));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey(kKey1 + kKey2), &segments));
|
||||||
|
|
||||||
int rest_size = 0;
|
int rest_size = 0;
|
||||||
for (const Segment &segment : segments.conversion_segments().drop(1)) {
|
for (const Segment &segment : segments.conversion_segments().drop(1)) {
|
||||||
@ -934,7 +945,7 @@ TEST_F(ConverterTest, Regression3046266) {
|
|||||||
|
|
||||||
constexpr char kValueNotExpected[] = "中";
|
constexpr char kValueNotExpected[] = "中";
|
||||||
|
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey1));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(kKey1), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_TRUE(converter->CommitSegmentValue(&segments, 0, 0));
|
EXPECT_TRUE(converter->CommitSegmentValue(&segments, 0, 0));
|
||||||
|
|
||||||
@ -942,7 +953,7 @@ TEST_F(ConverterTest, Regression3046266) {
|
|||||||
const ConversionRequest default_request;
|
const ConversionRequest default_request;
|
||||||
converter->FinishConversion(default_request, &segments);
|
converter->FinishConversion(default_request, &segments);
|
||||||
|
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey2));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(kKey2), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
const Segment &segment = segments.conversion_segment(0);
|
const Segment &segment = segments.conversion_segment(0);
|
||||||
for (size_t i = 0; i < segment.candidates_size(); ++i) {
|
for (size_t i = 0; i < segment.candidates_size(); ++i) {
|
||||||
@ -960,7 +971,7 @@ TEST_F(ConverterTest, Regression5502496) {
|
|||||||
constexpr char kKey[] = "みんあ";
|
constexpr char kKey[] = "みんあ";
|
||||||
constexpr char kValueExpected[] = "みんな";
|
constexpr char kValueExpected[] = "みんな";
|
||||||
|
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, kKey));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey(kKey), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
const Segment &segment = segments.conversion_segment(0);
|
const Segment &segment = segments.conversion_segment(0);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -1037,7 +1048,8 @@ TEST_F(ConverterTest, StartPartialPrediction) {
|
|||||||
ConverterInterface *converter = engine->GetConverter();
|
ConverterInterface *converter = engine->GetConverter();
|
||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPartialPredictionWithKey(&segments, "わたしは"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPartialPrediction(ConvReqWithKey("わたしは"), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), 1);
|
EXPECT_EQ(segments.segments_size(), 1);
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
||||||
@ -1049,7 +1061,8 @@ TEST_F(ConverterTest, StartPartialSuggestion) {
|
|||||||
ConverterInterface *converter = engine->GetConverter();
|
ConverterInterface *converter = engine->GetConverter();
|
||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPartialSuggestionWithKey(&segments, "わたしは"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPartialSuggestion(ConvReqWithKey("わたしは"), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), 1);
|
EXPECT_EQ(segments.segments_size(), 1);
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
||||||
@ -1060,7 +1073,8 @@ TEST_F(ConverterTest, StartPartialPredictionMobile) {
|
|||||||
ConverterInterface *converter = engine->GetConverter();
|
ConverterInterface *converter = engine->GetConverter();
|
||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPartialPredictionWithKey(&segments, "わたしは"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPartialPrediction(ConvReqWithKey("わたしは"), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), 1);
|
EXPECT_EQ(segments.segments_size(), 1);
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
||||||
@ -1071,7 +1085,8 @@ TEST_F(ConverterTest, StartPartialSuggestionMobile) {
|
|||||||
ConverterInterface *converter = engine->GetConverter();
|
ConverterInterface *converter = engine->GetConverter();
|
||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPartialSuggestionWithKey(&segments, "わたしは"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPartialSuggestion(ConvReqWithKey("わたしは"), &segments));
|
||||||
EXPECT_EQ(segments.segments_size(), 1);
|
EXPECT_EQ(segments.segments_size(), 1);
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).key, "わたしは");
|
||||||
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
EXPECT_EQ(segments.segment(0).candidate(0).content_key, "わたしは");
|
||||||
@ -1217,7 +1232,7 @@ TEST_F(ConverterTest, VariantExpansionForSuggestion) {
|
|||||||
Segments segments;
|
Segments segments;
|
||||||
{
|
{
|
||||||
// Dictionary suggestion
|
// Dictionary suggestion
|
||||||
EXPECT_TRUE(converter.StartSuggestionWithKey(&segments, "てすと"));
|
EXPECT_TRUE(converter.StartSuggestion(ConvReqWithKey("てすと"), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_LE(1, segments.conversion_segment(0).candidates_size());
|
EXPECT_LE(1, segments.conversion_segment(0).candidates_size());
|
||||||
EXPECT_TRUE(FindCandidateByValue("<>!?", segments.conversion_segment(0)));
|
EXPECT_TRUE(FindCandidateByValue("<>!?", segments.conversion_segment(0)));
|
||||||
@ -1227,7 +1242,8 @@ TEST_F(ConverterTest, VariantExpansionForSuggestion) {
|
|||||||
{
|
{
|
||||||
// Realtime conversion
|
// Realtime conversion
|
||||||
segments.Clear();
|
segments.Clear();
|
||||||
EXPECT_TRUE(converter.StartSuggestionWithKey(&segments, "てすとの"));
|
EXPECT_TRUE(
|
||||||
|
converter.StartSuggestion(ConvReqWithKey("てすとの"), &segments));
|
||||||
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
EXPECT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_LE(1, segments.conversion_segment(0).candidates_size());
|
EXPECT_LE(1, segments.conversion_segment(0).candidates_size());
|
||||||
EXPECT_TRUE(FindCandidateByValue("<>!?の", segments.conversion_segment(0)));
|
EXPECT_TRUE(FindCandidateByValue("<>!?の", segments.conversion_segment(0)));
|
||||||
@ -1623,7 +1639,7 @@ TEST_F(ConverterTest, UserEntryShouldBePromoted) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "あい"));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey("あい"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
||||||
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, "哀");
|
EXPECT_EQ(segments.conversion_segment(0).candidate(0).value, "哀");
|
||||||
@ -1681,7 +1697,7 @@ TEST_F(ConverterTest, UserEntryShouldBePromotedMobilePrediction) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPredictionWithKey(&segments, "あい"));
|
EXPECT_TRUE(converter->StartPrediction(ConvReqWithKey("あい"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
||||||
|
|
||||||
@ -1716,7 +1732,7 @@ TEST_F(ConverterTest, SuppressionEntryShouldBePrioritized) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "あい"));
|
EXPECT_TRUE(converter->StartConversion(ConvReqWithKey("あい"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
||||||
EXPECT_FALSE(FindCandidateByValue("哀", segments.conversion_segment(0)));
|
EXPECT_FALSE(FindCandidateByValue("哀", segments.conversion_segment(0)));
|
||||||
@ -1741,7 +1757,8 @@ TEST_F(ConverterTest, SuppressionEntryShouldBePrioritizedPrediction) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPredictionWithKey(&segments, "あい"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPrediction(ConvReqWithKey("あい"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
ASSERT_LT(1, segments.conversion_segment(0).candidates_size());
|
||||||
EXPECT_FALSE(FindCandidateByValue("哀", segments.conversion_segment(0)));
|
EXPECT_FALSE(FindCandidateByValue("哀", segments.conversion_segment(0)));
|
||||||
@ -1763,7 +1780,8 @@ TEST_F(ConverterTest, AbbreviationShouldBeIndependent) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "じゅうじか"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey("じゅうじか"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
FindCandidateByValue("Google+うじか", segments.conversion_segment(0)));
|
FindCandidateByValue("Google+うじか", segments.conversion_segment(0)));
|
||||||
@ -1787,7 +1805,8 @@ TEST_F(ConverterTest, AbbreviationShouldBeIndependentPrediction) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartPredictionWithKey(&segments, "じゅうじか"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartPrediction(ConvReqWithKey("じゅうじか"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_FALSE(FindCandidateByValue("Google+うじか",
|
EXPECT_FALSE(FindCandidateByValue("Google+うじか",
|
||||||
segments.conversion_segment(0)));
|
segments.conversion_segment(0)));
|
||||||
@ -1809,7 +1828,8 @@ TEST_F(ConverterTest, SuggestionOnlyShouldBeIndependent) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "じゅうじか"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey("じゅうじか"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_FALSE(
|
EXPECT_FALSE(
|
||||||
FindCandidateByValue("Google+うじか", segments.conversion_segment(0)));
|
FindCandidateByValue("Google+うじか", segments.conversion_segment(0)));
|
||||||
@ -1832,7 +1852,8 @@ TEST_F(ConverterTest, SuggestionOnlyShouldBeIndependentPrediction) {
|
|||||||
CHECK(converter);
|
CHECK(converter);
|
||||||
{
|
{
|
||||||
Segments segments;
|
Segments segments;
|
||||||
EXPECT_TRUE(converter->StartConversionWithKey(&segments, "じゅうじか"));
|
EXPECT_TRUE(
|
||||||
|
converter->StartConversion(ConvReqWithKey("じゅうじか"), &segments));
|
||||||
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
ASSERT_EQ(segments.conversion_segments_size(), 1);
|
||||||
EXPECT_FALSE(FindCandidateByValue("Google+うじか",
|
EXPECT_FALSE(FindCandidateByValue("Google+うじか",
|
||||||
segments.conversion_segment(0)));
|
segments.conversion_segment(0)));
|
||||||
|
@ -106,11 +106,6 @@ class MinimalConverter : public ConverterInterface {
|
|||||||
return AddAsIsCandidate(request, segments);
|
return AddAsIsCandidate(request, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartConversionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const override {
|
|
||||||
return AddAsIsCandidate(key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartReverseConversion(Segments *segments,
|
bool StartReverseConversion(Segments *segments,
|
||||||
const absl::string_view key) const override {
|
const absl::string_view key) const override {
|
||||||
return false;
|
return false;
|
||||||
@ -121,41 +116,21 @@ class MinimalConverter : public ConverterInterface {
|
|||||||
return AddAsIsCandidate(request, segments);
|
return AddAsIsCandidate(request, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartPredictionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const override {
|
|
||||||
return AddAsIsCandidate(key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartSuggestion(const ConversionRequest &request,
|
bool StartSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const override {
|
Segments *segments) const override {
|
||||||
return AddAsIsCandidate(request, segments);
|
return AddAsIsCandidate(request, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartSuggestionWithKey(Segments *segments,
|
|
||||||
const absl::string_view key) const override {
|
|
||||||
return AddAsIsCandidate(key, segments);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartPartialPrediction(const ConversionRequest &request,
|
bool StartPartialPrediction(const ConversionRequest &request,
|
||||||
Segments *segments) const override {
|
Segments *segments) const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartPartialPredictionWithKey(
|
|
||||||
Segments *segments, const absl::string_view key) const override {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartPartialSuggestion(const ConversionRequest &request,
|
bool StartPartialSuggestion(const ConversionRequest &request,
|
||||||
Segments *segments) const override {
|
Segments *segments) const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartPartialSuggestionWithKey(
|
|
||||||
Segments *segments, const absl::string_view key) const override {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FinishConversion(const ConversionRequest &request,
|
void FinishConversion(const ConversionRequest &request,
|
||||||
Segments *segments) const override {}
|
Segments *segments) const override {}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user