• R/O
  • SSH
  • HTTPS

aquaskk: Commit


Commit MetaInfo

Revision146 (tree)
Time2009-11-25 00:16:35
Authort-suwa

Log Message

r200@milonga-2: t_suwa | 2009-11-23 16:47:49 +0900
- SKKRomanKanaConverter: Patch メソッドを追加(設定ファイルの差分反映)

r201@milonga-2: t_suwa | 2009-11-23 16:48:48 +0900
- period.rule: 新規追加(kana-rule.conf 差分反映テスト用)

r202@milonga-2: t_suwa | 2009-11-23 16:49:10 +0900
- SKKRomanKanaConverter_TEST: SKKRomanKanaConverter::Patch のテストを追加

r203@milonga-2: t_suwa | 2009-11-25 00:02:34 +0900
- SKKConstVars: SKKUserDefaultKeys::sub_rules と SKKFilePaths::SystemResourceFolder を追加

r204@milonga-2: t_suwa | 2009-11-25 00:07:32 +0900
- SKKServer: reloadComponents に sub_rule 適用処理を追加

r205@milonga-2: t_suwa | 2009-11-25 00:10:38 +0900
- comma.rule, period.rule: 新規追加(かな変換規則の差分ファイル)

r206@milonga-2: t_suwa | 2009-11-25 00:11:09 +0900
- sub-rule.desc: 補助ルールの説明文言

r207@milonga-2: t_suwa | 2009-11-25 00:12:50 +0900
- SubRuleDescriptions.*: 新規追加(sub-rule.desc 解析クラス)

r208@milonga-2: t_suwa | 2009-11-25 00:14:14 +0900
- PreferenceController.*: 補助ルールの読み込みと書き込みをサポート

r209@milonga-2: t_suwa | 2009-11-25 00:14:50 +0900
- Preferences.xib: 補助ルール編集用にかな変換タブを追加

r210@milonga-2: t_suwa | 2009-11-25 00:15:11 +0900
- プロジェクトを更新

Change Summary

Incremental Difference

