From: Peng Huang Date: Sun, 16 May 2010 04:42:22 +0000 (+0800) Subject: Add PunctTable.h X-Git-Tag: 1.3.10~162^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40b35c83033ba26a661731f44405280ed91bd48a;p=platform%2Fupstream%2Fibus-libpinyin.git Add PunctTable.h --- diff --git a/scripts/genpuncttable.py b/scripts/genpuncttable.py new file mode 100644 index 0000000..b852ec6 --- /dev/null +++ b/scripts/genpuncttable.py @@ -0,0 +1,32 @@ +# vim:set et sts=4: +# -*- coding: utf-8 -*- + +from punct import * + +def tocstr(s): + s = s.replace('\\', '\\\\') + s = s.replace('"', '\\"') + return '"%s"' % s + +def gen_table(): + array = [] + i = 0 + print 'static const gchar * const' + print 'puncts[] = {' + for k, vs in punct_map: + k = tocstr(k) + vs = map(tocstr, vs) + array.append((i, k)) + line = ' %s, %s, NULL,' % (k, ", ".join(vs)) + print line.encode("utf8") + i += len(vs) + 2 + print '};' + print + print 'static const gchar * const * const' + print 'punct_table[] = {' + for i, k in array: + print ' &puncts[%d], // %s' % (i, k) + print '};' + +if __name__ == "__main__": + gen_table() diff --git a/src/PunctEditor.cc b/src/PunctEditor.cc index 5b22ce5..45c7dba 100644 --- a/src/PunctEditor.cc +++ b/src/PunctEditor.cc @@ -2,6 +2,8 @@ namespace PY { +#include "PunctTable.h" + PunctEditor::PunctEditor (PinyinProperties & props) : Editor (props) { diff --git a/src/PunctTable.h b/src/PunctTable.h new file mode 100644 index 0000000..939c318 --- /dev/null +++ b/src/PunctTable.h @@ -0,0 +1,197 @@ +static const gchar * const +puncts[] = { + "", ",", "。", "「", "」", "、", ":", ";", "?", "!", NULL, + "!", "!", "﹗", "‼", "⁉", NULL, + "\"", "“", "”", """, NULL, + "#", "#", "﹟", "♯", NULL, + "$", "$", "€", "﹩", "¢", "£", "¥", NULL, + "%", "%", "﹪", "‰", "‱", "㏙", "㏗", NULL, + "&", "&", "﹠", NULL, + "(", "(", "︵", "﹙", NULL, + ")", ")", "︶", "﹚", NULL, + "*", "*", "×", "※", "╳", "﹡", "⁎", "⁑", "⁂", "⌘", NULL, + "+", "+", "±", "﹢", NULL, + ",", ",", "、", "﹐", "﹑", NULL, + "-", "…", "—", "-", "¯", "﹉", " ̄", "﹊", "ˍ", "–", "‥", NULL, + ".", "。", "·", "‧", "﹒", ".", NULL, + "/", "/", "÷", "↗", "↙", "∕", NULL, + "0", "0", NULL, + "1", "1", NULL, + "2", "2", NULL, + "3", "3", NULL, + "4", "4", NULL, + "5", "5", NULL, + "6", "6", NULL, + "7", "7", NULL, + "8", "8", NULL, + "9", "9", NULL, + ":", ":", "︰", "﹕", NULL, + ";", ";", "﹔", NULL, + "<", "<", "〈", "《", "︽", "︿", "﹤", NULL, + "=", "=", "≒", "≠", "≡", "≦", "≧", "﹦", NULL, + ">", ">", "〉", "》", "︾", "﹀", "﹥", NULL, + "?", "?", "﹖", "⁇", "⁈", NULL, + "@", "@", "⊕", "⊙", "㊣", "﹫", "◉", "◎", NULL, + "A", "A", NULL, + "B", "B", NULL, + "C", "C", NULL, + "D", "D", NULL, + "E", "E", NULL, + "F", "F", NULL, + "G", "G", NULL, + "H", "H", NULL, + "I", "I", NULL, + "J", "J", NULL, + "K", "K", NULL, + "L", "L", NULL, + "M", "M", NULL, + "N", "N", NULL, + "O", "O", NULL, + "P", "P", NULL, + "Q", "Q", NULL, + "R", "R", NULL, + "S", "S", NULL, + "T", "T", NULL, + "U", "U", NULL, + "V", "V", NULL, + "W", "W", NULL, + "X", "X", NULL, + "Y", "Y", NULL, + "Z", "Z", NULL, + "[", "「", "[", "『", "【", "「", "︻", "﹁", "﹃", NULL, + "'", "、", "‘", "’", NULL, + "\\", "\", "↖", "↘", "﹨", NULL, + "]", "」", "]", "』", "】", "」", "︼", "﹂", "﹄", NULL, + "^", "︿", "〈", "《", "︽", "﹤", "<", NULL, + "_", "_", "╴", "←", "→", NULL, + "`", "‵", "′", NULL, + "a", "a", NULL, + "b", "b", NULL, + "c", "c", NULL, + "d", "d", NULL, + "e", "e", NULL, + "f", "f", NULL, + "g", "g", NULL, + "h", "h", NULL, + "i", "i", NULL, + "j", "j", NULL, + "k", "k", NULL, + "l", "l", NULL, + "m", "m", NULL, + "n", "n", NULL, + "o", "o", NULL, + "p", "p", NULL, + "q", "q", NULL, + "r", "r", NULL, + "s", "s", NULL, + "t", "t", NULL, + "u", "u", NULL, + "v", "v", NULL, + "w", "w", NULL, + "x", "x", NULL, + "y", "y", NULL, + "z", "z", NULL, + "{", "{", "︷", "﹛", "〔", "﹝", "︹", NULL, + "|", "|", "↑", "↓", "∣", "∥", "︱", "︳", "︴", "¦", NULL, + "}", "}", "︸", "﹜", "〕", "﹞", "︺", NULL, + "~", "~", "﹋", "﹌", NULL, +}; + +static const gchar * const * const +punct_table[] = { + &puncts[0], // "" + &puncts[11], // "!" + &puncts[17], // "\"" + &puncts[22], // "#" + &puncts[27], // "$" + &puncts[35], // "%" + &puncts[43], // "&" + &puncts[47], // "(" + &puncts[52], // ")" + &puncts[57], // "*" + &puncts[68], // "+" + &puncts[73], // "," + &puncts[79], // "-" + &puncts[91], // "." + &puncts[98], // "/" + &puncts[105], // "0" + &puncts[108], // "1" + &puncts[111], // "2" + &puncts[114], // "3" + &puncts[117], // "4" + &puncts[120], // "5" + &puncts[123], // "6" + &puncts[126], // "7" + &puncts[129], // "8" + &puncts[132], // "9" + &puncts[135], // ":" + &puncts[140], // ";" + &puncts[144], // "<" + &puncts[152], // "=" + &puncts[161], // ">" + &puncts[169], // "?" + &puncts[175], // "@" + &puncts[184], // "A" + &puncts[187], // "B" + &puncts[190], // "C" + &puncts[193], // "D" + &puncts[196], // "E" + &puncts[199], // "F" + &puncts[202], // "G" + &puncts[205], // "H" + &puncts[208], // "I" + &puncts[211], // "J" + &puncts[214], // "K" + &puncts[217], // "L" + &puncts[220], // "M" + &puncts[223], // "N" + &puncts[226], // "O" + &puncts[229], // "P" + &puncts[232], // "Q" + &puncts[235], // "R" + &puncts[238], // "S" + &puncts[241], // "T" + &puncts[244], // "U" + &puncts[247], // "V" + &puncts[250], // "W" + &puncts[253], // "X" + &puncts[256], // "Y" + &puncts[259], // "Z" + &puncts[262], // "[" + &puncts[272], // "'" + &puncts[277], // "\\" + &puncts[283], // "]" + &puncts[293], // "^" + &puncts[301], // "_" + &puncts[307], // "`" + &puncts[311], // "a" + &puncts[314], // "b" + &puncts[317], // "c" + &puncts[320], // "d" + &puncts[323], // "e" + &puncts[326], // "f" + &puncts[329], // "g" + &puncts[332], // "h" + &puncts[335], // "i" + &puncts[338], // "j" + &puncts[341], // "k" + &puncts[344], // "l" + &puncts[347], // "m" + &puncts[350], // "n" + &puncts[353], // "o" + &puncts[356], // "p" + &puncts[359], // "q" + &puncts[362], // "r" + &puncts[365], // "s" + &puncts[368], // "t" + &puncts[371], // "u" + &puncts[374], // "v" + &puncts[377], // "w" + &puncts[380], // "x" + &puncts[383], // "y" + &puncts[386], // "z" + &puncts[389], // "{" + &puncts[397], // "|" + &puncts[408], // "}" + &puncts[416], // "~" +};