Skip to content

Commit

Permalink
Merge branch 'google:master' into uim
Browse files Browse the repository at this point in the history
  • Loading branch information
shitamo authored Oct 30, 2024
2 parents 448f64b + 22a09ff commit e2d39b9
Show file tree
Hide file tree
Showing 18 changed files with 584 additions and 585 deletions.
123 changes: 123 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# src/

Directory of the source code.

## Overview of components and directories

```
+------------+ +------------+ +------------+
| Server | <--------> | Client | <--------> | UI |
+------------+ Protocol +------------+ Protocol +------------+
| Session | | Platform |
+------------+ +------------+
| Converter |
+------------+
| Dictionary |
+------------+
```

Note: Platform is used for various components for platform specific
requirements.

### Platform

* [android/](android/)
* Android specific implementation.
* Note: Mozc does not contain the client UI implementation for Android.
* [unix/](unix/)
* Linux specific implementation.
* [win32/](win32/)
* Windows specific implementation.
* [mac/](mac/)
* macOS specific implementation.
* [ios/](ios/)
* iOS specific implementation.
* Note: Mozc does not officially support iOS build.

### Build

* [build_tools/](build_tools/)
* Utilities used for build (e.g. code generation).
* [bazel/](bazel/)
* Build rules and tools for Bazel build.
* [gyp/](gyp/)
* Build rules and tools for GYP.
* [protobuf/](protobuf/)
* Build rules and tools of GYP for Protocol Buffers.

### Base

* [base/](base/)
* Fundamental libraries for generic purposes.
* [data/](data/)
* Directory and subdirectories of data files.
* [third_party/](third_party/)
* Third party libraries (e.g. Abseil).
* [testing/](testing/)
* Libraries for testing.
* [usage_stats/](usage_stats/)
* Libraries for usage statistics.
* Note: Mozc does not use usage statistics.

### Protocol

* [protocol/](protocol/)
* Protocol definitions of function API (e.g. API between client and
server).
* [config/](config/)
* Libraries to manage user configurations.
* [request/](request/)
* Libraries of request used for text conversion.

### Client / Server

* [client/](client/)
* Libraries of client code.
* Note: The main function of the client is in each platform directory.
* [server/](server/)
* Libraries of server code.
* The main function is in this directory.
* [ipc/](ipc/)
* Libraries of IPC to communicate between client, server and other
processes.

### Session

* [session/](session/)
* Libraries of state management between user interactions and text
conversion.
* [composer/](composer/)
* Libraries of text composing (e.g. Romaji-Hiragana conversion).
* [transliteration/](transliteration/)
* Libraries of script type transliteration (e.g. half-width Katakana,
full-width Ascii).

### Converter

* [engine/](engine/)
* Libraries to manage converter libraries.
* [data_manager/](data_manager/)
* Libraries to manage converter data.
* [converter/](converter/)
* Libraries of text conversion (e.g. Hiragana to Kanji exact match
conversion).
* [rewriter/](rewriter/)
* Libraries for additional conversions (e.g. date input, symbol input, zip
code input).
* [prediction/](prediction/)
* Libraries of text prediction (e.g. Hiragana to Kanji prefix match
conversion).

### Dictionary

* [dictionary/](dictionary/)
* Libraries of dictionary lookup (e.g. Hiragana key to possible words).
* [storage/](storage/)
* Libraries of dictionary data storage (e.g. LOUDS, etc.).

### UI

