Codebase list mozc / 839fc5a
Merge commit 'upstream/1.1.773.102' Nobuhiro Iwamatsu 12 years ago
22 changed file(s) with 749 addition(s) and 240 deletion(s). Raw diff Collapse all Expand all
646646 }
647647
648648 void Util::UCS4ToUTF8Append(char32 c, string *output) {
649 char buf[6];
649 char buf[7];
650650 UCS4ToUTF8Internal(c, buf);
651651 *output += buf;
652652 }
164164 return (template_path, version_path)
165165
166166
167 def GetGypFileNames():
167 def GetGypFileNames(options):
168168 """Gets the list of gyp file names."""
169169 gyp_file_names = []
170170 mozc_top_level_names = glob.glob('%s/*' % SRC_DIR)
194194 try:
195195 RunOrDie(['pkg-config', '--exists', 'ibus-1.0'])
196196 except RunOrDieError:
197 print 'ibus-1.0 was not found.'
197198 gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR)
198199 # Add gui.gyp if Qt libraries are installed.
199200 try:
200201 RunOrDie(['pkg-config', '--exists', 'QtCore', 'QtGui'])
202 qt_found = True
201203 except RunOrDieError:
204 print 'QtCore or QtGui was not found.'
205 qt_found = False
206 if options.ensure_value('qtdir', None):
207 qt_found = True
208 if options.ensure_value('noqt', None) or not qt_found:
202209 gyp_file_names.remove('%s/gui/gui.gyp' % SRC_DIR)
203210 # Add scim.gyp if SCIM is installed.
204211 try:
205212 RunOrDie(['pkg-config', '--exists', 'scim'])
206213 except RunOrDieError:
214 print 'scim was not found.'
207215 gyp_file_names.remove('%s/unix/scim/scim.gyp' % SRC_DIR)
208216 gyp_file_names.extend(glob.glob('third_party/rx/*.gyp'))
209217 gyp_file_names.sort()
250258 directory_names = []
251259
252260 # Collect stuff in the gyp directories.
253 gyp_directory_names = [os.path.dirname(f) for f in GetGypFileNames()]
261 gyp_directory_names = [os.path.dirname(f) for f in GetGypFileNames(options)]
254262 for gyp_directory_name in gyp_directory_names:
255263 if IsWindows():
256264 for pattern in ['*.rules', '*.sln', '*.vcproj']:
335343 print 'Build tool: %s' % generator
336344
337345 # Get and show the list of .gyp file names.
338 gyp_file_names = GetGypFileNames()
346 gyp_file_names = GetGypFileNames(options)
339347 banned_gyp_files = []
340348 if not options.chewing:
341349 # chewing/chewing.gyp is automatically included because of the
375383 command_line.extend(['-D', 'branding=%s' % options.branding])
376384 if options.noqt:
377385 command_line.extend(['-D', 'use_qt=NO'])
386 else:
387 command_line.extend(['-D', 'use_qt=YES'])
388 if options.qtdir:
389 command_line.extend(['-D', 'qt_dir=%s' % os.path.abspath(options.qtdir)])
390 else:
391 command_line.extend(['-D', 'qt_dir='])
378392 if options.coverage:
379393 command_line.extend(['-D', 'coverage=1'])
380394
549563 parser.add_option('--branding', dest='branding', default='Mozc')
550564 parser.add_option('--gypdir', dest='gypdir', default='third_party/gyp')
551565 parser.add_option('--noqt', action='store_true', dest='noqt', default=False)
566 parser.add_option('--qtdir', dest='qtdir',
567 default=os.getenv('QTDIR', None),
568 help='Qt base directory to be used.')
552569 parser.add_option('--coverage', action='store_true', dest='coverage',
553570 help='use code coverage analysis build options',
554571 default=False)
630647 help='run jobs in parallel')
631648 parser.add_option('--configuration', '-c', dest='configuration',
632649 default='Debug', help='specify the build configuration.')
633 parser.add_option('--noqt', action='store_true', dest='noqt', default=False)
634650 parser.add_option('--version_file', dest='version_file',
635651 help='use the specified version template file',
636652 default='mozc_version_template.txt')
641657 if IsLinux():
642658 parser.add_option('--build_base', dest='build_base',
643659 help='specify the base directory of the built binaries.')
644
645 # default Qt dir to support the current build procedure for Debian.
646 default_qtdir = '/usr/local/Trolltech/Qt-4.6.3'
647 if IsWindows():
648 default_qtdir = None
649 parser.add_option('--qtdir', dest='qtdir',
650 default=os.getenv('QTDIR', default_qtdir),
651 help='Qt base directory to be used.')
652660
653661 (options, args) = parser.parse_args()
654662
814822 GenerateVersionFile(template_path, version_path)
815823
816824
817 if not options.noqt:
818 # Set $QTDIR for mozc_tool
819 if options.qtdir:
820 if not options.qtdir.startswith('/'):
821 options.qtdir = os.path.join(os.getcwd(), options.qtdir)
822 print 'export $QTDIR = %s' % options.qtdir
823 os.environ['QTDIR'] = options.qtdir
824
825825 if IsMac():
826826 BuildOnMac(options, targets, original_directory_name)
827827 elif IsLinux():
3131 'relative_dir': 'gui',
3232 'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
3333 },
34 'includes': [
35 'qt_common.gypi',
36 ],
3734 'targets': [
3835 {
3936 'target_name': 'gui_base',
359356 'gen_character_pad_data',
360357 'gen_dictionary_tool_files',
361358 ],
359 'includes': [
360 'qt_libraries.gypi',
361 ],
362362 'conditions': [['use_libzinnia==1 and OS=="linux"', {
363363 'defines': [
364364 'USE_LIBZINNIA',
919919 'conditions': [
920920 ['use_qt=="YES"', {
921921 'includes': [
922 'qt_target_default.gypi',
923 ],
924 },],
922 'qt_target_defaults.gypi',
923 ],
924 }],
925925 ['OS=="win"', {
926926 'targets': [
927927 {
+0
-43
gui/qt_common.gypi less more
0 # Copyright 2010-2011, 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 # This include file add various settings for Qt as
30 # target_defaults.
31 {
32 'variables': {
33 'qt_basepath': '$(QTDIR)',
34 'conditions': [
35 ['OS=="linux"', {
36 'qt_cflags': ' <!@(pkg-config --cflags QtCore QtGui)',
37 },{ # OS!="linux"
38 'qt_cflags': '<(qt_basepath)/include',
39 }],
40 ],
41 },
42 }
2828
2929 # You can include this file in a target block to add Qt-related
3030 # libraries to the target.
31 # Currently debug libraries in Mac (e.g. libQtCore_debug.dylib)
32 # are not supported.
33 # For Windows developers, you need not to include this file.
34 # Use common_qt.gypi instead.
31 # Currently debug libraries are not supported on Mac
32 # (e.g. libQtCore_debug.dylib) and GNU/Linux.
3533 {
34 'variables': {
35 'conditions': [
36 ['qt_dir', {
37 'qt_cflags': [],
38 'qt_include_dirs': ['<(qt_dir)/include'],
39 }, {
40 'conditions': [
41 ['OS=="linux"', {
42 'qt_cflags': ['<!@(pkg-config --cflags QtGui QtCore)'],
43 'qt_include_dirs': [],
44 }, {
45 'qt_cflags': [],
46 'qt_include_dirs': ['<(qt_dir_env)/include'],
47 }],
48 ],
49 }],
50 ],
51 },
52 # compilation settings
53 'cflags': ['<@(qt_cflags)'],
54 'include_dirs': ['<@(qt_include_dirs)'],
55 # link settings
3656 'conditions': [
3757 ['OS=="mac"', {
38 'link_settings': {
39 'libraries': [
40 'libQtCore.dylib',
41 'libQtGui.dylib',
42 '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
43 ],
44 },
58 'conditions': [
59 ['qt_dir', {
60 'xcode_settings': {
61 'LIBRARY_SEARCH_PATHS': [
62 '<(qt_dir)/lib',
63 ],
64 },
65 'libraries': [
66 '<(qt_dir)/lib/libQtCore.a',
67 '<(qt_dir)/lib/libQtGui.a',
68 ],
69 }, {
70 'xcode_settings': {
71 'LIBRARY_SEARCH_PATHS': [
72 '<(qt_dir_env)/lib',
73 ],
74 },
75 'libraries': [
76 '<(qt_dir_env)/lib/libQtCore.a',
77 '<(qt_dir_env)/lib/libQtGui.a',
78 ],
79 }],
80 ],
81 'libraries': [
82 '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
83 ]
4584 }],
4685 ['OS=="linux"', {
47 'link_settings': {
48 'libraries': [
49 ' <!@(pkg-config --libs QtCore QtGui)',
50 ],
51 },
86 'conditions': [
87 ['qt_dir', {
88 'libraries': [
89 '-L<(qt_dir)/lib',
90 '-lQtGui',
91 '-lQtCore',
92 # Supposing Qt libraries in qt_dir will be built as static libraries
93 # without support of pkg-config, we need to list all the
94 # dependencies of QtGui.
95 # See http://doc.qt.nokia.com/4.7/requirements-x11.html
96 # pthread library is removed because it must not be specific to Qt,
97 # and libpng12, which is missing on the list, is added because we
98 # use PNG images.
99 '<!@(pkg-config --libs-only-L --libs-only-l'
100 ' xrender xrandr xcursor xfixes xinerama fontconfig freetype2'
101 ' xi xt xext x11'
102 ' sm ice'
103 ' gobject-2.0'
104 ' libpng12)',
105 ],
106 }, {
107 'libraries': [
108 '<!@(pkg-config --libs QtGui QtCore)',
109 ],
110 }],
111 ],
52112 }],
53113 ],
54114 }
3030 {
3131 'variables': {
3232 'conditions': [
33 ['OS=="linux"', {
34 'moc_path': '<!(pkg-config --variable=moc_location QtGui)',
35 },{ # OS!="linux"
36 'moc_path': '<(qt_basepath)/bin/moc<(EXECUTABLE_SUFFIX)',
33 ['qt_dir', {
34 'moc_path': '<(qt_dir)/bin/moc<(EXECUTABLE_SUFFIX)',
35 }, {
36 'conditions': [
37 ['OS=="linux"', {
38 'moc_path': '<!(pkg-config --variable=moc_location QtGui)',
39 }, {
40 'moc_path': '<(qt_dir_env)/bin/moc<(EXECUTABLE_SUFFIX)',
41 }],
42 ],
3743 }],
3844 ],
3945 },
3030 {
3131 'variables': {
3232 'conditions': [
33 ['OS=="linux"', {
34 # seems that --variable=rcc_location is not supported
35 'rcc_path': '<!(pkg-config --variable=exec_prefix QtGui)/bin/rcc',
36 },{ # OS!="linux"
37 'rcc_path': '<(qt_basepath)/bin/rcc<(EXECUTABLE_SUFFIX)',
33 ['qt_dir', {
34 'rcc_path': '<(qt_dir)/bin/rcc<(EXECUTABLE_SUFFIX)',
35 }, {
36 'conditions': [
37 ['OS=="linux"', {
38 # seems that --variable=rcc_location is not supported
39 'rcc_path': '<!(pkg-config --variable=exec_prefix QtGui)/bin/rcc',
40 }, {
41 'rcc_path': '<(qt_dir_env)/bin/rcc<(EXECUTABLE_SUFFIX)',
42 }],
43 ],
3844 }],
3945 ],
4046 },
+0
-106
gui/qt_target_default.gypi less more
0 # Copyright 2010-2011, 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 # This include file add various settings for Qt as
30 # target_defaults.
31 {
32 'target_defaults': {
33 'configurations': {
34 'Common_Base': {
35 'include_dirs': [
36 '<(qt_cflags)',
37 ],
38 },
39 },
40 },
41 'conditions': [
42 ['OS=="win"', {
43 'target_defaults': {
44 'configurations': {
45 'Common_Base': {
46 'msvs_settings': {
47 'VCLinkerTool': {
48 'AdditionalDependencies': [
49 'Ws2_32.lib',
50 ],
51 'AdditionalLibraryDirectories': [
52 '<(qt_basepath)/lib',
53 ],
54 },
55 },
56 },
57 'Debug_Base': {
58 'msvs_settings': {
59 'VCLinkerTool': {
60 'AdditionalDependencies': [
61 'QtCored.lib',
62 'QtGuid.lib',
63 ],
64 },
65 },
66 },
67 'Optimize_Base': {
68 'msvs_settings': {
69 'VCLinkerTool': {
70 'AdditionalDependencies': [
71 'QtCore.lib',
72 'QtGui.lib',
73 ],
74 },
75 },
76 },
77 },
78 },
79 }],
80 ['OS=="mac"', {
81 'target_defaults': {
82 'configurations': {
83 'Common_Base': {
84 'xcode_settings': {
85 'LIBRARY_SEARCH_PATHS': [
86 '<(qt_basepath)/lib',
87 ],
88 },
89 },
90 },
91 },
92 }],
93 ['OS=="linux"', {
94 'target_defaults': {
95 'configurations': {
96 'Common_Base': {
97 'ldflags': [
98 ' <!@(pkg-config --libs-only-L QtCore QtGui)',
99 ],
100 },
101 },
102 },
103 }],
104 ],
105 }
0 # Copyright 2010-2011, 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 # This include file adds various settings for Qt as target_defaults.
30 {
31 'variables': {
32 'qt_dir_env': '$(QTDIR)',
33 },
34 # MSVS specific settings
35 'target_defaults': {
36 'configurations': {
37 'Common_Base': {
38 'msvs_settings': {
39 'VCLinkerTool': {
40 'AdditionalDependencies': [
41 'Ws2_32.lib',
42 ],
43 'conditions': [
44 ['qt_dir', {
45 'AdditionalLibraryDirectories': [
46 '<(qt_dir)/lib',
47 ],
48 }, {
49 'AdditionalLibraryDirectories': [
50 '<(qt_dir_env)/lib',
51 ],
52 }],
53 ],
54 },
55 },
56 },
57 'Debug_Base': {
58 'msvs_settings': {
59 'VCLinkerTool': {
60 'AdditionalDependencies': [
61 'QtCored.lib',
62 'QtGuid.lib',
63 ],
64 },
65 },
66 },
67 'Optimize_Base': {
68 'msvs_settings': {
69 'VCLinkerTool': {
70 'AdditionalDependencies': [
71 'QtCore.lib',
72 'QtGui.lib',
73 ],
74 },
75 },
76 },
77 },
78 },
79 }
3030 {
3131 'variables': {
3232 'conditions': [
33 ['OS=="linux"', {
34 'uic_path': '<!(pkg-config --variable=uic_location QtGui)',
35 },{ # OS!="linux"
36 'uic_path': '<(qt_basepath)/bin/uic<(EXECUTABLE_SUFFIX)',
33 ['qt_dir', {
34 'uic_path': '<(qt_dir)/bin/uic<(EXECUTABLE_SUFFIX)',
35 }, {
36 'conditions': [
37 ['OS=="linux"', {
38 'uic_path': '<!(pkg-config --variable=uic_location QtGui)',
39 }, {
40 'uic_path': '<(qt_dir_env)/bin/uic<(EXECUTABLE_SUFFIX)',
41 }],
42 ],
3743 }],
3844 ],
3945 },
5258 '-o', '<(gen_out_dir)/<(subdir)/ui_<(RULE_INPUT_ROOT).h',
5359 '"<(RULE_INPUT_PATH)"'
5460 ],
55 }],
56 ['OS!="win"', {
61 }, {
5762 'action': [
5863 '<(uic_path)',
5964 '-o', '<(gen_out_dir)/<(subdir)/ui_<(RULE_INPUT_ROOT).h',
130130 # project file called "coverage".
131131 'coverage%': 0,
132132
133 'mozc_data_dir': '<(SHARED_INTERMEDIATE_DIR)/',
133 'mozc_data_dir': '<(SHARED_INTERMEDIATE_DIR)',
134134 },
135135 'target_defaults': {
136136 'variables': {
433433 'MOZC_RES_USE_TEMPLATE=1',
434434 ],
435435 'AdditionalIncludeDirectories': [
436 '<(SHARED_INTERMEDIATE_DIR)/',
437 '<(DEPTH)/',
436 '<(SHARED_INTERMEDIATE_DIR)',
437 '<(DEPTH)',
438438 ],
439439 },
440440 },
3232 {
3333 'action_name': 'gen_<(gen_resource_proj_name)_resource_header',
3434 'variables': {
35 'base_path': '<(DEPTH)/',
35 'base_path': '<(DEPTH)',
3636 'version_file_path': '<(base_path)/mozc_version.txt',
3737 'script_path': '<(base_path)/build_tools/gen_win32_resource_header.py',
3838 },
00 MAJOR=1
11 MINOR=1
2 BUILD=758
2 BUILD=773
33 REVISION=102
11461146 return false;
11471147 }
11481148
1149 const string &current_value = current_segment->candidate(0).value;
1149 const string &current_key = current_segment->key();
11501150 const string &next_value = next_segment.candidate(0).value;
11511151
11521152 // "年"
11541154 return false;
11551155 }
11561156
1157 if (Util::GetScriptType(current_value) != Util::NUMBER) {
1158 return false;
1159 }
1160
1161 const size_t len = Util::CharsLen(current_value);
1157 if (Util::GetScriptType(current_key) != Util::NUMBER) {
1158 return false;
1159 }
1160
1161 const size_t len = Util::CharsLen(current_key);
11621162 if (len < 3 || len > 4) {
11631163 LOG(WARNING) << "Too long year";
11641164 return false;
11651165 }
11661166
11671167 string year_str;
1168 Util::FullWidthAsciiToHalfWidthAscii(current_value,
1168 Util::FullWidthAsciiToHalfWidthAscii(current_key,
11691169 &year_str);
11701170
11711171 const uint32 year = atoi32(year_str.c_str());
12671267 if (RewriteDate(seg) || RewriteWeekday(seg) ||
12681268 RewriteMonth(seg) || RewriteYear(seg) ||
12691269 RewriteCurrentTime(seg) ||
1270 RewriteDateAndCurrentTime(seg) ||
1271 RewriteFourDigits(seg)) {
1270 RewriteDateAndCurrentTime(seg)) {
12721271 modified = true;
12731272 } else if (i + 1 < segments->segments_size() &&
12741273 RewriteEra(seg, segments->segment(i + 1))) {
12751274 modified = true;
12761275 ++i; // skip one more
12771276 }
1277 modified |= RewriteFourDigits(seg);
12781278 }
12791279
12801280 return modified;
102102 }
103103 }
104104
105 void InitSegment(const string &key, const string &value,
106 Segments *segments) {
107 segments->Clear();
105 void AppendSegment(const string &key, const string &value,
106 Segments *segments) {
108107 Segment *seg = segments->add_segment();
109108 Segment::Candidate *candidate = seg->add_candidate();
110109 seg->set_key(key);
111110 candidate->content_key = key;
112111 candidate->value = value;
113112 candidate->content_value = value;
113 }
114
115 void InitSegment(const string &key, const string &value,
116 Segments *segments) {
117 segments->Clear();
118 AppendSegment(key, value, segments);
114119 }
115120
116121 void InsertCandidate(const string &key,
861866 }
862867
863868
869 TEST(DateRewriterTest, RewriteYearTest) {
870 DateRewriter rewriter;
871 Segments segments;
872
873 InitSegment("2010", "2010", &segments);
874 // "年"
875 AppendSegment("nenn", "\xE5\xB9\xB4", &segments);
876
877 EXPECT_TRUE(rewriter.Rewrite(&segments));
878 // "平成22"
879 EXPECT_TRUE(ContainCandidate(segments, "\xE5\xB9\xB3\xE6\x88\x90\x32\x32"));
880 }
881
882 // This test treats the situation that if UserHistoryRewriter or other like
883 // Rewriter moves up a candidate which is actually a number but can not be
884 // converted integer easily.
885 TEST(DateRewriterTest, RelationWithUserHistoryRewriterTest) {
886 DateRewriter rewriter;
887 Segments segments;
888
889 // "二千十一"
890 InitSegment("2011",
891 "\xE4\xBA\x8C\xE5\x8D\x83\xE5\x8D\x81\xE4\xB8\x80",
892 &segments);
893 // "年"
894 AppendSegment("nenn", "\xE5\xB9\xB4", &segments);
895
896 EXPECT_TRUE(rewriter.Rewrite(&segments));
897 // "平成23"
898 EXPECT_TRUE(ContainCandidate(segments, "\xE5\xB9\xB3\xE6\x88\x90\x32\x33"));
899 }
864900 } // namespace mozc
0 // Copyright 2010-2011, 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 "base/util.h"
30 #include "converter/segments.h"
31 #include "rewriter/usage_rewriter.h"
32
33 namespace mozc {
34 namespace {
35 struct ConjugationSuffix {
36 const char *value_suffix;
37 const char *key_suffix;
38 };
39 #include "rewriter/usage_rewriter_data.h"
40 }
41
42 UsageRewriter::UsageRewriter() {
43 const UsageDictItem *item = kUsageData_value;
44 for (; item->key != NULL; ++item) {
45 for (size_t i = kConjugationSuffixDataIndex[item->conjugation_id];
46 i < kConjugationSuffixDataIndex[item->conjugation_id + 1];
47 ++i) {
48 StrPair key_value(
49 string(item->key) + kConjugationSuffixData[i].key_suffix,
50 string(item->value) + kConjugationSuffixData[i].value_suffix);
51 key_value_usageitem_map_[key_value] = item;
52 }
53 }
54 }
55
56 UsageRewriter::~UsageRewriter() {
57 }
58
59 const UsageDictItem* UsageRewriter::LookupUsage(const string &key,
60 const string &value) const {
61 StrPair key_value(key, value);
62 const map<StrPair, const UsageDictItem *>::const_iterator itr =
63 key_value_usageitem_map_.find(key_value);
64 if (itr == key_value_usageitem_map_.end()) {
65 return NULL;
66 }
67 return itr->second;
68 }
69
70 bool UsageRewriter::Rewrite(Segments *segments) const {
71 DLOG(INFO) << segments->DebugString();
72 bool modified = false;
73 for (size_t i = 0; i < segments->conversion_segments_size(); ++i) {
74 Segment *segment = segments->mutable_conversion_segment(i);
75 DCHECK(segment);
76 for (size_t j = 0; j < segment->candidates_size(); ++j) {
77 const string &content_key = segment->candidate(j).content_key;
78 const string &content_value = segment->candidate(j).content_value;
79 const UsageDictItem* usage = LookupUsage(content_key, content_value);
80
81 if (usage != NULL) {
82 Segment::Candidate *candidate = segment->mutable_candidate(j);
83 DCHECK(candidate);
84 candidate->usage_id = usage->id;
85 candidate->usage_title = string(usage->value)
86 + kBaseConjugationSuffix[usage->conjugation_id].value_suffix;
87 candidate->usage_description = usage->meaning;
88 DLOG(INFO) << i << ":" << j << ":" <<
89 content_key << ":" << content_value <<
90 ":" << usage->key << ":" << usage->value <<
91 ":" << usage->conjugation_id << ":" << usage->meaning;
92 modified = true;
93 }
94 }
95 }
96 return modified;
97 }
98 } // namespace mozc
0 // Copyright 2010-2011, 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_REWRITER_USAGE_REWRITER_H_
30 #define MOZC_REWRITER_USAGE_REWRITER_H_
31 #include <list>
32 #include <map>
33 #include <string>
34
35 #include "base/base.h"
36 #include "rewriter/rewriter_interface.h"
37
38 namespace mozc {
39 struct UsageDictItem {
40 const int32 id;
41 const char *key;
42 const char *value;
43 const int32 conjugation_id;
44 const char *meaning;
45 };
46
47 class Segments;
48 class UsageRewriter: public RewriterInterface {
49 public:
50 UsageRewriter();
51 virtual ~UsageRewriter();
52 virtual bool Rewrite(Segments *segments) const;
53 private:
54 typedef pair<string, string> StrPair;
55 map<StrPair, const UsageDictItem *> key_value_usageitem_map_;
56 const UsageDictItem* LookupUsage(const string &key, const string &value) const;
57 };
58 } // namespace mozc
59 #endif // MOZC_REWRITER_USAGE_REWRITER_H_
0 // Copyright 2010-2011, 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 <string>
30
31 #include "base/util.h"
32 #include "converter/segments.h"
33 #include "rewriter/usage_rewriter.h"
34 #include "testing/base/public/gunit.h"
35
36 namespace mozc {
37 namespace {
38 void AddCandidate(const string &key, const string &value,
39 const string &content_key, const string &content_value,
40 Segment *segment) {
41 Segment::Candidate *candidate = segment->add_candidate();
42 candidate->Init();
43 candidate->key = key;
44 candidate->value = value;
45 candidate->content_key = content_key;
46 candidate->content_value = content_value;
47 }
48 } // namespace
49
50 class UsageRewriterTest : public testing::Test {
51 protected:
52 virtual void SetUp() {
53 }
54 virtual void TearDown() {
55 }
56 };
57
58 TEST(UsageRewriterTest, ConjugationTest) {
59 Segments segments;
60 UsageRewriter rewriter;
61 Segment *seg;
62
63 segments.Clear();
64 seg = segments.push_back_segment();
65 // "うたえば"
66 seg->set_key("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22");
67 // "うたえば", "歌えば", "うたえ", "歌え",
68 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22",
69 "\xE6\xAD\x8C\xE3\x81\x88\xE3\x81\xB0",
70 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
71 "\xE6\xAD\x8C\xE3\x81\x88", seg);
72 // "うたえば", "唱えば", "うたえ", "唄え"
73 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0",
74 "\xE5\x94\xB1\xE3\x81\x88\xE3\x81\xB0",
75 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
76 "\xE5\x94\x84\xE3\x81\x88", seg);
77 EXPECT_TRUE(rewriter.Rewrite(&segments));
78 // "歌う"
79 EXPECT_EQ("\xE6\xAD\x8C\xE3\x81\x86",
80 segments.conversion_segment(0).candidate(0).usage_title);
81 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
82 // "唄う"
83 EXPECT_EQ("\xE5\x94\x84\xE3\x81\x86",
84 segments.conversion_segment(0).candidate(1).usage_title);
85 EXPECT_NE("", segments.conversion_segment(0).candidate(1).usage_description);
86 }
87
88 TEST(UsageRewriterTest, SingleSegmentSingleCandidateTest) {
89 Segments segments;
90 UsageRewriter rewriter;
91 Segment *seg;
92
93 segments.Clear();
94 seg = segments.push_back_segment();
95 // "あおい"
96 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
97 // "あおい", "青い", "あおい", "青い"
98 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
99 "\xE9\x9D\x92\xE3\x81\x84",
100 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
101 "\xE9\x9D\x92\xE3\x81\x84", seg);
102 EXPECT_TRUE(rewriter.Rewrite(&segments));
103 // "青い"
104 EXPECT_EQ("\xE9\x9D\x92\xE3\x81\x84",
105 segments.conversion_segment(0).candidate(0).usage_title);
106 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
107
108 segments.Clear();
109 seg = segments.push_back_segment();
110 // "あおい"
111 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
112 // "あおい", "あああ", "あおい", "あああ"
113 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
114 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82",
115 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
116 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82", seg);
117 EXPECT_FALSE(rewriter.Rewrite(&segments));
118 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_title);
119 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_description);
120 }
121
122 TEST(UsageRewriterTest, SingleSegmentMultiCandidatesTest) {
123 Segments segments;
124 UsageRewriter rewriter;
125 Segment *seg;
126
127 segments.Clear();
128 seg = segments.push_back_segment();
129 // "あおい"
130 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
131 // "あおい", "青い", "あおい", "青い"
132 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
133 "\xE9\x9D\x92\xE3\x81\x84",
134 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
135 "\xE9\x9D\x92\xE3\x81\x84", seg);
136 // "あおい", "蒼い", "あおい", "蒼い"
137 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
138 "\xE8\x92\xBC\xE3\x81\x84",
139 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
140 "\xE8\x92\xBC\xE3\x81\x84", seg);
141 EXPECT_TRUE(rewriter.Rewrite(&segments));
142 // "青い"
143 EXPECT_EQ("\xE9\x9D\x92\xE3\x81\x84",
144 segments.conversion_segment(0).candidate(0).usage_title);
145 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
146 // "蒼い"
147 EXPECT_EQ("\xE8\x92\xBC\xE3\x81\x84",
148 segments.conversion_segment(0).candidate(1).usage_title);
149 EXPECT_NE("", segments.conversion_segment(0).candidate(1).usage_description);
150
151 segments.Clear();
152 seg = segments.push_back_segment();
153 // "あおい"
154 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
155 // "あおい", "青い", "あおい", "青い"
156 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
157 "\xE9\x9D\x92\xE3\x81\x84",
158 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
159 "\xE9\x9D\x92\xE3\x81\x84", seg);
160 // "あおい", "あああ", "あおい", "あああ"
161 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
162 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82",
163 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
164 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82", seg);
165 EXPECT_TRUE(rewriter.Rewrite(&segments));
166 // "青い"
167 EXPECT_EQ("\xE9\x9D\x92\xE3\x81\x84",
168 segments.conversion_segment(0).candidate(0).usage_title);
169 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
170 EXPECT_EQ("", segments.conversion_segment(0).candidate(1).usage_title);
171 EXPECT_EQ("", segments.conversion_segment(0).candidate(1).usage_description);
172
173 segments.Clear();
174 seg = segments.push_back_segment();
175 // "あおい"
176 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
177 // "あおい", "あああ", "あおい", "あああ"
178 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
179 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82",
180 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
181 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82", seg);
182 // "あおい", "青い", "あおい", "青い"
183 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
184 "\xE9\x9D\x92\xE3\x81\x84",
185 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
186 "\xE9\x9D\x92\xE3\x81\x84", seg);
187 EXPECT_TRUE(rewriter.Rewrite(&segments));
188 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_title);
189 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_description);
190 // "青い"
191 EXPECT_EQ("\xE9\x9D\x92\xE3\x81\x84",
192 segments.conversion_segment(0).candidate(1).usage_title);
193 EXPECT_NE("", segments.conversion_segment(0).candidate(1).usage_description);
194
195 segments.Clear();
196 seg = segments.push_back_segment();
197 // "あおい"
198 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84");
199 // "あおい", "あああ", "あおい", "あああ"
200 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
201 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82",
202 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
203 "\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82", seg);
204 // "あおい", "いいい", "あおい", "いいい"
205 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
206 "\xE3\x81\x84\xE3\x81\x84\xE3\x81\x84",
207 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x84",
208 "\xE3\x81\x84\xE3\x81\x84\xE3\x81\x84", seg);
209 EXPECT_FALSE(rewriter.Rewrite(&segments));
210 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_title);
211 EXPECT_EQ("", segments.conversion_segment(0).candidate(0).usage_description);
212 EXPECT_EQ("", segments.conversion_segment(0).candidate(1).usage_title);
213 EXPECT_EQ("", segments.conversion_segment(0).candidate(1).usage_description);
214 }
215
216 TEST(UsageRewriterTest, MultiSegmentsTest) {
217 Segments segments;
218 UsageRewriter rewriter;
219 Segment *seg;
220
221 segments.Clear();
222 seg = segments.push_back_segment();
223 // "あおく"
224 seg->set_key("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F");
225 // "あおく", "青く", "あおく", "青く"
226 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
227 "\xE9\x9D\x92\xE3\x81\x8F",
228 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
229 "\xE9\x9D\x92\xE3\x81\x8F", seg);
230 // "あおく", "蒼く", "あおく", "蒼く"
231 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
232 "\xE8\x92\xBC\xE3\x81\x8F",
233 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
234 "\xE8\x92\xBC\xE3\x81\x8F", seg);
235 // "あおく", "アオク", "あおく", "アオク"
236 AddCandidate("\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
237 "\xE3\x82\xA2\xE3\x82\xAA\xE3\x82\xAF",
238 "\xE3\x81\x82\xE3\x81\x8A\xE3\x81\x8F",
239 "\xE3\x82\xA2\xE3\x82\xAA\xE3\x82\xAF", seg);
240 seg = segments.push_back_segment();
241 // "うたえば"
242 seg->set_key("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22");
243 // "うたえば", "歌えば", "うたえ", "歌え",
244 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22",
245 "\xE6\xAD\x8C\xE3\x81\x88\xE3\x81\xB0",
246 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
247 "\xE6\xAD\x8C\xE3\x81\x88", seg);
248 // "うたえば", "唱えば", "うたえ", "唄え"
249 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0",
250 "\xE5\x94\xB1\xE3\x81\x88\xE3\x81\xB0",
251 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
252 "\xE5\x94\x84\xE3\x81\x88", seg);
253 EXPECT_TRUE(rewriter.Rewrite(&segments));
254 // "青い"
255 EXPECT_EQ("\xE9\x9D\x92\xE3\x81\x84",
256 segments.conversion_segment(0).candidate(0).usage_title);
257 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
258 // "蒼い"
259 EXPECT_EQ("\xE8\x92\xBC\xE3\x81\x84",
260 segments.conversion_segment(0).candidate(1).usage_title);
261 EXPECT_NE("", segments.conversion_segment(0).candidate(1).usage_description);
262 EXPECT_EQ("", segments.conversion_segment(0).candidate(2).usage_title);
263 EXPECT_EQ("", segments.conversion_segment(0).candidate(2).usage_description);
264 // "歌う"
265 EXPECT_EQ("\xE6\xAD\x8C\xE3\x81\x86",
266 segments.conversion_segment(1).candidate(0).usage_title);
267 EXPECT_NE("", segments.conversion_segment(1).candidate(0).usage_description);
268 // "唄う"
269 EXPECT_EQ("\xE5\x94\x84\xE3\x81\x86",
270 segments.conversion_segment(1).candidate(1).usage_title);
271 EXPECT_NE("", segments.conversion_segment(1).candidate(1).usage_description);
272 }
273
274 TEST(UsageRewriterTest, SameUsageTest) {
275 Segments segments;
276 UsageRewriter rewriter;
277 Segment *seg;
278 seg = segments.push_back_segment();
279 // "うたえば"
280 seg->set_key("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22");
281 // "うたえば", "歌えば", "うたえ", "歌え",
282 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0\x22",
283 "\xE6\xAD\x8C\xE3\x81\x88\xE3\x81\xB0",
284 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
285 "\xE6\xAD\x8C\xE3\x81\x88", seg);
286 // "うたえば", "唱えば", "うたえ", "唄え"
287 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0",
288 "\xE5\x94\xB1\xE3\x81\x88\xE3\x81\xB0",
289 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
290 "\xE5\x94\x84\xE3\x81\x88", seg);
291 // "うたえば", "唱エバ", "うたえ", "唄え"
292 AddCandidate("\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88\xE3\x81\xB0",
293 "\xE5\x94\xB1\xE3\x82\xA8\xE3\x83\x90",
294 "\xE3\x81\x86\xE3\x81\x9F\xE3\x81\x88",
295 "\xE5\x94\x84\xE3\x81\x88", seg);
296 EXPECT_TRUE(rewriter.Rewrite(&segments));
297 // "歌う"
298 EXPECT_EQ("\xE6\xAD\x8C\xE3\x81\x86",
299 segments.conversion_segment(0).candidate(0).usage_title);
300 EXPECT_NE("", segments.conversion_segment(0).candidate(0).usage_description);
301 // "唄う"
302 EXPECT_EQ("\xE5\x94\x84\xE3\x81\x86",
303 segments.conversion_segment(0).candidate(1).usage_title);
304 EXPECT_NE("", segments.conversion_segment(0).candidate(1).usage_description);
305 // "唄う"
306 EXPECT_EQ("\xE5\x94\x84\xE3\x81\x86",
307 segments.conversion_segment(0).candidate(2).usage_title);
308 EXPECT_NE("", segments.conversion_segment(0).candidate(2).usage_description);
309 EXPECT_NE(segments.conversion_segment(0).candidate(0).usage_id,
310 segments.conversion_segment(0).candidate(1).usage_id);
311 EXPECT_EQ(segments.conversion_segment(0).candidate(1).usage_id,
312 segments.conversion_segment(0).candidate(2).usage_id);
313 }
314 } // mozc namespace
118118 #endif // OS_MACOSX
119119 }
120120
121 #ifdef OS_CHROMEOS
122 if (!config_.has_use_realtime_conversion()) {
123 // Realtime conversion is off by default in Chrome OS.
124 config_.set_use_realtime_conversion(false);
125 }
126 #endif // OS_CHROMEOS
127
128121 return true;
129122 }
130123
233226 config::Config::FULL_WIDTH, config::Config::LAST_FORM);
234227 AddCharacterFormRule(config, "?!",
235228 config::Config::FULL_WIDTH, config::Config::LAST_FORM);
236
237 #ifdef OS_CHROMEOS
238 config->set_use_auto_conversion(false);
239 #endif
240229 }
241230
242231 // Reload from file
8484 'layout': ['jp', 'us', 'us(dvorak)'],
8585 # hotkeys property is Chrome/Chromium OS specific. Upstream ibus-daemon
8686 # doesn't support this.
87 'hotkeys': ['Henkan', '', ''],
87 'hotkeys': ['Henkan,Zenkaku_Hankaku', '', ''],
8888 },
8989 }
9090
391391 }
392392 #endif
393393
394 // We don't enable the DELETE_PRECEDING_TEXT feature on Chrome OS for now
395 // since it's highly experimental.
396 #ifndef OS_CHROMEOS
397394 // Currently client capability is fixed.
398395 commands::Capability capability;
399396 capability.set_text_deletion(commands::Capability::DELETE_PRECEDING_TEXT);
400397 session_->set_client_capability(capability);
401398 // TODO(yusukes): write a unit test to check if the capability is set
402399 // as expected.
403 #endif
404400 }
405401
406402 MozcEngine::~MozcEngine() {
0 mozc (1.1.773.102) lucid; urgency=low
1
2 * Ver. 1.1.773.102 on 2011-07-07
3
4 -- Hiroshi Sumita <hsumita> Thu, 07 Jul 2011 15:45:12 +0900
5
06 mozc (1.1.758.102) lucid; urgency=low
17
28 * Ver. 1.1.758.102 on 2011-06-23