comparison Wnn/jserver/sisheng.c @ 0:bbc77ca4def5

initial import
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 13 Dec 2007 04:30:14 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bbc77ca4def5
1 /*
2 * $Id: sisheng.c,v 1.4 2002/07/14 04:26:57 hiroo Exp $
3 */
4
5 /*
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
7 * This file is part of FreeWnn.
8 *
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
10 * 1987, 1988, 1989, 1990, 1991, 1992
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
13 * Copyright FreeWnn Project 1999, 2000, 2002
14 *
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */
31
32 /** cWnn Version 1.1 **/
33
34 #ifdef HAVE_CONFIG_H
35 # include <config.h>
36 #endif
37
38 #ifdef CHINESE
39
40 #include <stdio.h>
41 #if STDC_HEADERS
42 # include <string.h>
43 #else
44 # if HAVE_STRINGS_H
45 # include <strings.h>
46 # endif
47 #endif /* STDC_HEADERS */
48 #include "commonhd.h"
49 #include "cplib.h"
50 #include "de_header.h"
51
52 #define isfuyuanyin(c) ((c=='m')||(c=='n')||(c=='g'))
53 #define isyuanyin(c) \
54 ((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')||(c=='v'))
55
56 /* yincod_flt_sisheng(): filter sisheng of Yincode strings */
57
58 static int
59 yincod_flt_sisheng (yincod, si, siyincod)
60 w_char *yincod; /* Yincode without sisheng */
61 char *si; /* sisheng string */
62 w_char *siyincod; /* Yincode with sisheng */
63 {
64 register int pan_count = 0;
65 for (; *siyincod; siyincod++)
66 {
67 if (_cwnn_isyincod_d (*siyincod))
68 {
69 *si++ = (char) (_cwnn_sisheng (*siyincod) + 0x30);
70 *yincod++ = _cwnn_yincod_0 (*siyincod);
71 }
72 else
73 {
74 *si++ = '5';
75 *yincod++ = *siyincod;
76 }
77 if (pan_count++ == 5)
78 *(si - 1) = 0;
79 }
80 *yincod = 0;
81 *si = 0;
82 return (strlen (si));
83 }
84
85 int
86 get_sisheng (yomi, si, yomi_tmp)
87 w_char *yomi;
88 w_char *yomi_tmp;
89 char *si;
90 {
91 int length;
92
93 length = yincod_flt_sisheng (yomi_tmp, si, yomi);
94 return (length);
95 }
96
97 w_char *
98 biki_sisheng (yomi, si, yomi_tmp)
99 w_char *yomi;
100 w_char *yomi_tmp;
101 char *si;
102 {
103 int length;
104
105 length = yincod_flt_sisheng (yomi_tmp, si, yomi);
106 return (yomi_tmp);
107 }
108
109 unsigned int
110 diff_sisheng (si1, si2) /* PAN deleted by pan shilei */
111 int si1;
112 int si2;
113 {
114 register int length;
115 register unsigned int reslt;
116 char s1[7];
117 char s2[7];
118
119 sprintf (s1, "%d", si1);
120 sprintf (s2, "%d", si2);
121 length = strlen (s1) - 1;
122 for (reslt = 1; length >= 0; length--)
123 if (s1[length] == s2[length])
124 reslt = reslt * (10 - length);
125 return (reslt);
126 }
127
128 #endif /* CHINESE */