* [renderer/](renderer/)
* UI application of candidate words.
* [gui/](gui/)
* GUI applications for configurations.
27 changes: 16 additions & 11 deletions src/converter/converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1610,9 +1610,6 @@ TEST_F(ConverterTest, UserEntryInMobilePrediction) {
composer::Table table;
composer::Composer composer(&table, &request, &config);
request_test_util::FillMobileRequest(&request);
ConversionRequest conversion_request(
&composer, &request, &commands::Context::default_instance(), &config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);

std::unique_ptr<ConverterAndData> ret =
CreateConverterAndDataWithUserDefinedEntries(user_defined_entries,
Expand All @@ -1622,6 +1619,10 @@ TEST_F(ConverterTest, UserEntryInMobilePrediction) {
CHECK(converter);
{
composer.SetPreeditTextForTestOnly("てすとが");
commands::Context context;
ConversionRequest conversion_request(&composer, &request, &context,
&config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);
Segments segments;
EXPECT_TRUE(converter->StartPrediction(conversion_request, &segments));
ASSERT_EQ(segments.segments_size(), 1);
Expand Down Expand Up @@ -1809,17 +1810,19 @@ TEST_F(ConverterTest, RewriterShouldRespectDefaultCandidates) {
std::unique_ptr<EngineInterface> engine = CreateEngineWithMobilePredictor();
ConverterInterface *converter = engine->GetConverter();
CHECK(converter);
commands::Request request;

config::Config config;
config::ConfigHandler::GetDefaultConfig(&config);
commands::Request request;
request_test_util::FillMobileRequest(&request);
composer::Table table;
composer::Composer composer(&table, &request, &config);
request_test_util::FillMobileRequest(&request);
ConversionRequest conversion_request(&composer, &request, &config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);
composer.SetPreeditTextForTestOnly("あい");
commands::Context context;

ConversionRequest conversion_request(&composer, &request, &context, &config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);
Segments segments;
composer.SetPreeditTextForTestOnly("あい");

// Remember user history 3 times after getting the top candidate
std::string top_candidate;
Expand Down Expand Up @@ -1863,17 +1866,19 @@ TEST_F(ConverterTest,
std::unique_ptr<EngineInterface> engine = CreateEngineWithMobilePredictor();
ConverterInterface *converter = engine->GetConverter();
CHECK(converter);

commands::Request request;
config::Config config;
config::ConfigHandler::GetDefaultConfig(&config);
composer::Table table;
composer::Composer composer(&table, &request, &config);
request_test_util::FillMobileRequest(&request);
ConversionRequest conversion_request(&composer, &request, &config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);
composer.SetPreeditTextForTestOnly("おつかれ");
commands::Context context;

ConversionRequest conversion_request(&composer, &request, &context, &config);
conversion_request.set_request_type(ConversionRequest::PREDICTION);
Segments segments;
composer.SetPreeditTextForTestOnly("おつかれ");

EXPECT_TRUE(converter->StartPrediction(conversion_request, &segments));

Expand Down
2 changes: 2 additions & 0 deletions src/data/test/dictionary/collocation.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
猫を飼いたい
マグロを解体
周回っ
周回って
5 changes: 4 additions & 1 deletion src/data_manager/mozc_data.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,16 @@ def mozc_dataset(
tools = ["//dictionary:gen_pos_matcher_code"],
)

def _get_collocation_error_rate(data_tag):
return 0.00001 if data_tag != "mock" else 0.000001

native.genrule(
name = name + "@collocation",
srcs = [collocation_src],
outs = ["collocation.data"],
cmd = (
"$(location //rewriter:gen_collocation_data_main) " +
"--collocation_data=$< --output=$@ --binary_mode"
"--collocation_data=$< --output=$@ --binary_mode --error_rate=%f" % _get_collocation_error_rate(tag)
),
tools = ["//rewriter:gen_collocation_data_main"],
)
Expand Down
2 changes: 1 addition & 1 deletion src/dictionary/pos_matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class PosMatcher {
PosMatcher(const PosMatcher &) = default;
PosMatcher &operator=(const PosMatcher &) = default;

void Set(const uint16_t *data ABSL_ATTRIBUTE_LIFETIME_BOUND) { data_ = data; }
void Set(const uint16_t *data) { data_ = data; }

private:
// Used in pos_matcher_impl.inc.
Expand Down
10 changes: 0 additions & 10 deletions src/engine/supplemental_model_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ class SupplementalModelInterface {
const ConversionRequest &request, const Segments &segments,
std::vector<absl::Nonnull<const prediction::Result *>> *results) const {}

// Returns true if the final typing correct result is not confident.
// TODO(taku): Remove this function after finishing the migration of
// the more general SuppressTypingCorrection method.
virtual bool ShouldRevertTypingCorrection(
const ConversionRequest &request, const Segments &segments,
absl::Span<const prediction::Result> literal_results,
absl::Span<const prediction::Result> typing_corrected_results) const {
return false;
}

// Performs general post correction on `segments`.
virtual void PostCorrect(const ConversionRequest &request,
absl::Nonnull<Segments *> segments) const {}
Expand Down
5 changes: 0 additions & 5 deletions src/engine/supplemental_model_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class MockSupplementalModel : public SupplementalModelInterface {
(const ConversionRequest &request, const Segments &segments,
std::vector<absl::Nonnull<const prediction::Result *>> *results),
(const, override));
MOCK_METHOD(bool, ShouldRevertTypingCorrection,
(const ConversionRequest &request, const Segments &segments,
absl::Span<const prediction::Result> literal_results,
absl::Span<const prediction::Result> typing_corrected_results),
(const, override));
MOCK_METHOD(void, PostCorrect,
(const ConversionRequest &, absl::Nonnull<Segments *> segments),
(const, override));
Expand Down
Loading

0 comments on commit e2d39b9

Please sign in to comment.