1 /***************************************************************************
2  *  Copyright 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002               *
3  *    David R. Hill, Leonard Manzara, Craig Schock                         *
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 3 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, see <http://www.gnu.org/licenses/>.  *
17  ***************************************************************************/
18 // 2014-09
19 // This file was copied from Gnuspeech and modified by Marcelo Y. Matuda.
20 
21 #include "en/letter_to_sound/medial_silent_e.h"
22 
23 #include "en/letter_to_sound/member.h"
24 #include "en/letter_to_sound/insert_mark.h"
25 
26 
27 
28 namespace GS {
29 namespace En {
30 
31 /******************************************************************************
32 *
33 *	function:	medial_silent_e
34 *
35 *	purpose:
36 *
37 *       arguments:      in, eow
38 *
39 *	internal
40 *	functions:	member, insert_mark
41 *
42 *	library
43 *	functions:	none
44 *
45 ******************************************************************************/
46 void
medial_silent_e(char * in,char ** eow)47 medial_silent_e(char *in, char **eow)
48 {
49     char               *end = *eow;
50     register char      *position;
51     register int        index;
52 
53     for (position = in + 2; position < end - 5; position++) {
54 	if (!member(position[0], "bcdfgmnprst"))
55 	    continue;		/* c */
56 	if (!member(position[1], "bdfgkpt"))
57 	    continue;		/* k */
58 	if ((position[2] != 'l') || (position[3] != 'e'))
59 	    continue;		/* le */
60 	if (member(position[4] | 040, "aeiouy"))
61 	    continue;		/* s */
62 	if (position[4] == '|')
63 	    continue;
64 
65 	index = 5;
66 	while (!member(position[index] | 040, "aeiouy|")) {	/* he */
67 	    index++;
68 	    if (&position[index] >= end) {
69 		index = 0;
70 		break;
71 	    }
72 	}
73 
74 	if (!index)
75 	    continue;
76 	if (position[index] == '|')
77 	    continue;
78 	if ((position[index] == 'e') && (position[index + 1] == '|'))
79 	    continue;
80 	insert_mark(&end, &position[3]);
81 	break;
82     }
83 
84     for (position = in; position < end - 5; position++) {
85 	if ((member(position[0], "aeiou#")))
86 	    continue;
87 	if (!member(position[1], "aiouy"))
88 	    continue;
89 	if (member(position[2] | 040, "aehiouwxy"))
90 	    continue;
91 	if (position[3] != 'e')
92 	    continue;
93 	if (member(position[4] | 040, "aeiouynr"))
94 	    continue;
95 
96 	index = 5;
97 	if ((position[index] == '|') ||
98 	    ((position[index] == 'e') && (position[++index] == '|')))
99 	    continue;
100 	index++;
101 	if (!member(position[index] | 040, "aeiouy"))
102 	    continue;
103 	insert_mark(&end, &position[3]);
104 	position[1] &= 0xdf;
105 	break;
106     }
107 
108     for (position = in + 1; position < end - 5; position++) {
109 	if (position[0] != 'o')
110 	    continue;
111 	if (!member(position[1], "aiouyU"))
112 	    continue;
113 	if (member(position[2] | 040, "aehiouwxy"))
114 	    continue;
115 	if (position[3] != 'e')
116 	    continue;
117 	if (member(position[4] | 040, "aeiouynr"))
118 	    continue;
119 	index = 5;
120 	if ((position[index] == '|') ||
121 	    ((position[index] == 'e') && (position[++index] == '|')))
122 	    continue;
123 	index++;
124 	if (!member(position[index] | 040, "aeiouy"))
125 	    continue;
126 	insert_mark(&end, &position[3]);
127 	break;
128     }
129     *eow = end;
130 }
131 
132 } /* namespace En */
133 } /* namespace GS */
134