Skip to content

Commit 6015ea3

Browse files
author
Keng-Yu Lin
committed
Add back simple codes (originally called short codes)
closes #6 Signed-off-by: Keng-Yu Lin <kengyu@lexical.tw>
1 parent 4097a6f commit 6015ea3

8 files changed

Lines changed: 9351 additions & 9 deletions

File tree

data/array.db

0 Bytes
Binary file not shown.

data/array30_simplecode.cin

Lines changed: 9309 additions & 0 deletions
Large diffs are not rendered by default.

data/cin2sqlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
REGION_UNIFIED_ExtCD = 4
2929
REGION_UNIFIED_ExtE = 5
3030
REGION_UNIFIED_ExtF = 6
31-
REGION_ARRAY_SIMPLE = 7
31+
REGION_ARRAY_SYMBOL = 7
3232

3333
STR_UNIFIED_ExtA = "CJK Unified Ideographs + Extension A"
3434
STR_ARRAY_SPECIAL = "Array30 Special Code"
3535
STR_UNIFIED_ExtB = "CJK Unified Ideographs Extension B"
3636
STR_UNIFIED_ExtCD = "CJK Unified Ideographs Extension C & D"
3737
STR_UNIFIED_ExtE = "CJK Unified Ideographs Extension E"
3838
STR_UNIFIED_ExtF = "CJK Unified Ideographs Extension F"
39-
STR_ARRAY_SIMPLE = "CJK Symbols & Punctuation for Array30 input method (w+0~9)"
39+
STR_ARRAY_SYMBOL = "CJK Symbols & Punctuation for Array30 input method (w+0~9)"
4040

4141
REG_STACK = []
4242

data/emptyDB.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
con = sqlite.connect(argv[1])
2727
cur = con.cursor()
2828
cur.execute('DELETE FROM main;')
29+
cur.execute('DELETE FROM simple;')
2930
con.commit()
3031
con.close()

data/updateSimple.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
from pysqlite2 import dbapi2 as sqlite
5+
6+
def array_updatedb(table_file, table):
7+
con = sqlite.connect("array.db")
8+
cur = con.cursor()
9+
cur.execute('select * from ' + table)
10+
tbl = cur.fetchall()
11+
12+
# read from the text table
13+
f = open(table_file, 'r')
14+
z = map(lambda x:x.split('\t'), filter(lambda k:(k[0] != '#' and k[0] != '%' and len(k.strip()) != 0), f.readlines()))
15+
k = map(lambda y:(y[0].lower(), y[1].strip(' \n')), z)
16+
f.close()
17+
18+
# update the database
19+
for i, j in k:
20+
cur.execute('INSERT INTO ' + table + ' (keys, ch) VALUES ("' + i + '", "' + j + '");')
21+
22+
con.commit()
23+
con.close()
24+
25+
# empty tables
26+
con = sqlite.connect("array.db")
27+
cur = con.cursor()
28+
cur.execute('DELETE FROM simple;')
29+
con.commit()
30+
con.close()
31+
32+
array_updatedb('array30_simplecode.cin', 'simple')

src/array.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ GArray* array_get_candidates_from_main(ArrayContext *context, gchar *keys) {
138138
return result;
139139
}
140140

141-
GArray* array_get_candidates_from_short(ArrayContext *context, gchar *keys) {
141+
GArray* array_get_candidates_from_simple(ArrayContext *context, gchar *keys) {
142142
GArray *result;
143143
result = (GArray*)g_array_new(FALSE, FALSE, sizeof(gchar*));
144144

145145
sqlite3_stmt *stmt;
146146

147147
int retcode;
148-
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM short WHERE keys=?", -1, &stmt, NULL);
148+
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM simple WHERE keys=?", -1, &stmt, NULL);
149149
if (retcode == SQLITE_OK) {
150150
sqlite3_bind_text(stmt, 1, keys, -1, SQLITE_TRANSIENT);
151151
while (sqlite3_step(stmt) == SQLITE_ROW) {
@@ -167,7 +167,7 @@ GArray* array_get_candidates_from_special(ArrayContext *context, gchar *keys) {
167167
sqlite3_stmt *stmt;
168168

169169
int retcode;
170-
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM special WHERE keys=?", -1, &stmt, NULL);
170+
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM main WHERE cat='2' AND keys=?", -1, &stmt, NULL);
171171
if (retcode == SQLITE_OK) {
172172
sqlite3_bind_text(stmt, 1, keys, -1, SQLITE_TRANSIENT);
173173
while (sqlite3_step(stmt) == SQLITE_ROW) {
@@ -189,7 +189,7 @@ GArray* array_get_reverted_key_candidates_from_special(ArrayContext *context, gc
189189
sqlite3_stmt *stmt;
190190

191191
int retcode;
192-
retcode = sqlite3_prepare_v2(context->conn, "SELECT keys FROM special WHERE ch=?", -1, &stmt, NULL);
192+
retcode = sqlite3_prepare_v2(context->conn, "SELECT keys FROM main WHERE cat='2' AND ch=?", -1, &stmt, NULL);
193193
if (retcode == SQLITE_OK) {
194194
sqlite3_bind_text(stmt, 1, ch, -1, SQLITE_TRANSIENT);
195195
while (sqlite3_step(stmt) == SQLITE_ROW) {
@@ -211,7 +211,7 @@ GArray* array_get_reverted_char_candidates_from_special(ArrayContext *context, g
211211
sqlite3_stmt *stmt;
212212

213213
int retcode;
214-
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM special WHERE keys=?", -1, &stmt, NULL);
214+
retcode = sqlite3_prepare_v2(context->conn, "SELECT ch FROM main WHERE cat='2' AND keys=?", -1, &stmt, NULL);
215215
if (retcode == SQLITE_OK) {
216216
sqlite3_bind_text(stmt, 1, keys, -1, SQLITE_TRANSIENT);
217217
while (sqlite3_step(stmt) == SQLITE_ROW) {

src/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ArrayContext* array_create_context();
3333
void array_release_context(ArrayContext *context);
3434
GString* array_get_preedit_string(GString *preedit);
3535
GArray* array_get_candidates_from_main(ArrayContext *context, gchar *keys);
36-
GArray* array_get_candidates_from_short(ArrayContext *context, gchar *keys);
36+
GArray* array_get_candidates_from_simple(ArrayContext *context, gchar *keys);
3737
GArray* array_get_candidates_from_special(ArrayContext *context, gchar *keys);
3838
GArray* array_get_reverted_key_candidates_from_special(ArrayContext *context, gchar *ch);
3939
GArray* array_get_reverted_char_candidates_from_special(ArrayContext *context, gchar *keys);

src/engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static void ibus_array_engine_update_lookup_table (IBusArrayEngine *arrayeng) {
267267
GArray *candidates = NULL;
268268

269269
if (arrayeng->preedit->len <= 2 && arrayeng->space_press_count == 0)
270-
candidates = array_get_candidates_from_short(array_context, arrayeng->preedit->str);
270+
candidates = array_get_candidates_from_simple(array_context, arrayeng->preedit->str);
271271
else
272272
candidates = array_get_candidates_from_main(array_context, arrayeng->preedit->str);
273273

0 commit comments

Comments
 (0)