Remove user pos managers
BUG=
TEST=
REF_BUG=26841123
REF_CL=116821189
REF_TIME=2016-03-10T10:18:14+09:00
REF_TIME_RAW=1457572694 +0900
Noriyuki Takahashi
8 years ago
41 | 41 | ], |
42 | 42 | 'dependencies': [ |
43 | 43 | '../composer/composer.gyp:composer', |
44 | '../data_manager/data_manager.gyp:user_pos_manager', | |
45 | 44 | '../dictionary/dictionary_base.gyp:pos_matcher', |
46 | 45 | '../prediction/prediction.gyp:prediction', |
47 | 46 | '../prediction/prediction.gyp:prediction_protocol', |
118 | 118 | 'dependencies': [ |
119 | 119 | '../base/base.gyp:base', |
120 | 120 | '../config/config.gyp:config_handler', |
121 | '../data_manager/data_manager.gyp:user_pos_manager', | |
122 | 121 | '../dictionary/dictionary.gyp:suffix_dictionary', |
123 | 122 | '../dictionary/dictionary_base.gyp:pos_matcher', |
124 | 123 | '../dictionary/dictionary_base.gyp:suppression_dictionary', |
48 | 48 | 'dependencies': [ |
49 | 49 | '../composer/composer.gyp:composer', |
50 | 50 | '../config/config.gyp:config_handler', |
51 | '../data_manager/data_manager.gyp:user_pos_manager', | |
52 | 51 | '../data_manager/data_manager_test.gyp:scoped_data_manager_initializer_for_testing', |
53 | 52 | '../data_manager/testing/mock_data_manager.gyp:mock_data_manager', |
54 | 53 | '../dictionary/dictionary.gyp:dictionary_mock', |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #include "data_manager/chromeos/chromeos_user_pos_manager.h" | |
30 | ||
31 | #include "base/embedded_file.h" | |
32 | #include "base/logging.h" | |
33 | #include "base/singleton.h" | |
34 | ||
35 | namespace mozc { | |
36 | namespace chromeos { | |
37 | ||
38 | ChromeOsUserPosManager *ChromeOsUserPosManager::GetUserPosManager() { | |
39 | return Singleton<ChromeOsUserPosManager>::get(); | |
40 | } | |
41 | ||
42 | namespace { | |
43 | ||
44 | // Embedded file kUserPosManagerData is defined in this header file. | |
45 | #include "data_manager/chromeos/user_pos_manager_data.h" | |
46 | ||
47 | } // namespace | |
48 | ||
49 | ChromeOsUserPosManager::ChromeOsUserPosManager() { | |
50 | const StringPiece data = LoadEmbeddedFile(kUserPosManagerData); | |
51 | const char *kMagicNumber = ""; // Magic number is not present. | |
52 | CHECK(manager_.InitUserPosManagerDataFromArray(data, kMagicNumber)) | |
53 | << "Embedded user_pos_manager_data.h is broken"; | |
54 | } | |
55 | ||
56 | ChromeOsUserPosManager::~ChromeOsUserPosManager() = default; | |
57 | ||
58 | void ChromeOsUserPosManager::GetUserPOSData( | |
59 | StringPiece *token_array_data, StringPiece *string_array_data) const { | |
60 | manager_.GetUserPOSData(token_array_data, string_array_data); | |
61 | } | |
62 | ||
63 | const uint16 *ChromeOsUserPosManager::GetPOSMatcherData() const { | |
64 | return manager_.GetPOSMatcherData(); | |
65 | } | |
66 | ||
67 | } // namespace chromeos | |
68 | } // namespace mozc |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #ifndef MOZC_DATA_MANAGER_CHROMEOS_CHROMEOS_USER_POS_MANAGER_H_ | |
30 | #define MOZC_DATA_MANAGER_CHROMEOS_CHROMEOS_USER_POS_MANAGER_H_ | |
31 | ||
32 | #include "base/port.h" | |
33 | #include "data_manager/data_manager.h" | |
34 | #include "data_manager/data_manager_interface.h" | |
35 | ||
36 | namespace mozc { | |
37 | namespace chromeos { | |
38 | ||
39 | class ChromeOsUserPosManager : public DataManagerInterface { | |
40 | public: | |
41 | ChromeOsUserPosManager(); | |
42 | ~ChromeOsUserPosManager() override; | |
43 | ||
44 | static ChromeOsUserPosManager *GetUserPosManager(); | |
45 | ||
46 | // Partially implement the interface because some binary only reqiures the | |
47 | // folloiwng embedded data. | |
48 | void GetUserPOSData(StringPiece *token_array_data, | |
49 | StringPiece *string_array_data) const override; | |
50 | const uint16 *GetPOSMatcherData() const override; | |
51 | ||
52 | // The following are implemented in ChromeOsDataManager. | |
53 | const uint8 *GetPosGroupData() const override { return nullptr; } | |
54 | void GetConnectorData(const char **data, size_t *size) const override {} | |
55 | void GetSegmenterData(size_t *l_num_elements, size_t *r_num_elements, | |
56 | const uint16 **l_table, const uint16 **r_table, | |
57 | size_t *bitarray_num_bytes, const char **bitarray_data, | |
58 | const uint16 **boundary_data) const override {} | |
59 | void GetSystemDictionaryData(const char **data, int *size) const override {} | |
60 | void GetSuffixDictionaryData(StringPiece *key_array, StringPiece *value_array, | |
61 | const uint32 **token_array) const override {} | |
62 | void GetReadingCorrectionData( | |
63 | StringPiece *value_array_data, StringPiece *error_array_data, | |
64 | StringPiece *correction_array_data) const override {} | |
65 | void GetCollocationData(const char **array, size_t *size) const override {} | |
66 | void GetCollocationSuppressionData(const char **array, | |
67 | size_t *size) const override {} | |
68 | void GetSuggestionFilterData(const char **data, size_t *size) const override { | |
69 | } | |
70 | void GetSymbolRewriterData(StringPiece *token_array_data, | |
71 | StringPiece *string_array_data) const override {} | |
72 | #ifndef NO_USAGE_REWRITER | |
73 | void GetUsageRewriterData( | |
74 | StringPiece *base_conjugation_suffix_data, | |
75 | StringPiece *conjugation_suffix_data, | |
76 | StringPiece *conjugation_suffix_index_data, | |
77 | StringPiece *usage_items_data, | |
78 | StringPiece *string_array_data) const override {} | |
79 | #endif // NO_USAGE_REWRITER | |
80 | ||
81 | void GetCounterSuffixSortedArray(const char **array, | |
82 | size_t *size) const override {} | |
83 | ||
84 | private: | |
85 | DataManager manager_; | |
86 | DISALLOW_COPY_AND_ASSIGN(ChromeOsUserPosManager); | |
87 | }; | |
88 | ||
89 | } // namespace chromeos | |
90 | } // namespace mozc | |
91 | ||
92 | #endif // MOZC_DATA_MANAGER_CHROMEOS_CHROMEOS_USER_POS_MANAGER_H_ |
52 | 52 | ], |
53 | 53 | }, |
54 | 54 | { |
55 | 'target_name': 'user_pos_manager', | |
56 | 'type': 'none', | |
57 | 'toolsets': [ 'target', 'host' ], | |
58 | 'sources': [ | |
59 | 'user_pos_manager.h', | |
60 | ], | |
61 | 'dependencies': [ | |
62 | 'oss/oss_data_manager_base.gyp:oss_user_pos_manager', | |
63 | ], | |
64 | 'conditions': [ | |
65 | ['use_packed_dictionary==1', { | |
66 | 'dependencies': [ | |
67 | 'packed/packed_data_manager_base.gyp:packed_data_manager' | |
68 | ], | |
69 | 'dependencies!': [ | |
70 | 'oss/oss_data_manager_base.gyp:oss_user_pos_manager' | |
71 | ] | |
72 | }], | |
73 | ], | |
74 | }, | |
75 | { | |
76 | 55 | 'target_name': 'connection_file_reader', |
77 | 56 | 'type': 'static_library', |
78 | 57 | 'toolsets': [ 'target', 'host' ], |
29 | 29 | { |
30 | 30 | 'targets': [ |
31 | 31 | { |
32 | 'target_name': '<(dataset_tag)_user_pos_manager', | |
33 | 'type': 'static_library', | |
34 | 'toolsets': [ 'target', 'host' ], | |
35 | 'sources': [ | |
36 | '<(current_dir)/<(dataset_tag)_user_pos_manager.cc', | |
37 | ], | |
38 | 'dependencies': [ | |
39 | '<(mozc_dir)/base/base.gyp:base', | |
40 | 'gen_user_pos_manager_data_header_for_<(dataset_tag)#host', | |
41 | '../data_manager_base.gyp:data_manager', | |
42 | ], | |
43 | }, | |
44 | { | |
45 | 32 | 'target_name': 'gen_<(dataset_tag)_embedded_pos_list', |
46 | 33 | 'type': 'none', |
47 | 34 | 'toolsets': ['host'], |
65 | 52 | '--input=<(pos_list)', |
66 | 53 | '--name=kPosArray', |
67 | 54 | '--output=<(gen_out_dir)/pos_list.h', |
68 | ], | |
69 | }, | |
70 | ], | |
71 | }, | |
72 | { | |
73 | 'target_name': 'gen_user_pos_manager_data_header_for_<(dataset_tag)', | |
74 | 'type': 'none', | |
75 | 'toolsets': ['host'], | |
76 | 'dependencies': [ | |
77 | 'gen_user_pos_manager_data_for_<(dataset_tag)#host', | |
78 | ], | |
79 | 'actions': [ | |
80 | { | |
81 | 'action_name': 'gen_user_pos_manager_data_header_for_<(dataset_tag)', | |
82 | 'variables': { | |
83 | 'user_pos_manager_data': '<(gen_out_dir)/user_pos_manager.data', | |
84 | }, | |
85 | 'inputs': [ | |
86 | '<(user_pos_manager_data)', | |
87 | ], | |
88 | 'outputs': [ | |
89 | '<(gen_out_dir)/user_pos_manager_data.h', | |
90 | ], | |
91 | 'action': [ | |
92 | 'python', '<(mozc_dir)/build_tools/embed_file.py', | |
93 | '--input=<(user_pos_manager_data)', | |
94 | '--name=kUserPosManagerData', | |
95 | '--output=<(gen_out_dir)/user_pos_manager_data.h', | |
96 | 55 | ], |
97 | 56 | }, |
98 | 57 | ], |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #include "data_manager/oss/oss_user_pos_manager.h" | |
30 | ||
31 | #include "base/embedded_file.h" | |
32 | #include "base/logging.h" | |
33 | #include "base/singleton.h" | |
34 | ||
35 | namespace mozc { | |
36 | namespace oss { | |
37 | ||
38 | OssUserPosManager *OssUserPosManager::GetUserPosManager() { | |
39 | return Singleton<OssUserPosManager>::get(); | |
40 | } | |
41 | ||
42 | namespace { | |
43 | ||
44 | // Embedded file kUserPosManagerData is defined in this header file. | |
45 | #include "data_manager/oss/user_pos_manager_data.h" | |
46 | ||
47 | } // namespace | |
48 | ||
49 | OssUserPosManager::OssUserPosManager() { | |
50 | const StringPiece data = LoadEmbeddedFile(kUserPosManagerData); | |
51 | const char *kMagicNumber = ""; // Magic number is not present. | |
52 | CHECK(manager_.InitUserPosManagerDataFromArray(data, kMagicNumber)) | |
53 | << "Embedded user_pos_manager_data.h is broken"; | |
54 | } | |
55 | ||
56 | OssUserPosManager::~OssUserPosManager() = default; | |
57 | ||
58 | void OssUserPosManager::GetUserPOSData( | |
59 | StringPiece *token_array_data, StringPiece *string_array_data) const { | |
60 | manager_.GetUserPOSData(token_array_data, string_array_data); | |
61 | } | |
62 | ||
63 | const uint16 *OssUserPosManager::GetPOSMatcherData() const { | |
64 | return manager_.GetPOSMatcherData(); | |
65 | } | |
66 | ||
67 | } // namespace oss | |
68 | } // namespace mozc |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #ifndef MOZC_DATA_MANAGER_OSS_OSS_USER_POS_MANAGER_H_ | |
30 | #define MOZC_DATA_MANAGER_OSS_OSS_USER_POS_MANAGER_H_ | |
31 | ||
32 | #include "base/port.h" | |
33 | #include "data_manager/data_manager.h" | |
34 | #include "data_manager/data_manager_interface.h" | |
35 | ||
36 | namespace mozc { | |
37 | namespace oss { | |
38 | ||
39 | class OssUserPosManager : public DataManagerInterface { | |
40 | public: | |
41 | OssUserPosManager(); | |
42 | ~OssUserPosManager() override; | |
43 | ||
44 | static OssUserPosManager *GetUserPosManager(); | |
45 | ||
46 | // Partially implement the interface because some binary only reqiures the | |
47 | // folloiwng embedded data. | |
48 | // Returns the address to an array of UserPOS::POSToken. | |
49 | void GetUserPOSData(StringPiece *token_array_data, | |
50 | StringPiece *string_array_data) const override; | |
51 | const uint16 *GetPOSMatcherData() const override; | |
52 | ||
53 | // The following are implemented in OssDataManager. | |
54 | const uint8 *GetPosGroupData() const override { return nullptr; } | |
55 | void GetConnectorData(const char **data, size_t *size) const override {} | |
56 | void GetSegmenterData(size_t *l_num_elements, size_t *r_num_elements, | |
57 | const uint16 **l_table, const uint16 **r_table, | |
58 | size_t *bitarray_num_bytes, const char **bitarray_data, | |
59 | const uint16 **boundary_data) const override {} | |
60 | void GetSystemDictionaryData(const char **data, int *size) const override {} | |
61 | void GetSuffixDictionaryData(StringPiece *key_array, StringPiece *value_array, | |
62 | const uint32 **token_array) const override {} | |
63 | void GetReadingCorrectionData( | |
64 | StringPiece *value_array_data, StringPiece *error_array_data, | |
65 | StringPiece *correction_array_data) const override {} | |
66 | void GetCollocationData(const char **array, size_t *size) const override {} | |
67 | void GetCollocationSuppressionData(const char **array, | |
68 | size_t *size) const override {} | |
69 | void GetSuggestionFilterData(const char **data, size_t *size) const override { | |
70 | } | |
71 | void GetSymbolRewriterData(StringPiece *token_array_data, | |
72 | StringPiece *string_array_data) const override {} | |
73 | #ifndef NO_USAGE_REWRITER | |
74 | void GetUsageRewriterData( | |
75 | StringPiece *base_conjugation_suffix_data, | |
76 | StringPiece *conjugation_suffix_data, | |
77 | StringPiece *conjugation_suffix_index_data, | |
78 | StringPiece *usage_items_data, | |
79 | StringPiece *string_array_data) const override {} | |
80 | #endif // NO_USAGE_REWRITER | |
81 | void GetCounterSuffixSortedArray(const char **array, | |
82 | size_t *size) const override {} | |
83 | ||
84 | private: | |
85 | DataManager manager_; | |
86 | DISALLOW_COPY_AND_ASSIGN(OssUserPosManager); | |
87 | }; | |
88 | ||
89 | } // namespace oss | |
90 | } // namespace mozc | |
91 | ||
92 | #endif // MOZC_DATA_MANAGER_OSS_OSS_USER_POS_MANAGER_H_ |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #include "data_manager/testing/mock_user_pos_manager.h" | |
30 | ||
31 | #include "base/embedded_file.h" | |
32 | #include "base/logging.h" | |
33 | #include "base/singleton.h" | |
34 | ||
35 | namespace mozc { | |
36 | namespace testing { | |
37 | ||
38 | MockUserPosManager *MockUserPosManager::GetUserPosManager() { | |
39 | return Singleton<MockUserPosManager>::get(); | |
40 | } | |
41 | ||
42 | namespace { | |
43 | ||
44 | // Embedded file kUserPosManagerData is defined in this header file. | |
45 | #include "data_manager/testing/user_pos_manager_data.h" | |
46 | ||
47 | } // namespace | |
48 | ||
49 | MockUserPosManager::MockUserPosManager() { | |
50 | const StringPiece data = LoadEmbeddedFile(kUserPosManagerData); | |
51 | const char *kMagicNumber = ""; // Magic number is not present. | |
52 | CHECK(manager_.InitUserPosManagerDataFromArray(data, kMagicNumber)) | |
53 | << "Embedded user_pos_manager_data.h is broken"; | |
54 | } | |
55 | ||
56 | MockUserPosManager::~MockUserPosManager() = default; | |
57 | ||
58 | void MockUserPosManager::GetUserPOSData( | |
59 | StringPiece *token_array_data, StringPiece *string_array_data) const { | |
60 | manager_.GetUserPOSData(token_array_data, string_array_data); | |
61 | } | |
62 | ||
63 | const uint16 *MockUserPosManager::GetPOSMatcherData() const { | |
64 | return manager_.GetPOSMatcherData(); | |
65 | } | |
66 | ||
67 | } // namespace testing | |
68 | } // namespace mozc |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #ifndef MOZC_DATA_MANAGER_TESTING_MOCK_USER_POS_MANAGER_H_ | |
30 | #define MOZC_DATA_MANAGER_TESTING_MOCK_USER_POS_MANAGER_H_ | |
31 | ||
32 | #include "base/port.h" | |
33 | #include "data_manager/data_manager.h" | |
34 | #include "data_manager/data_manager_interface.h" | |
35 | ||
36 | namespace mozc { | |
37 | namespace testing { | |
38 | ||
39 | class MockUserPosManager : public DataManagerInterface { | |
40 | public: | |
41 | MockUserPosManager(); | |
42 | ~MockUserPosManager() override; | |
43 | ||
44 | static MockUserPosManager *GetUserPosManager(); | |
45 | ||
46 | // Partially implement the interface because some binary only reqiures the | |
47 | // folloiwng embedded data. | |
48 | void GetUserPOSData(StringPiece *token_array_data, | |
49 | StringPiece *string_array_data) const override; | |
50 | const uint16 *GetPOSMatcherData() const override; | |
51 | ||
52 | // The following are implemented in MockDataManager. | |
53 | const uint8 *GetPosGroupData() const override { return nullptr; } | |
54 | void GetConnectorData(const char **data, size_t *size) const override {} | |
55 | void GetSegmenterData(size_t *l_num_elements, size_t *r_num_elements, | |
56 | const uint16 **l_table, const uint16 **r_table, | |
57 | size_t *bitarray_num_bytes, const char **bitarray_data, | |
58 | const uint16 **boundary_data) const override {} | |
59 | void GetSystemDictionaryData(const char **data, int *size) const override {} | |
60 | void GetSuffixDictionaryData(StringPiece *key_array, StringPiece *value_array, | |
61 | const uint32 **token_array) const override {} | |
62 | void GetReadingCorrectionData( | |
63 | StringPiece *value_array_data, StringPiece *error_array_data, | |
64 | StringPiece *correction_array_data) const override {} | |
65 | void GetCollocationData(const char **array, size_t *size) const override {} | |
66 | void GetCollocationSuppressionData(const char **array, | |
67 | size_t *size) const override {} | |
68 | void GetSuggestionFilterData(const char **data, size_t *size) const override { | |
69 | } | |
70 | void GetSymbolRewriterData(StringPiece *token_array_data, | |
71 | StringPiece *string_array_data) const override {} | |
72 | #ifndef NO_USAGE_REWRITER | |
73 | void GetUsageRewriterData( | |
74 | StringPiece *base_conjugation_suffix_data, | |
75 | StringPiece *conjugation_suffix_data, | |
76 | StringPiece *conjugation_suffix_index_data, | |
77 | StringPiece *usage_items_data, | |
78 | StringPiece *string_array_data) const override {} | |
79 | #endif // NO_USAGE_REWRITER | |
80 | void GetCounterSuffixSortedArray(const char **array, | |
81 | size_t *size) const override {} | |
82 | ||
83 | private: | |
84 | DataManager manager_; | |
85 | DISALLOW_COPY_AND_ASSIGN(MockUserPosManager); | |
86 | }; | |
87 | ||
88 | } // namespace testing | |
89 | } // namespace mozc | |
90 | ||
91 | #endif // MOZC_DATA_MANAGER_TESTING_MOCK_USER_POS_MANAGER_H_ |
0 | // Copyright 2010-2016, Google Inc. | |
1 | // All rights reserved. | |
2 | // | |
3 | // Redistribution and use in source and binary forms, with or without | |
4 | // modification, are permitted provided that the following conditions are | |
5 | // met: | |
6 | // | |
7 | // * Redistributions of source code must retain the above copyright | |
8 | // notice, this list of conditions and the following disclaimer. | |
9 | // * Redistributions in binary form must reproduce the above | |
10 | // copyright notice, this list of conditions and the following disclaimer | |
11 | // in the documentation and/or other materials provided with the | |
12 | // distribution. | |
13 | // * Neither the name of Google Inc. nor the names of its | |
14 | // contributors may be used to endorse or promote products derived from | |
15 | // this software without specific prior written permission. | |
16 | // | |
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ||
29 | #ifndef MOZC_DATA_MANAGER_USER_POS_MANAGER_H_ | |
30 | #define MOZC_DATA_MANAGER_USER_POS_MANAGER_H_ | |
31 | ||
32 | ||
33 | #if defined(MOZC_USE_PACKED_DICTIONARY) | |
34 | #include "data_manager/packed/packed_data_manager.h" | |
35 | namespace mozc { | |
36 | typedef packed::PackedDataManager UserPosManager; | |
37 | } | |
38 | #else // !MOZC_USE_PACKED_DICTIONARY | |
39 | #include "data_manager/oss/oss_user_pos_manager.h" | |
40 | namespace mozc { | |
41 | typedef oss::OssUserPosManager UserPosManager; | |
42 | } | |
43 | #endif // MOZC_USE_PACKED_DICTIONARY | |
44 | ||
45 | #endif // MOZC_DATA_MANAGER_USER_POS_MANAGER_H_ |
81 | 81 | ], |
82 | 82 | 'dependencies': [ |
83 | 83 | '../base/base.gyp:base', |
84 | '../data_manager/data_manager.gyp:user_pos_manager', | |
85 | '../data_manager/testing/mock_data_manager_base.gyp:mock_user_pos_manager', | |
84 | '../data_manager/data_manager_base.gyp:data_manager', | |
86 | 85 | 'dictionary_base.gyp:pos_matcher', |
87 | 86 | 'system/system_dictionary.gyp:system_dictionary_builder', |
88 | 87 | ], |
0 | 0 | MAJOR=2 |
1 | 1 | MINOR=17 |
2 | BUILD=2529 | |
2 | BUILD=2530 | |
3 | 3 | REVISION=102 |
4 | 4 | # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be |
5 | 5 | # downloaded by NaCl Mozc. |
48 | 48 | '../converter/converter_base.gyp:immutable_converter', |
49 | 49 | '../converter/converter_base.gyp:segmenter', |
50 | 50 | '../converter/converter_base.gyp:segments', |
51 | '../data_manager/data_manager.gyp:user_pos_manager', | |
52 | 51 | '../data_manager/data_manager_test.gyp:scoped_data_manager_initializer_for_testing', |
53 | 52 | '../data_manager/testing/mock_data_manager.gyp:mock_data_manager', |
54 | 53 | '../dictionary/dictionary.gyp:dictionary', |
88 | 88 | '../config/config.gyp:character_form_manager', |
89 | 89 | '../config/config.gyp:config_handler', |
90 | 90 | '../converter/converter_base.gyp:immutable_converter', |
91 | '../data_manager/data_manager.gyp:user_pos_manager', | |
92 | 91 | '../dictionary/dictionary.gyp:dictionary', |
93 | 92 | '../dictionary/dictionary_base.gyp:pos_matcher', |
94 | 93 | '../protocol/protocol.gyp:commands_proto', |
195 | 195 | 'dependencies': [ |
196 | 196 | '../base/base.gyp:base', |
197 | 197 | '../base/base.gyp:serialized_string_array', |
198 | '../data_manager/data_manager.gyp:user_pos_manager', | |
198 | '../data_manager/data_manager_base.gyp:data_manager', | |
199 | 199 | '../dictionary/dictionary_base.gyp:pos_matcher', |
200 | 200 | '../dictionary/dictionary_base.gyp:user_pos', |
201 | 201 | 'rewriter_serialized_dictionary.gyp:serialized_dictionary', |