1 /***************************************************************************
2 * Copyright (C) 2002~2005 by Yuking *
3 * yuking_net@sohu.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20
21 #include "fcitx/fcitx.h"
22 #include "PYFA.h"
23 #include "pyconfig.h"
24
25 #include <stdio.h>
26 #include "fcitx-utils/log.h"
27 #include <string.h>
28 #include <fcitx-utils/utils.h>
29
30 const MHPY_TEMPLATE MHPY_C_TEMPLATE[] = { //韵母
31 //{"an","ang"},
32 {"CD"}
33 ,
34 //{"en","eng"},
35 {"HI"}
36 ,
37 //{"ian","iang"},
38 {"LM"}
39 ,
40 //{"in","ing"},
41 {"PQ"}
42 ,
43 //{"u","ou"},
44 {"VW"}
45 ,
46 //{"uan","uang"},
47 {"Za"}
48 ,
49 //{"v", "u"},
50 {"fW"}
51 ,
52
53 {"\0"}
54 };
55
56 const MHPY_TEMPLATE MHPY_S_TEMPLATE[] = { //声母
57 //{"c","ch"},
58 {"bc"}
59 ,
60 //{"f","h"},
61 {"TV"}
62 ,
63 //{"l","n"},
64 {"OQ"}
65 ,
66 //{"s","sh"},
67 {"GH"}
68 ,
69 //{"z","zh"},
70 {"AB"}
71 ,
72 //{"an","ang"}
73 {"fg"}
74 ,
75
76 {"\0"}
77 };
78
79 //其中增加了那些不是标准的拼音,但模糊输入中需要使用的拼音组合
80 const PYTABLE_TEMPLATE PYTable_template[] = {
81 {"zuo", PYTABLE_NONE}
82 ,
83 {"zun", PYTABLE_NONE}
84 ,
85 {"zui", PYTABLE_NONE}
86 ,
87 {"zuagn", PYTABLE_NG_GN}
88 ,
89 {"zuang", PYTABLE_UAN_UANG}
90 ,
91 {"zuagn", PYTABLE_NG_GN}
92 ,
93 {"zuang", PYTABLE_Z_ZH}
94 ,
95 {"zuan", PYTABLE_NONE}
96 ,
97 {"zua", PYTABLE_Z_ZH}
98 ,
99 {"zu", PYTABLE_NONE}
100 ,
101 {"zou", PYTABLE_NONE}
102 ,
103 {"zogn", PYTABLE_NG_GN}
104 ,
105 {"zong", PYTABLE_NONE}
106 ,
107 {"zi", PYTABLE_NONE}
108 ,
109 {"zhuo", PYTABLE_NONE}
110 ,
111 {"zhun", PYTABLE_NONE}
112 ,
113 {"zhui", PYTABLE_NONE}
114 ,
115 {"zhuagn", PYTABLE_NG_GN}
116 ,
117 {"zhuang", PYTABLE_NONE}
118 ,
119 {"zhuan", PYTABLE_NONE}
120 ,
121 {"zhuai", PYTABLE_NONE}
122 ,
123 {"zhua", PYTABLE_NONE}
124 ,
125 {"zhu", PYTABLE_NONE}
126 ,
127 {"zhou", PYTABLE_NONE}
128 ,
129 {"zhogn", PYTABLE_NG_GN}
130 ,
131 {"zhong", PYTABLE_NONE}
132 ,
133 {"zhi", PYTABLE_NONE}
134 ,
135 {"zhegn", PYTABLE_NG_GN}
136 ,
137 {"zheng", PYTABLE_NONE}
138 ,
139 {"zhen", PYTABLE_NONE}
140 ,
141 {"zhe", PYTABLE_NONE}
142 ,
143 {"zhao", PYTABLE_NONE}
144 ,
145 {"zhagn", PYTABLE_NG_GN}
146 ,
147 {"zhang", PYTABLE_NONE}
148 ,
149 {"zhan", PYTABLE_NONE}
150 ,
151 {"zhai", PYTABLE_NONE}
152 ,
153 {"zha", PYTABLE_NONE}
154 ,
155 {"zegn", PYTABLE_NG_GN}
156 ,
157 {"zeng", PYTABLE_NONE}
158 ,
159 {"zen", PYTABLE_NONE}
160 ,
161 {"zei", PYTABLE_NONE}
162 ,
163 {"ze", PYTABLE_NONE}
164 ,
165 {"zao", PYTABLE_NONE}
166 ,
167 {"zagn", PYTABLE_NG_GN}
168 ,
169 {"zang", PYTABLE_NONE}
170 ,
171 {"zan", PYTABLE_NONE}
172 ,
173 {"zai", PYTABLE_NONE}
174 ,
175 {"za", PYTABLE_NONE}
176 ,
177 {"yun", PYTABLE_NONE}
178 ,
179 {"yue", PYTABLE_NONE}
180 ,
181 {"yuagn", PYTABLE_NG_GN}
182 ,
183 {"yuang", PYTABLE_UAN_UANG}
184 ,
185 {"yuan", PYTABLE_NONE}
186 ,
187 {"yu", PYTABLE_NONE}
188 ,
189 {"yv", PYTABLE_V_U}
190 ,
191 {"you", PYTABLE_NONE}
192 ,
193 {"yogn", PYTABLE_NG_GN}
194 ,
195 {"yong", PYTABLE_NONE}
196 ,
197 {"yo", PYTABLE_NONE}
198 ,
199 {"yign", PYTABLE_NG_GN}
200 ,
201 {"ying", PYTABLE_NONE}
202 ,
203 {"yin", PYTABLE_NONE}
204 ,
205 {"yi", PYTABLE_NONE}
206 ,
207 {"ye", PYTABLE_NONE}
208 ,
209 {"yao", PYTABLE_NONE}
210 ,
211 {"yagn", PYTABLE_NG_GN}
212 ,
213 {"yang", PYTABLE_NONE}
214 ,
215 {"yan", PYTABLE_NONE}
216 ,
217 {"ya", PYTABLE_NONE}
218 ,
219 {"xun", PYTABLE_NONE}
220 ,
221 {"xue", PYTABLE_NONE}
222 ,
223 {"xuagn", PYTABLE_NG_GN}
224 ,
225 {"xuang", PYTABLE_UAN_UANG}
226 ,
227 {"xuan", PYTABLE_NONE}
228 ,
229 {"xu", PYTABLE_NONE}
230 ,
231 {"xv", PYTABLE_V_U}
232 ,
233 {"xou", PYTABLE_U_OU}
234 ,
235 {"xiu", PYTABLE_NONE}
236 ,
237 {"xiogn", PYTABLE_NG_GN}
238 ,
239 {"xiong", PYTABLE_NONE}
240 ,
241 {"xign", PYTABLE_NG_GN}
242 ,
243 {"xing", PYTABLE_NONE}
244 ,
245 {"xin", PYTABLE_NONE}
246 ,
247 {"xie", PYTABLE_NONE}
248 ,
249 {"xiao", PYTABLE_NONE}
250 ,
251 {"xiagn", PYTABLE_NG_GN}
252 ,
253 {"xiang", PYTABLE_NONE}
254 ,
255 {"xian", PYTABLE_NONE}
256 ,
257 {"xia", PYTABLE_NONE}
258 ,
259 {"xi", PYTABLE_NONE}
260 ,
261 {"wu", PYTABLE_NONE}
262 ,
263 {"wo", PYTABLE_NONE}
264 ,
265 {"wegn", PYTABLE_NG_GN}
266 ,
267 {"weng", PYTABLE_NONE}
268 ,
269 {"wen", PYTABLE_NONE}
270 ,
271 {"wei", PYTABLE_NONE}
272 ,
273 {"wagn", PYTABLE_NG_GN}
274 ,
275 {"wang", PYTABLE_NONE}
276 ,
277 {"wan", PYTABLE_NONE}
278 ,
279 {"wai", PYTABLE_NONE}
280 ,
281 {"wa", PYTABLE_NONE}
282 ,
283 {"tuo", PYTABLE_NONE}
284 ,
285 {"tun", PYTABLE_NONE}
286 ,
287 {"tui", PYTABLE_NONE}
288 ,
289 {"tuagn", PYTABLE_NG_GN}
290 ,
291 {"tuang", PYTABLE_UAN_UANG}
292 ,
293 {"tuan", PYTABLE_NONE}
294 ,
295 {"tu", PYTABLE_NONE}
296 ,
297 {"tou", PYTABLE_NONE}
298 ,
299 {"togn", PYTABLE_NG_GN}
300 ,
301 {"tong", PYTABLE_NONE}
302 ,
303 {"tign", PYTABLE_NG_GN}
304 ,
305 {"ting", PYTABLE_NONE}
306 ,
307 {"tin", PYTABLE_IN_ING}
308 ,
309 {"tie", PYTABLE_NONE}
310 ,
311 {"tiao", PYTABLE_NONE}
312 ,
313 {"tiagn", PYTABLE_NG_GN}
314 ,
315 {"tiang", PYTABLE_IAN_IANG}
316 ,
317 {"tian", PYTABLE_NONE}
318 ,
319 {"ti", PYTABLE_NONE}
320 ,
321 {"tegn", PYTABLE_NG_GN}
322 ,
323 {"teng", PYTABLE_NONE}
324 ,
325 {"ten", PYTABLE_EN_ENG}
326 ,
327 {"tei", PYTABLE_NONE}
328 ,
329 {"te", PYTABLE_NONE}
330 ,
331 {"tao", PYTABLE_NONE}
332 ,
333 {"tagn", PYTABLE_NG_GN}
334 ,
335 {"tang", PYTABLE_NONE}
336 ,
337 {"tan", PYTABLE_NONE}
338 ,
339 {"tai", PYTABLE_NONE}
340 ,
341 {"ta", PYTABLE_NONE}
342 ,
343 {"suo", PYTABLE_NONE}
344 ,
345 {"sun", PYTABLE_NONE}
346 ,
347 {"sui", PYTABLE_NONE}
348 ,
349 {"suagn", PYTABLE_NG_GN}
350 ,
351 {"suang", PYTABLE_S_SH}
352 ,
353 {"suagn", PYTABLE_NG_GN}
354 ,
355 {"suang", PYTABLE_UAN_UANG}
356 ,
357 {"suan", PYTABLE_NONE}
358 ,
359 {"sua", PYTABLE_S_SH}
360 ,
361 {"su", PYTABLE_NONE}
362 ,
363 {"sou", PYTABLE_NONE}
364 ,
365 {"sogn", PYTABLE_NG_GN}
366 ,
367 {"song", PYTABLE_NONE}
368 ,
369 {"si", PYTABLE_NONE}
370 ,
371 {"shuo", PYTABLE_NONE}
372 ,
373 {"shun", PYTABLE_NONE}
374 ,
375 {"shui", PYTABLE_NONE}
376 ,
377 {"shuagn", PYTABLE_NG_GN}
378 ,
379 {"shuang", PYTABLE_NONE}
380 ,
381 {"shuan", PYTABLE_NONE}
382 ,
383 {"shuai", PYTABLE_NONE}
384 ,
385 {"shua", PYTABLE_NONE}
386 ,
387 {"shu", PYTABLE_NONE}
388 ,
389 {"shou", PYTABLE_NONE}
390 ,
391 {"shi", PYTABLE_NONE}
392 ,
393 {"shegn", PYTABLE_NG_GN}
394 ,
395 {"sheng", PYTABLE_NONE}
396 ,
397 {"shen", PYTABLE_NONE}
398 ,
399 {"shei", PYTABLE_NONE}
400 ,
401 {"she", PYTABLE_NONE}
402 ,
403 {"shao", PYTABLE_NONE}
404 ,
405 {"shagn", PYTABLE_NG_GN}
406 ,
407 {"shang", PYTABLE_NONE}
408 ,
409 {"shan", PYTABLE_NONE}
410 ,
411 {"shai", PYTABLE_NONE}
412 ,
413 {"sha", PYTABLE_NONE}
414 ,
415 {"segn", PYTABLE_NG_GN}
416 ,
417 {"seng", PYTABLE_NONE}
418 ,
419 {"sen", PYTABLE_NONE}
420 ,
421 {"se", PYTABLE_NONE}
422 ,
423 {"sao", PYTABLE_NONE}
424 ,
425 {"sagn", PYTABLE_NG_GN}
426 ,
427 {"sang", PYTABLE_NONE}
428 ,
429 {"san", PYTABLE_NONE}
430 ,
431 {"sai", PYTABLE_NONE}
432 ,
433 {"sa", PYTABLE_NONE}
434 ,
435 {"ruo", PYTABLE_NONE}
436 ,
437 {"run", PYTABLE_NONE}
438 ,
439 {"rui", PYTABLE_NONE}
440 ,
441 {"ruagn", PYTABLE_NG_GN}
442 ,
443 {"ruang", PYTABLE_UAN_UANG}
444 ,
445 {"ruan", PYTABLE_NONE}
446 ,
447 {"ru", PYTABLE_NONE}
448 ,
449 {"rou", PYTABLE_NONE}
450 ,
451 {"rogn", PYTABLE_NG_GN}
452 ,
453 {"rong", PYTABLE_NONE}
454 ,
455 {"ri", PYTABLE_NONE}
456 ,
457 {"regn", PYTABLE_NG_GN}
458 ,
459 {"reng", PYTABLE_NONE}
460 ,
461 {"ren", PYTABLE_NONE}
462 ,
463 {"re", PYTABLE_NONE}
464 ,
465 {"rao", PYTABLE_NONE}
466 ,
467 {"ragn", PYTABLE_NG_GN}
468 ,
469 {"rang", PYTABLE_NONE}
470 ,
471 {"ran", PYTABLE_NONE}
472 ,
473 {"qun", PYTABLE_NONE}
474 ,
475 {"que", PYTABLE_NONE}
476 ,
477 {"quagn", PYTABLE_NG_GN}
478 ,
479 {"quang", PYTABLE_UAN_UANG}
480 ,
481 {"quan", PYTABLE_NONE}
482 ,
483 {"qu", PYTABLE_NONE}
484 ,
485 {"qv", PYTABLE_V_U}
486 ,
487 {"qiu", PYTABLE_NONE}
488 ,
489 {"qiogn", PYTABLE_NG_GN}
490 ,
491 {"qiong", PYTABLE_NONE}
492 ,
493 {"qign", PYTABLE_NG_GN}
494 ,
495 {"qing", PYTABLE_NONE}
496 ,
497 {"qin", PYTABLE_NONE}
498 ,
499 {"qie", PYTABLE_NONE}
500 ,
501 {"qiao", PYTABLE_NONE}
502 ,
503 {"qiagn", PYTABLE_NG_GN}
504 ,
505 {"qiang", PYTABLE_NONE}
506 ,
507 {"qian", PYTABLE_NONE}
508 ,
509 {"qia", PYTABLE_NONE}
510 ,
511 {"qi", PYTABLE_NONE}
512 ,
513 {"pu", PYTABLE_NONE}
514 ,
515 {"pou", PYTABLE_NONE}
516 ,
517 {"po", PYTABLE_NONE}
518 ,
519 {"pign", PYTABLE_NG_GN}
520 ,
521 {"ping", PYTABLE_NONE}
522 ,
523 {"pin", PYTABLE_NONE}
524 ,
525 {"pie", PYTABLE_NONE}
526 ,
527 {"piao", PYTABLE_NONE}
528 ,
529 {"piagn", PYTABLE_NG_GN}
530 ,
531 {"piang", PYTABLE_IAN_IANG}
532 ,
533 {"pian", PYTABLE_NONE}
534 ,
535 {"pi", PYTABLE_NONE}
536 ,
537 {"pegn", PYTABLE_NG_GN}
538 ,
539 {"peng", PYTABLE_NONE}
540 ,
541 {"pen", PYTABLE_NONE}
542 ,
543 {"pei", PYTABLE_NONE}
544 ,
545 {"pao", PYTABLE_NONE}
546 ,
547 {"pagn", PYTABLE_NG_GN}
548 ,
549 {"pang", PYTABLE_NONE}
550 ,
551 {"pan", PYTABLE_NONE}
552 ,
553 {"pai", PYTABLE_NONE}
554 ,
555 {"pa", PYTABLE_NONE}
556 ,
557 {"ou", PYTABLE_NONE}
558 ,
559 {"o", PYTABLE_NONE}
560 ,
561 {"nve", PYTABLE_NONE}
562 ,
563 {"nv", PYTABLE_NONE}
564 ,
565 {"nuo", PYTABLE_NONE}
566 ,
567 {"nue", PYTABLE_NONE}
568 ,
569 {"nuagn", PYTABLE_NG_GN}
570 ,
571 {"nuang", PYTABLE_UAN_UANG}
572 ,
573 {"nuagn", PYTABLE_NG_GN}
574 ,
575 {"nuang", PYTABLE_L_N}
576 ,
577 {"nuan", PYTABLE_NONE}
578 ,
579 {"nu", PYTABLE_NONE}
580 ,
581 {"nou", PYTABLE_NONE}
582 ,
583 {"nogn", PYTABLE_NG_GN}
584 ,
585 {"nong", PYTABLE_NONE}
586 ,
587 {"niu", PYTABLE_NONE}
588 ,
589 {"nign", PYTABLE_NG_GN}
590 ,
591 {"ning", PYTABLE_NONE}
592 ,
593 {"nin", PYTABLE_NONE}
594 ,
595 {"nie", PYTABLE_NONE}
596 ,
597 {"niao", PYTABLE_NONE}
598 ,
599 {"niagn", PYTABLE_NG_GN}
600 ,
601 {"niang", PYTABLE_NONE}
602 ,
603 {"nian", PYTABLE_NONE}
604 ,
605 {"ni", PYTABLE_NONE}
606 ,
607 {"ng", PYTABLE_NONE}
608 ,
609 {"negn", PYTABLE_NG_GN}
610 ,
611 {"neng", PYTABLE_NONE}
612 ,
613 {"nen", PYTABLE_NONE}
614 ,
615 {"nei", PYTABLE_NONE}
616 ,
617 {"ne", PYTABLE_NONE}
618 ,
619 {"nao", PYTABLE_NONE}
620 ,
621 {"nagn", PYTABLE_NG_GN}
622 ,
623 {"nang", PYTABLE_NONE}
624 ,
625 {"nan", PYTABLE_NONE}
626 ,
627 {"nai", PYTABLE_NONE}
628 ,
629 {"na", PYTABLE_NONE}
630 ,
631 {"n", PYTABLE_NONE}
632 ,
633 {"mu", PYTABLE_NONE}
634 ,
635 {"mou", PYTABLE_NONE}
636 ,
637 {"mo", PYTABLE_NONE}
638 ,
639 {"miu", PYTABLE_NONE}
640 ,
641 {"mign", PYTABLE_NG_GN}
642 ,
643 {"ming", PYTABLE_NONE}
644 ,
645 {"min", PYTABLE_NONE}
646 ,
647 {"mie", PYTABLE_NONE}
648 ,
649 {"miao", PYTABLE_NONE}
650 ,
651 {"miagn", PYTABLE_NG_GN}
652 ,
653 {"miang", PYTABLE_IAN_IANG}
654 ,
655 {"mian", PYTABLE_NONE}
656 ,
657 {"mi", PYTABLE_NONE}
658 ,
659 {"megn", PYTABLE_NG_GN}
660 ,
661 {"meng", PYTABLE_NONE}
662 ,
663 {"men", PYTABLE_NONE}
664 ,
665 {"mei", PYTABLE_NONE}
666 ,
667 {"me", PYTABLE_NONE}
668 ,
669 {"mao", PYTABLE_NONE}
670 ,
671 {"magn", PYTABLE_NG_GN}
672 ,
673 {"mang", PYTABLE_NONE}
674 ,
675 {"man", PYTABLE_NONE}
676 ,
677 {"mai", PYTABLE_NONE}
678 ,
679 {"ma", PYTABLE_NONE}
680 ,
681 {"m", PYTABLE_NONE}
682 ,
683 {"lve", PYTABLE_NONE}
684 ,
685 {"lv", PYTABLE_NONE}
686 ,
687 {"luo", PYTABLE_NONE}
688 ,
689 {"lun", PYTABLE_NONE}
690 ,
691 {"lue", PYTABLE_NONE}
692 ,
693 {"luagn", PYTABLE_NG_GN}
694 ,
695 {"luang", PYTABLE_UAN_UANG}
696 ,
697 {"luagn", PYTABLE_NG_GN}
698 ,
699 {"luang", PYTABLE_L_N}
700 ,
701 {"luan", PYTABLE_NONE}
702 ,
703 {"lu", PYTABLE_NONE}
704 ,
705 {"lou", PYTABLE_NONE}
706 ,
707 {"logn", PYTABLE_NG_GN}
708 ,
709 {"long", PYTABLE_NONE}
710 ,
711 {"lo", PYTABLE_NONE}
712 ,
713 {"liu", PYTABLE_NONE}
714 ,
715 {"lign", PYTABLE_NG_GN}
716 ,
717 {"ling", PYTABLE_NONE}
718 ,
719 {"lin", PYTABLE_NONE}
720 ,
721 {"lie", PYTABLE_NONE}
722 ,
723 {"liao", PYTABLE_NONE}
724 ,
725 {"liagn", PYTABLE_NG_GN}
726 ,
727 {"liang", PYTABLE_NONE}
728 ,
729 {"lian", PYTABLE_NONE}
730 ,
731 {"lia", PYTABLE_NONE}
732 ,
733 {"li", PYTABLE_NONE}
734 ,
735 {"legn", PYTABLE_NG_GN}
736 ,
737 {"leng", PYTABLE_NONE}
738 ,
739 {"len", PYTABLE_EN_ENG}
740 ,
741 {"lei", PYTABLE_NONE}
742 ,
743 {"le", PYTABLE_NONE}
744 ,
745 {"lao", PYTABLE_NONE}
746 ,
747 {"lagn", PYTABLE_NG_GN}
748 ,
749 {"lang", PYTABLE_NONE}
750 ,
751 {"lan", PYTABLE_NONE}
752 ,
753 {"lai", PYTABLE_NONE}
754 ,
755 {"la", PYTABLE_NONE}
756 ,
757 {"kuo", PYTABLE_NONE}
758 ,
759 {"kun", PYTABLE_NONE}
760 ,
761 {"kui", PYTABLE_NONE}
762 ,
763 {"kuagn", PYTABLE_NG_GN}
764 ,
765 {"kuang", PYTABLE_NONE}
766 ,
767 {"kuan", PYTABLE_NONE}
768 ,
769 {"kuai", PYTABLE_NONE}
770 ,
771 {"kua", PYTABLE_NONE}
772 ,
773 {"ku", PYTABLE_NONE}
774 ,
775 {"kou", PYTABLE_NONE}
776 ,
777 {"kogn", PYTABLE_NG_GN}
778 ,
779 {"kong", PYTABLE_NONE}
780 ,
781 {"kegn", PYTABLE_NG_GN}
782 ,
783 {"keng", PYTABLE_NONE}
784 ,
785 {"ken", PYTABLE_NONE}
786 ,
787 {"kei", PYTABLE_NONE}
788 ,
789 {"ke", PYTABLE_NONE}
790 ,
791 {"kao", PYTABLE_NONE}
792 ,
793 {"kagn", PYTABLE_NG_GN}
794 ,
795 {"kang", PYTABLE_NONE}
796 ,
797 {"kan", PYTABLE_NONE}
798 ,
799 {"kai", PYTABLE_NONE}
800 ,
801 {"ka", PYTABLE_NONE}
802 ,
803 {"jun", PYTABLE_NONE}
804 ,
805 {"jue", PYTABLE_NONE}
806 ,
807 {"juagn", PYTABLE_NG_GN}
808 ,
809 {"juang", PYTABLE_UAN_UANG}
810 ,
811 {"juan", PYTABLE_NONE}
812 ,
813 {"ju", PYTABLE_NONE}
814 ,
815 {"jv", PYTABLE_V_U}
816 ,
817 {"jiu", PYTABLE_NONE}
818 ,
819 {"jiogn", PYTABLE_NG_GN}
820 ,
821 {"jiong", PYTABLE_NONE}
822 ,
823 {"jign", PYTABLE_NG_GN}
824 ,
825 {"jing", PYTABLE_NONE}
826 ,
827 {"jin", PYTABLE_NONE}
828 ,
829 {"jie", PYTABLE_NONE}
830 ,
831 {"jiao", PYTABLE_NONE}
832 ,
833 {"jiagn", PYTABLE_NG_GN}
834 ,
835 {"jiang", PYTABLE_NONE}
836 ,
837 {"jian", PYTABLE_NONE}
838 ,
839 {"jia", PYTABLE_NONE}
840 ,
841 {"ji", PYTABLE_NONE}
842 ,
843 {"huo", PYTABLE_NONE}
844 ,
845 {"hun", PYTABLE_NONE}
846 ,
847 {"hui", PYTABLE_NONE}
848 ,
849 {"huagn", PYTABLE_NG_GN}
850 ,
851 {"huang", PYTABLE_NONE}
852 ,
853 {"huan", PYTABLE_NONE}
854 ,
855 {"huai", PYTABLE_NONE}
856 ,
857 {"hua", PYTABLE_NONE}
858 ,
859 {"hu", PYTABLE_NONE}
860 ,
861 {"hou", PYTABLE_NONE}
862 ,
863 {"hogn", PYTABLE_NG_GN}
864 ,
865 {"hong", PYTABLE_NONE}
866 ,
867 {"hegn", PYTABLE_NG_GN}
868 ,
869 {"heng", PYTABLE_NONE}
870 ,
871 {"hen", PYTABLE_NONE}
872 ,
873 {"hei", PYTABLE_NONE}
874 ,
875 {"he", PYTABLE_NONE}
876 ,
877 {"hao", PYTABLE_NONE}
878 ,
879 {"hagn", PYTABLE_NG_GN}
880 ,
881 {"hang", PYTABLE_NONE}
882 ,
883 {"han", PYTABLE_NONE}
884 ,
885 {"hai", PYTABLE_NONE}
886 ,
887 {"ha", PYTABLE_NONE}
888 ,
889 {"guo", PYTABLE_NONE}
890 ,
891 {"gun", PYTABLE_NONE}
892 ,
893 {"gui", PYTABLE_NONE}
894 ,
895 {"guagn", PYTABLE_NG_GN}
896 ,
897 {"guang", PYTABLE_NONE}
898 ,
899 {"guan", PYTABLE_NONE}
900 ,
901 {"guai", PYTABLE_NONE}
902 ,
903 {"gua", PYTABLE_NONE}
904 ,
905 {"gu", PYTABLE_NONE}
906 ,
907 {"gou", PYTABLE_NONE}
908 ,
909 {"gogn", PYTABLE_NG_GN}
910 ,
911 {"gong", PYTABLE_NONE}
912 ,
913 {"gegn", PYTABLE_NG_GN}
914 ,
915 {"geng", PYTABLE_NONE}
916 ,
917 {"gen", PYTABLE_NONE}
918 ,
919 {"gei", PYTABLE_NONE}
920 ,
921 {"ge", PYTABLE_NONE}
922 ,
923 {"gao", PYTABLE_NONE}
924 ,
925 {"gagn", PYTABLE_NG_GN}
926 ,
927 {"gang", PYTABLE_NONE}
928 ,
929 {"gan", PYTABLE_NONE}
930 ,
931 {"gai", PYTABLE_NONE}
932 ,
933 {"ga", PYTABLE_NONE}
934 ,
935 {"fu", PYTABLE_NONE}
936 ,
937 {"fou", PYTABLE_NONE}
938 ,
939 {"fo", PYTABLE_NONE}
940 ,
941 {"fegn", PYTABLE_NG_GN}
942 ,
943 {"feng", PYTABLE_NONE}
944 ,
945 {"fen", PYTABLE_NONE}
946 ,
947 {"fei", PYTABLE_NONE}
948 ,
949 {"fagn", PYTABLE_NG_GN}
950 ,
951 {"fang", PYTABLE_NONE}
952 ,
953 {"fan", PYTABLE_NONE}
954 ,
955 {"fa", PYTABLE_NONE}
956 ,
957 {"er", PYTABLE_NONE}
958 ,
959 {"egn", PYTABLE_NG_GN}
960 ,
961 {"eng", PYTABLE_EN_ENG}
962 ,
963 {"en", PYTABLE_NONE}
964 ,
965 {"ei", PYTABLE_NONE}
966 ,
967 {"e", PYTABLE_NONE}
968 ,
969 {"duo", PYTABLE_NONE}
970 ,
971 {"dun", PYTABLE_NONE}
972 ,
973 {"dui", PYTABLE_NONE}
974 ,
975 {"duagn", PYTABLE_NG_GN}
976 ,
977 {"duang", PYTABLE_UAN_UANG}
978 ,
979 {"duan", PYTABLE_NONE}
980 ,
981 {"du", PYTABLE_NONE}
982 ,
983 {"dou", PYTABLE_NONE}
984 ,
985 {"dogn", PYTABLE_NG_GN}
986 ,
987 {"dong", PYTABLE_NONE}
988 ,
989 {"diu", PYTABLE_NONE}
990 ,
991 {"dign", PYTABLE_NG_GN}
992 ,
993 {"ding", PYTABLE_NONE}
994 ,
995 {"din", PYTABLE_IN_ING}
996 ,
997 {"die", PYTABLE_NONE}
998 ,
999 {"diao", PYTABLE_NONE}
1000 ,
1001 {"diagn", PYTABLE_NG_GN}
1002 ,
1003 {"diang", PYTABLE_IAN_IANG}
1004 ,
1005 {"dian", PYTABLE_NONE}
1006 ,
1007 {"dia", PYTABLE_NONE}
1008 ,
1009 {"di", PYTABLE_NONE}
1010 ,
1011 {"degn", PYTABLE_NG_GN}
1012 ,
1013 {"deng", PYTABLE_NONE}
1014 ,
1015 {"den", PYTABLE_NONE}
1016 ,
1017 {"dei", PYTABLE_NONE}
1018 ,
1019 {"de", PYTABLE_NONE}
1020 ,
1021 {"dao", PYTABLE_NONE}
1022 ,
1023 {"dagn", PYTABLE_NG_GN}
1024 ,
1025 {"dang", PYTABLE_NONE}
1026 ,
1027 {"dan", PYTABLE_NONE}
1028 ,
1029 {"dai", PYTABLE_NONE}
1030 ,
1031 {"da", PYTABLE_NONE}
1032 ,
1033 {"cuo", PYTABLE_NONE}
1034 ,
1035 {"cun", PYTABLE_NONE}
1036 ,
1037 {"cui", PYTABLE_NONE}
1038 ,
1039 {"cuagn", PYTABLE_NG_GN}
1040 ,
1041 {"cuang", PYTABLE_UAN_UANG}
1042 ,
1043 {"cuagn", PYTABLE_NG_GN}
1044 ,
1045 {"cuang", PYTABLE_C_CH}
1046 ,
1047 {"cuan", PYTABLE_NONE}
1048 ,
1049 {"cu", PYTABLE_NONE}
1050 ,
1051 {"cou", PYTABLE_NONE}
1052 ,
1053 {"cogn", PYTABLE_NG_GN}
1054 ,
1055 {"cong", PYTABLE_NONE}
1056 ,
1057 {"ci", PYTABLE_NONE}
1058 ,
1059 {"chuo", PYTABLE_NONE}
1060 ,
1061 {"chun", PYTABLE_NONE}
1062 ,
1063 {"chui", PYTABLE_NONE}
1064 ,
1065 {"chuagn", PYTABLE_NG_GN}
1066 ,
1067 {"chuang", PYTABLE_NONE}
1068 ,
1069 {"chuan", PYTABLE_NONE}
1070 ,
1071 {"chuai", PYTABLE_NONE}
1072 ,
1073 {"chu", PYTABLE_NONE}
1074 ,
1075 {"chou", PYTABLE_NONE}
1076 ,
1077 {"chogn", PYTABLE_NG_GN}
1078 ,
1079 {"chong", PYTABLE_NONE}
1080 ,
1081 {"chi", PYTABLE_NONE}
1082 ,
1083 {"chegn", PYTABLE_NG_GN}
1084 ,
1085 {"cheng", PYTABLE_NONE}
1086 ,
1087 {"chen", PYTABLE_NONE}
1088 ,
1089 {"che", PYTABLE_NONE}
1090 ,
1091 {"chao", PYTABLE_NONE}
1092 ,
1093 {"chagn", PYTABLE_NG_GN}
1094 ,
1095 {"chang", PYTABLE_NONE}
1096 ,
1097 {"chan", PYTABLE_NONE}
1098 ,
1099 {"chai", PYTABLE_NONE}
1100 ,
1101 {"cha", PYTABLE_NONE}
1102 ,
1103 {"cegn", PYTABLE_NG_GN}
1104 ,
1105 {"ceng", PYTABLE_NONE}
1106 ,
1107 {"cen", PYTABLE_NONE}
1108 ,
1109 {"ce", PYTABLE_NONE}
1110 ,
1111 {"cao", PYTABLE_NONE}
1112 ,
1113 {"cagn", PYTABLE_NG_GN}
1114 ,
1115 {"cang", PYTABLE_NONE}
1116 ,
1117 {"can", PYTABLE_NONE}
1118 ,
1119 {"cai", PYTABLE_NONE}
1120 ,
1121 {"ca", PYTABLE_NONE}
1122 ,
1123 {"bu", PYTABLE_NONE}
1124 ,
1125 {"bo", PYTABLE_NONE}
1126 ,
1127 {"bign", PYTABLE_NG_GN}
1128 ,
1129 {"bing", PYTABLE_NONE}
1130 ,
1131 {"bin", PYTABLE_NONE}
1132 ,
1133 {"bie", PYTABLE_NONE}
1134 ,
1135 {"biao", PYTABLE_NONE}
1136 ,
1137 {"biagn", PYTABLE_NG_GN}
1138 ,
1139 {"biang", PYTABLE_IAN_IANG}
1140 ,
1141 {"bian", PYTABLE_NONE}
1142 ,
1143 {"bi", PYTABLE_NONE}
1144 ,
1145 {"begn", PYTABLE_NG_GN}
1146 ,
1147 {"beng", PYTABLE_NONE}
1148 ,
1149 {"ben", PYTABLE_NONE}
1150 ,
1151 {"bei", PYTABLE_NONE}
1152 ,
1153 {"bao", PYTABLE_NONE}
1154 ,
1155 {"bagn", PYTABLE_NG_GN}
1156 ,
1157 {"bang", PYTABLE_NONE}
1158 ,
1159 {"ban", PYTABLE_NONE}
1160 ,
1161 {"bai", PYTABLE_NONE}
1162 ,
1163 {"ba", PYTABLE_NONE}
1164 ,
1165 {"ao", PYTABLE_NONE}
1166 ,
1167 {"agn", PYTABLE_NG_GN}
1168 ,
1169 {"ang", PYTABLE_NONE}
1170 ,
1171 {"an", PYTABLE_NONE}
1172 ,
1173 {"ai", PYTABLE_NONE}
1174 ,
1175 {"a", PYTABLE_NONE}
1176 ,
1177 {"\0", PYTABLE_NONE}
1178 };
1179
GetMHIndex_C(MHPY * MHPY_C,char map)1180 int GetMHIndex_C(MHPY* MHPY_C, char map)
1181 {
1182 int i;
1183
1184 for (i = 0; MHPY_C[i].strMap[0]; i++) {
1185 if (map == MHPY_C[i].strMap[0] || map == MHPY_C[i].strMap[1]) {
1186 if (MHPY_C[i].bMode)
1187 return i;
1188 else
1189 return -1;
1190 }
1191 }
1192
1193 return -1;
1194 }
1195
GetMHIndex_C2(MHPY * MHPY_C,char map1,char map2)1196 int GetMHIndex_C2(MHPY* MHPY_C, char map1, char map2)
1197 {
1198 int i;
1199
1200 for (i = 0; MHPY_C[i].strMap[0]; i++) {
1201 if ((map1 == MHPY_C[i].strMap[0] || map1 == MHPY_C[i].strMap[1])
1202 && (map2 == MHPY_C[i].strMap[0] || map2 == MHPY_C[i].strMap[1])) {
1203 if (MHPY_C[i].bMode)
1204 return i;
1205 else
1206 return -1;
1207 }
1208 }
1209
1210 return -1;
1211 }
1212
GetMHIndex_S2(MHPY * MHPY_S,char map1,char map2,boolean bMode)1213 int GetMHIndex_S2(MHPY* MHPY_S, char map1, char map2, boolean bMode)
1214 {
1215 int i;
1216
1217 for (i = 0; MHPY_S[i].strMap[0]; i++) {
1218 if ((map1 == MHPY_S[i].strMap[0] || map1 == MHPY_S[i].strMap[1])
1219 && (map2 == MHPY_S[i].strMap[0] || map2 == MHPY_S[i].strMap[1])) {
1220 if (MHPY_S[i].bMode || bMode)
1221 return i;
1222 else
1223 return -1;
1224 }
1225 }
1226
1227 return -1;
1228
1229 }
1230
IsZ_C_S(char map)1231 boolean IsZ_C_S(char map)
1232 {
1233 if (map == 'c' || map == 'H' || map == 'B')
1234 return true;
1235
1236 return false;
1237 }
1238
IsJ_Q_X_Y(char map)1239 boolean IsJ_Q_X_Y(char map)
1240 {
1241 if (map == 'S' || map == 'J' || map == 'X' || map == 'C')
1242 return true;
1243 return false;
1244 }
1245
InitMHPY(MHPY ** pMHPY,const MHPY_TEMPLATE * MHPYtemplate)1246 void InitMHPY(MHPY** pMHPY, const MHPY_TEMPLATE* MHPYtemplate)
1247 {
1248 int iBaseCount = 0;
1249
1250 while (MHPYtemplate[iBaseCount].strMap[0] != '\0')
1251 iBaseCount++;
1252
1253 iBaseCount++;
1254
1255 *pMHPY = fcitx_utils_malloc0(sizeof(MHPY) * iBaseCount);
1256
1257 MHPY *mhpy = *pMHPY;
1258
1259 iBaseCount = 0;
1260
1261 while (MHPYtemplate[iBaseCount].strMap[0] != '\0') {
1262 strcpy(mhpy[iBaseCount].strMap, MHPYtemplate[iBaseCount].strMap);
1263 mhpy[iBaseCount].bMode = false;
1264 iBaseCount++;
1265 }
1266 }
1267
InitPYTable(FcitxPinyinConfig * pyconfig)1268 void InitPYTable(FcitxPinyinConfig* pyconfig)
1269 {
1270 int iBaseCount = 0;
1271
1272 while (PYTable_template[iBaseCount].strPY[0] != '\0')
1273 iBaseCount++;
1274
1275 iBaseCount++;
1276
1277 pyconfig->PYTable = fcitx_utils_malloc0(sizeof(PYTABLE) * iBaseCount);
1278
1279 iBaseCount = 0;
1280
1281 while (PYTable_template[iBaseCount].strPY[0] != '\0') {
1282 strcpy(pyconfig->PYTable[iBaseCount].strPY,
1283 PYTable_template[iBaseCount].strPY);
1284
1285 switch (PYTable_template[iBaseCount].control) {
1286
1287 case PYTABLE_NONE:
1288 pyconfig->PYTable[iBaseCount].pMH = NULL;
1289 break;
1290
1291 case PYTABLE_NG_GN:
1292 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->bMisstypeNGGN;
1293 break;
1294
1295 case PYTABLE_V_U:
1296 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[6].bMode;
1297 break;
1298
1299 case PYTABLE_AN_ANG: // 0
1300 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[0].bMode;
1301 break;
1302
1303 case PYTABLE_EN_ENG: // 1
1304 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[1].bMode;
1305 break;
1306
1307 case PYTABLE_IAN_IANG: // 2
1308 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[2].bMode;
1309 break;
1310
1311 case PYTABLE_IN_ING: // 3
1312 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[3].bMode;
1313 break;
1314
1315 case PYTABLE_U_OU: // 4
1316 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[4].bMode;
1317 break;
1318
1319 case PYTABLE_UAN_UANG: // 5
1320 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_C[5].bMode;
1321 break;
1322
1323 case PYTABLE_C_CH: // 0
1324 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[0].bMode;
1325 break;
1326
1327 case PYTABLE_F_H: // 1
1328 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[1].bMode;
1329 break;
1330
1331 case PYTABLE_L_N: // 2
1332 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[2].bMode;
1333 break;
1334
1335 case PYTABLE_S_SH: // 3
1336 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[3].bMode;
1337 break;
1338
1339 case PYTABLE_Z_ZH: // 4
1340 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[4].bMode;
1341 break;
1342
1343 case PYTABLE_AN_ANG_S: //5
1344 pyconfig->PYTable[iBaseCount].pMH = &pyconfig->MHPY_S[5].bMode;
1345 break;
1346 }
1347
1348 iBaseCount++;
1349 }
1350 }
1351
1352
1353 // kate: indent-mode cstyle; space-indent on; indent-width 0;
1354