--- aquaskk/trunk/platform/mac/src/preferences/PreferenceController.h (revision 145)
+++ aquaskk/trunk/platform/mac/src/preferences/PreferenceController.h (revision 146)
@@ -36,6 +36,7 @@
3636 IBOutlet NSTextField* version_;
3737 IBOutlet NSTextField* copyright_;
3838 IBOutlet NSArrayController* dictionaryTypes_;
39+ IBOutlet NSArrayController* subRuleController_;
3940
4041 NSMutableDictionary* preferences_;
4142 NSMutableArray* dictionarySet_;
--- aquaskk/trunk/platform/mac/src/preferences/SubRuleDescriptions.cpp (nonexistent)
+++ aquaskk/trunk/platform/mac/src/preferences/SubRuleDescriptions.cpp (revision 146)
@@ -0,0 +1,58 @@
1+/* -*- C++ -*-
2+
3+ MacOS X implementation of the SKK input method.
4+
5+ Copyright (C) 2009 Tomotaka SUWA <tomotaka.suwa@gmail.com>
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 2 of the License, or
10+ any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program; if not, write to the Free Software
19+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
21+*/
22+
23+#include "SubRuleDescriptions.h"
24+#include <fstream>
25+#include <sstream>
26+#include <iostream>
27+
28+SubRuleDescriptions::SubRuleDescriptions(const char* folder) {
29+ std::string path(std::string(folder) + "/sub-rule.desc");
30+ std::ifstream ifs(path.c_str());
31+ std::string line;
32+
33+ while(std::getline(ifs, line)) {
34+ add(line);
35+ }
36+}
37+
38+const char* SubRuleDescriptions::Description(const char* rule_path) {
39+ if(table_.find(rule_path) != table_.end()) {
40+ return table_[rule_path].c_str();
41+ }
42+
43+ return rule_path;
44+}
45+
46+// ----------------------------------------------------------------------
47+
48+void SubRuleDescriptions::add(const std::string& line) {
49+ if(line.empty() || line[0] == '#') return;
50+
51+ std::istringstream buf(line);
52+ std::string path;
53+ std::string description;
54+
55+ if(buf >> path >> description) {
56+ table_[path] = description;
57+ }
58+}
--- aquaskk/trunk/platform/mac/src/preferences/SubRuleDescriptions.h (nonexistent)
+++ aquaskk/trunk/platform/mac/src/preferences/SubRuleDescriptions.h (revision 146)
@@ -0,0 +1,40 @@
1+/* -*- C++ -*-
2+
3+ MacOS X implementation of the SKK input method.
4+
5+ Copyright (C) 2009 Tomotaka SUWA <tomotaka.suwa@gmail.com>
6+
7+ This program is free software; you can redistribute it and/or modify
8+ it under the terms of the GNU General Public License as published by
9+ the Free Software Foundation; either version 2 of the License, or
10+ any later version.
11+
12+ This program is distributed in the hope that it will be useful,
13+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ GNU General Public License for more details.
16+
17+ You should have received a copy of the GNU General Public License
18+ along with this program; if not, write to the Free Software
19+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
21+*/
22+
23+#ifndef SubRuleDescriptions_h
24+#define SubRuleDescriptions_h
25+
26+#include <string>
27+#include <map>
28+
29+class SubRuleDescriptions {
30+ std::map<std::string, std::string> table_;
31+
32+ void add(const std::string& line);
33+
34+public:
35+ SubRuleDescriptions(const char* folder);
36+
37+ const char* Description(const char* rule_path);
38+};
39+
40+#endif
--- aquaskk/trunk/platform/mac/src/server/SKKConstVars.h (revision 145)
+++ aquaskk/trunk/platform/mac/src/server/SKKConstVars.h (revision 146)
@@ -35,6 +35,8 @@
3535
3636 extern NSString* keyboard_layout;
3737
38+ extern NSString* sub_rules;
39+
3840 extern NSString* enable_extended_completion;
3941 extern NSString* enable_dynamic_completion;
4042 extern NSString* dynamic_completion_range;
@@ -72,6 +74,7 @@
7274
7375 // 重要なパス
7476 namespace SKKFilePaths {
77+ extern NSString* SystemResourceFolder;
7578 extern NSString* ApplicationSupportFolder;
7679 extern NSString* DictionarySet;
7780 extern NSString* UserDefaults;
--- aquaskk/trunk/src/engine/tests/SKKRomanKanaConverter_TEST.cpp (revision 145)
+++ aquaskk/trunk/src/engine/tests/SKKRomanKanaConverter_TEST.cpp (revision 146)
@@ -84,4 +84,12 @@
8484
8585 result = conv.Convert(HirakanaInputMode, "z ", state);
8686 assert(state.next == "" && state.output == " ");
87+
88+ result = conv.Convert(HirakanaInputMode, ".", state);
89+ assert(state.output == "。");
90+
91+ conv.Patch("period.rule");
92+
93+ result = conv.Convert(HirakanaInputMode, ".", state);
94+ assert(state.output == ".");
8795 }
--- aquaskk/trunk/src/engine/trie/SKKRomanKanaConverter.cpp (revision 145)
+++ aquaskk/trunk/src/engine/trie/SKKRomanKanaConverter.cpp (revision 146)
@@ -139,15 +139,55 @@
139139 }
140140
141141 void SKKRomanKanaConverter::Initialize(const std::string& path) {
142+ load(path, true);
143+}
144+
145+void SKKRomanKanaConverter::Patch(const std::string& path) {
146+ load(path, false);
147+}
148+
149+bool SKKRomanKanaConverter::Convert(SKKInputMode mode, const std::string& str, SKKRomanKanaConversionResult& result) {
150+ bool converted = false;
151+ std::string queue(str);
152+
153+ result = SKKRomanKanaConversionResult();
154+
155+ while(!queue.empty()) {
156+ ConversionHelper helper(mode, queue);
157+
158+ root_.Traverse(helper);
159+
160+ result.output += helper.Output();
161+ result.next = helper.Next();
162+ result.intermediate = helper.Intermediate();
163+
164+ converted = helper.IsConverted();
165+
166+ if(helper.IsShort()) {
167+ result.next = helper.Queue();
168+ break;
169+ }
170+
171+ queue = helper.Queue();
172+ }
173+
174+ return converted;
175+}
176+
177+// ----------------------------------------------------------------------
178+
179+void SKKRomanKanaConverter::load(const std::string& path, bool initialize) {
142180 std::ifstream ifs(path.c_str());
143181 std::string str;
144182
145183 if(!ifs) {
146- std::cerr << "SKKRomanKanaConverter::Initialize(): can't open file [" << path << "]" << std::endl;
184+ std::cerr << "SKKRomanKanaConverter::load(): can't open file [" << path << "]" << std::endl;
147185 return;
148186 }
149187
150- root_.Clear();
188+ if(initialize) {
189+ root_.Clear();
190+ }
151191
152192 while(std::getline(ifs, str)) {
153193 if(str.empty() || str[0] == '#') continue;
@@ -177,35 +217,7 @@
177217 root_.Add(roman, SKKTrie(hirakana, katakana, jisx0201kana, next));
178218 } else {
179219 // 不正な形式
180- std::cerr << "SKKRomanKanaConverter::Initialize(): invalid rule [" << utf8 << "]" << std::endl;
220+ std::cerr << "SKKRomanKanaConverter::load(): invalid rule [" << utf8 << "]" << std::endl;
181221 }
182222 }
183223 }
184-
185-bool SKKRomanKanaConverter::Convert(SKKInputMode mode, const std::string& str, SKKRomanKanaConversionResult& result) {
186- bool converted = false;
187- std::string queue(str);
188-
189- result = SKKRomanKanaConversionResult();
190-
191- while(!queue.empty()) {
192- ConversionHelper helper(mode, queue);
193-
194- root_.Traverse(helper);
195-
196- result.output += helper.Output();
197- result.next = helper.Next();
198- result.intermediate = helper.Intermediate();
199-
200- converted = helper.IsConverted();
201-
202- if(helper.IsShort()) {
203- result.next = helper.Queue();
204- break;
205- }
206-
207- queue = helper.Queue();
208- }
209-
210- return converted;
211-}
--- aquaskk/trunk/src/engine/trie/SKKRomanKanaConverter.h (revision 145)
+++ aquaskk/trunk/src/engine/trie/SKKRomanKanaConverter.h (revision 146)
@@ -40,11 +40,15 @@
4040 SKKRomanKanaConverter();
4141 SKKRomanKanaConverter(const SKKRomanKanaConverter&);
4242
43+ void load(const std::string& path, bool initialize);
44+
4345 public:
4446 static SKKRomanKanaConverter& theInstance();
4547
4648 void Initialize(const std::string& path);
4749
50+ void Patch(const std::string& path);
51+
4852 // ローマ字かな変換
4953 //
5054 // 引数:
Show on old repository browser