eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tr_languages.cpp 35KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2007 by Jonathan Duddington *
  3. * email: [email protected] *
  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: *
  17. * <http://www.gnu.org/licenses/>. *
  18. ***************************************************************************/
  19. #include "StdAfx.h"
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include <wctype.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <locale.h>
  26. #include <wctype.h>
  27. #include "speak_lib.h"
  28. #include "speech.h"
  29. #include "phoneme.h"
  30. #include "synthesize.h"
  31. #include "translate.h"
  32. #include "tr_languages.h"
  33. #define L_qa 0x716100
  34. #define L_grc 0x677263 // grc Ancient Greek
  35. #define L_zhy 0x7a6879 // zhy
  36. #define OFFSET_GREEK 0x380
  37. #define OFFSET_CYRILLIC 0x420
  38. #define OFFSET_DEVANAGARI 0x900
  39. #define OFFSET_TAMIL 0xb80
  40. static const unsigned int replace_cyrillic_latin[] =
  41. {0x430,'a',
  42. 0x431,'b',
  43. 0x446,'c',
  44. 0x45b,0x107,
  45. 0x447,0x10d,
  46. 0x45f,'d'+(0x17e<<16),
  47. 0x455,'d'+('z'<<16),
  48. 0x434,'d',
  49. 0x452,0x111,
  50. 0x435,'e',
  51. 0x444,'f',
  52. 0x433,'g',
  53. 0x445,'h',
  54. 0x438,'i',
  55. 0x458,'j',
  56. 0x43a,'k',
  57. 0x459,'l'+('j'<<16),
  58. 0x43b,'l',
  59. 0x43c,'m',
  60. 0x45a,'n'+('j'<<16),
  61. 0x43d,'n',
  62. 0x43e,'o',
  63. 0x43f,'p',
  64. 0x440,'r',
  65. 0x441,'s',
  66. 0x448,0x161,
  67. 0x442,'t',
  68. 0x443,'u',
  69. 0x432,'v',
  70. 0x437,'z',
  71. 0x436,0x17e,
  72. 0x453,0x111,
  73. 0x45c,0x107,
  74. 0}; // ѓ ѕ ќ
  75. void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
  76. {//==================================================================================
  77. if(lengths != NULL)
  78. memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths));
  79. if(amps != NULL)
  80. memcpy(tr->stress_amps,amps,sizeof(tr->stress_amps));
  81. }
  82. Translator *SelectTranslator(const char *name)
  83. {//===========================================
  84. int name2 = 0;
  85. Translator *tr;
  86. // convert name string into a word of up to 4 characters, for the switch()
  87. while(*name != 0)
  88. name2 = (name2 << 8) + *name++;
  89. switch(name2)
  90. {
  91. case L('a','f'):
  92. tr = new Translator_Afrikaans();
  93. break;
  94. case L('c','y'): // Welsh
  95. {
  96. static const short stress_lengths_cy[8] = {170,230, 190,190, 0, 0, 250,270};
  97. static const unsigned char stress_amps_cy[8] = {16,15, 18,18, 0,0, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  98. tr = new Translator();
  99. SetupTranslator(tr,stress_lengths_cy,stress_amps_cy);
  100. tr->charset_a0 = charsets[14]; // ISO-8859-14
  101. // tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  102. tr->langopts.stress_rule = 2;
  103. // 'diminished' is an unstressed final syllable
  104. tr->langopts.stress_flags = 0x6 | 0x10;
  105. tr->langopts.unstressed_wd1 = 0;
  106. tr->langopts.unstressed_wd2 = 2;
  107. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  108. tr->langopts.numbers = 0x401;
  109. SetLetterVowel(tr,'w'); // add letter to vowels and remove from consonants
  110. SetLetterVowel(tr,'y');
  111. }
  112. break;
  113. case L('d','e'):
  114. {
  115. static const short stress_lengths_de[8] = {150,130, 190,190, 0, 0, 260,275};
  116. tr = new Translator();
  117. tr->langopts.stress_rule = 0;
  118. tr->langopts.word_gap = 0x8; // don't use linking phonemes
  119. tr->langopts.vowel_pause = 0x30;
  120. tr->langopts.param[LOPT_PREFIXES] = 1;
  121. memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
  122. tr->langopts.numbers = 0x11c19 + NUM_ROMAN;
  123. SetLetterVowel(tr,'y');
  124. }
  125. break;
  126. case L('e','n'):
  127. tr = new Translator_English();
  128. break;
  129. case L('e','l'): // Greek
  130. case L_grc: // Ancient Greek
  131. {
  132. static const short stress_lengths_el[8] = {155, 180, 210, 210, 0, 0, 270, 300};
  133. static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  134. // character codes offset by 0x380
  135. static const char el_vowels[] = {0x10,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x35,0x37,0x39,0x3f,0x45,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0};
  136. static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι υ έ ή ί ύ
  137. static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ
  138. static const char el_consonants[]={0x32,0x33,0x34,0x36,0x38,0x3a,0x3b,0x3c,0x3d,0x3e,0x40,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0};
  139. static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ
  140. tr = new Translator();
  141. SetupTranslator(tr,stress_lengths_el,stress_amps_el);
  142. tr->charset_a0 = charsets[7]; // ISO-8859-7
  143. tr->char_plus_apostrophe = el_char_apostrophe;
  144. tr->letter_bits_offset = OFFSET_GREEK;
  145. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  146. SetLetterBits(tr,LETTERGP_A,el_vowels);
  147. SetLetterBits(tr,LETTERGP_B,el_voiceless);
  148. SetLetterBits(tr,LETTERGP_C,el_consonants);
  149. SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
  150. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  151. tr->langopts.stress_rule = 2;
  152. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  153. tr->langopts.unstressed_wd1 = 0;
  154. tr->langopts.unstressed_wd2 = 2;
  155. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  156. tr->langopts.numbers = 0xb09;
  157. tr->langopts.numbers2 = 0x2; // variant form of numbers before thousands
  158. if(name2 == L_grc)
  159. {
  160. // ancient greek
  161. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1;
  162. }
  163. }
  164. break;
  165. case L('e','o'):
  166. {
  167. static const short stress_lengths_eo[8] = {145, 180, 200, 190, 0, 0, 300, 320};
  168. static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,24, 24,22 };
  169. static const wchar_t eo_char_apostrophe[2] = {'l',0};
  170. tr = new Translator();
  171. SetupTranslator(tr,stress_lengths_eo,stress_amps_eo);
  172. tr->charset_a0 = charsets[3]; // ISO-8859-3
  173. tr->char_plus_apostrophe = eo_char_apostrophe;
  174. tr->langopts.vowel_pause = 1;
  175. tr->langopts.stress_rule = 2;
  176. tr->langopts.stress_flags = 0x6 | 0x10;
  177. // tr->langopts.stress_flags = 0x1; // don't give full stress to monosyllables
  178. tr->langopts.unstressed_wd1 = 1;
  179. tr->langopts.unstressed_wd2 = 2;
  180. tr->langopts.numbers = 0x1c09 + NUM_ROMAN;
  181. }
  182. break;
  183. case L('e','s'): // Spanish
  184. {
  185. static const short stress_lengths_es[8] = {170, 200, 180, 180, 0, 0, 220, 250};
  186. static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,22, 22,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  187. tr = new Translator();
  188. SetupTranslator(tr,stress_lengths_es,stress_amps_es);
  189. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  190. tr->langopts.stress_rule = 2;
  191. // stress last syllable if it doesn't end in vowel or "s" or "n"
  192. // 'diminished' is an unstressed final syllable
  193. tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
  194. tr->langopts.unstressed_wd1 = 0;
  195. tr->langopts.unstressed_wd2 = 2;
  196. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  197. tr->langopts.numbers = 0x529 + NUM_ROMAN;
  198. }
  199. break;
  200. case L('f','i'): // Finnish
  201. {
  202. static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 };
  203. static const short stress_lengths_fi[8] = {150,170, 200,200, 0,0, 210,250};
  204. tr = new Translator();
  205. SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
  206. tr->langopts.stress_rule = 0;
  207. tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
  208. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  209. tr->langopts.long_stop = 140;
  210. tr->langopts.numbers = 0x1009;
  211. SetLetterVowel(tr,'y');
  212. tr->langopts.max_initial_consonants = 2;
  213. tr->langopts.spelling_stress = 1;
  214. tr->punct_to_tone[0][1] = 0; // don't raise pitch for comma
  215. // tr->punct_to_tone[0][2] = 0; // don't raise pitch for question
  216. }
  217. break;
  218. case L('f','r'): // french
  219. {
  220. static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 235};
  221. static const unsigned char stress_amps_fr[8] = {16,14, 20,20, 20,24, 24,22 };
  222. tr = new Translator();
  223. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  224. tr->langopts.stress_rule = 3; // stress on final syllable
  225. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  226. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
  227. tr->langopts.numbers = 0x1509;
  228. SetLetterVowel(tr,'y');
  229. }
  230. break;
  231. case L('h','i'):
  232. {
  233. static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f};
  234. static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
  235. static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,24, 24,22 };
  236. tr = new Translator();
  237. SetupTranslator(tr,stress_lengths_hi,stress_amps_hi);
  238. tr->charset_a0 = charsets[19]; // ISCII
  239. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  240. tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
  241. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  242. tr->langopts.numbers = 0x811;
  243. tr->langopts.numbers2 = 0x100;
  244. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  245. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  246. SetLetterBitsRange(tr,LETTERGP_A,0x06,0x14); // vowel letters
  247. SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs + virama
  248. SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
  249. SetLetterBits(tr,LETTERGP_C,dev_consonants2); // additional consonants
  250. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  251. }
  252. break;
  253. case L('h','r'): // Croatian
  254. case L('b','s'): // Bosnian
  255. case L('s','r'): // Serbian
  256. {
  257. static const unsigned char stress_amps_hr[8] = {16,16, 20,20, 20,24, 24,22 };
  258. static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
  259. static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
  260. tr = new Translator();
  261. if(name2 == L('s','r'))
  262. SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
  263. else
  264. SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
  265. tr->charset_a0 = charsets[2]; // ISO-8859-2
  266. tr->langopts.stress_rule = 0;
  267. tr->langopts.stress_flags = 0x10;
  268. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  269. tr->langopts.max_initial_consonants = 5;
  270. tr->langopts.spelling_stress = 1;
  271. tr->langopts.numbers = 0x1c0d + 0x4000 + NUM_ROMAN_UC;
  272. tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
  273. tr->langopts.replace_chars = replace_cyrillic_latin;
  274. SetLetterVowel(tr,'y');
  275. SetLetterVowel(tr,'r');
  276. }
  277. break;
  278. case L('h','u'): // Hungarian
  279. {
  280. static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,24, 24,22 };
  281. static const short stress_lengths_hu[8] = {185,195, 195,190, 0,0, 210,220};
  282. tr = new Translator();
  283. SetupTranslator(tr,stress_lengths_hu,stress_amps_hu);
  284. tr->charset_a0 = charsets[2]; // ISO-8859-2
  285. tr->langopts.vowel_pause = 0x20;
  286. tr->langopts.stress_rule = 0;
  287. tr->langopts.stress_flags = 0x8036;
  288. tr->langopts.unstressed_wd1 = 2;
  289. // tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x4; // don't propagate over word boundaries
  290. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  291. tr->langopts.param[LOPT_COMBINE_WORDS] = 99; // combine some prepositions with the following word
  292. tr->langopts.numbers = 0x1809 + NUM_ROMAN;
  293. SetLetterVowel(tr,'y');
  294. tr->langopts.spelling_stress = 1;
  295. SetLengthMods(tr,3); // all equal
  296. }
  297. break;
  298. case L('i','s'): // Icelandic
  299. {
  300. static const unsigned char stress_amps_is[] = {16,16, 20,20, 20,24, 24,22 };
  301. static const short stress_lengths_is[8] = {180,160, 200,200, 0,0, 240,250};
  302. static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's'
  303. tr = new Translator();
  304. SetupTranslator(tr,stress_lengths_is,stress_amps_is);
  305. tr->langopts.stress_rule = 0;
  306. tr->langopts.stress_flags = 0x10;
  307. tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
  308. tr->langopts.param[LOPT_REDUCE] = 2;
  309. ResetLetterBits(tr,0x18);
  310. SetLetterBits(tr,4,"kpst"); // Letter group F
  311. SetLetterBits(tr,3,"jvr"); // Letter group H
  312. tr->letter_groups[1] = is_lettergroup_B;
  313. SetLetterVowel(tr,'y');
  314. tr->langopts.numbers = 0xe9;
  315. tr->langopts.numbers2 = 0x2;
  316. }
  317. break;
  318. case L('i','t'): // Italian
  319. {
  320. static const short stress_lengths_it[8] = {150, 140, 180, 180, 0, 0, 270, 320};
  321. static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,24, 24,22 };
  322. tr = new Translator();
  323. SetupTranslator(tr,stress_lengths_it,stress_amps_it);
  324. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  325. tr->langopts.stress_rule = 2;
  326. tr->langopts.vowel_pause = 1;
  327. tr->langopts.unstressed_wd1 = 2;
  328. tr->langopts.unstressed_wd2 = 2;
  329. tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
  330. tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
  331. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  332. tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
  333. tr->langopts.numbers = 0x2709 + 0x800 + NUM_ROMAN;
  334. }
  335. break;
  336. case L('l','a'): //Latin
  337. {
  338. tr = new Translator();
  339. tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
  340. tr->langopts.stress_rule = 2;
  341. tr->langopts.stress_flags = 0x20;
  342. tr->langopts.unstressed_wd1 = 0;
  343. tr->langopts.unstressed_wd2 = 2;
  344. tr->langopts.param[LOPT_DIERESES] = 1;
  345. tr->langopts.numbers = 0x1 + NUM_ROMAN;
  346. tr->langopts.max_roman = 5000;
  347. }
  348. break;
  349. case L('m','k'): // Macedonian
  350. {
  351. static wchar_t vowels_cyrillic[] = {0x440, // also include 'р' [R]
  352. 0x430,0x435,0x438,0x439,0x43e,0x443,0x44b,0x44d,0x44e,0x44f,0x450,0x451,0x456,0x457,0x45d,0x45e,0};
  353. static const unsigned char stress_amps_mk[8] = {16,16, 20,20, 20,24, 24,22 };
  354. static const short stress_lengths_mk[8] = {180,160, 200,200, 0,0, 220,230};
  355. tr = new Translator();
  356. SetupTranslator(tr,stress_lengths_mk,stress_amps_mk);
  357. tr->charset_a0 = charsets[5]; // ISO-8859-5
  358. tr->letter_groups[0] = vowels_cyrillic;
  359. tr->langopts.stress_rule = 4; // antipenultimate
  360. tr->langopts.numbers = 0x0c29 + 0x4000;
  361. tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
  362. }
  363. break;
  364. case L('n','l'): // Dutch
  365. {
  366. static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280};
  367. tr = new Translator();
  368. tr->langopts.stress_rule = 0;
  369. tr->langopts.vowel_pause = 1;
  370. tr->langopts.param[LOPT_DIERESES] = 1;
  371. tr->langopts.param[LOPT_PREFIXES] = 1;
  372. SetLetterVowel(tr,'y');
  373. tr->langopts.numbers = 0x11419;
  374. memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
  375. }
  376. break;
  377. case L('n','o'): // Norwegian
  378. {
  379. static const unsigned char stress_amps_no[] = {16,16, 20,20, 20,24, 24,22 };
  380. static const short stress_lengths_no[8] = {160,140, 200,190, 0,0, 220,240};
  381. tr = new Translator();
  382. SetupTranslator(tr,stress_lengths_no,stress_amps_no);
  383. tr->langopts.stress_rule = 0;
  384. SetLetterVowel(tr,'y');
  385. tr->langopts.numbers = 0x11049;
  386. }
  387. break;
  388. case L('p','l'): // Polish
  389. {
  390. static const short stress_lengths_pl[8] = {160, 180, 175, 175, 0, 0, 260, 290};
  391. static const unsigned char stress_amps_pl[8] = {17,14, 19,19, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  392. tr = new Translator();
  393. SetupTranslator(tr,stress_lengths_pl,stress_amps_pl);
  394. tr->charset_a0 = charsets[2]; // ISO-8859-2
  395. tr->langopts.stress_rule = 2;
  396. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  397. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
  398. tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
  399. tr->langopts.numbers=0x1809 + 0x4000;
  400. tr->langopts.numbers2=0x40;
  401. tr->langopts.param[LOPT_COMBINE_WORDS] = 2 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable words (marked with $alt)
  402. SetLetterVowel(tr,'y');
  403. }
  404. break;
  405. case L('p','t'): // Portuguese
  406. {
  407. static const short stress_lengths_pt[8] = {180, 125, 210, 210, 0, 0, 270, 295};
  408. static const unsigned char stress_amps_pt[8] = {16,13, 19,19, 20,24, 24,22 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  409. tr = new Translator();
  410. SetupTranslator(tr,stress_lengths_pt,stress_amps_pt);
  411. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  412. // tr->langopts.vowel_pause = 1;
  413. tr->langopts.stress_rule = 3; // stress on final syllable
  414. tr->langopts.stress_flags = 0x6 | 0x10 | 0x20000;
  415. tr->langopts.numbers = 0xa69 + 0x2000 + NUM_ROMAN;
  416. tr->punct_to_tone[0][3] = 2; // use exclamation intonation
  417. SetLetterVowel(tr,'y');
  418. }
  419. break;
  420. case L('r','o'): // Romanian
  421. {
  422. static const short stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260};
  423. static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,22 };
  424. tr = new Translator();
  425. SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
  426. tr->langopts.stress_rule = 2;
  427. tr->langopts.stress_flags = 0x100 + 0x6;
  428. tr->charset_a0 = charsets[2]; // ISO-8859-2
  429. tr->langopts.numbers = 0x1829+0x6000 + NUM_ROMAN;
  430. tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
  431. }
  432. break;
  433. case L('r','u'): // Russian
  434. tr = new Translator_Russian();
  435. break;
  436. case L('s','k'): // Slovak
  437. case L('c','s'): // Czech
  438. {
  439. static const unsigned char stress_amps_sk[8] = {16,16, 20,20, 20,24, 24,22 };
  440. static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
  441. static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
  442. tr = new Translator();
  443. SetupTranslator(tr,stress_lengths_sk,stress_amps_sk);
  444. tr->charset_a0 = charsets[2]; // ISO-8859-2
  445. tr->langopts.stress_rule = 0;
  446. tr->langopts.stress_flags = 0x16;
  447. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  448. tr->langopts.max_initial_consonants = 5;
  449. tr->langopts.spelling_stress = 1;
  450. tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
  451. tr->langopts.numbers = 0x1c01 + 0x4000;
  452. tr->langopts.numbers2 = 0x40;
  453. tr->langopts.thousands_sep = 0; //no thousands separator
  454. tr->langopts.decimal_sep = ',';
  455. if(name2 == L('c','s'))
  456. {
  457. tr->langopts.numbers2 = 0x8; // variant numbers before milliards
  458. }
  459. SetLetterVowel(tr,'y');
  460. SetLetterVowel(tr,'r');
  461. ResetLetterBits(tr,0x2);
  462. SetLetterBits(tr,5,sk_voiced);
  463. }
  464. break;
  465. case L('s','v'): // Swedish
  466. {
  467. static const unsigned char stress_amps_sv[] = {16,16, 20,20, 20,24, 24,22 };
  468. static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280};
  469. tr = new Translator();
  470. SetupTranslator(tr,stress_lengths_sv,stress_amps_sv);
  471. tr->langopts.stress_rule = 0;
  472. SetLetterVowel(tr,'y');
  473. // SetLetterBits(tr,6,"eiyäö"); // soft vowels NOTE accented letters don't work in SetLetterBits
  474. tr->langopts.numbers = 0x1109;
  475. }
  476. break;
  477. case L('s','w'): // Swahili
  478. {
  479. static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340};
  480. static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,24, 24,22 };
  481. tr = new Translator();
  482. SetupTranslator(tr,stress_lengths_sw,stress_amps_sw);
  483. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  484. tr->langopts.vowel_pause = 1;
  485. tr->langopts.stress_rule = 2;
  486. tr->langopts.stress_flags = 0x6 | 0x10;
  487. tr->langopts.numbers = 0x8e1;
  488. tr->langopts.numbers2 = 0x100;
  489. }
  490. break;
  491. case L('t','a'):
  492. {
  493. static const short stress_lengths_ta[8] = {190, 190, 210, 210, 0, 0, 230, 250};
  494. static const unsigned char stress_amps_ta[8] = {17,14, 20,19, 20,24, 24,22 };
  495. tr = new Translator();
  496. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  497. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  498. tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
  499. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  500. tr->langopts.numbers = 0x811;
  501. tr->langopts.numbers2 = 0x100;
  502. tr->letter_bits_offset = OFFSET_TAMIL;
  503. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  504. SetLetterBitsRange(tr,LETTERGP_A,0x05,0x14); // vowel letters
  505. SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4c); // vowel signs
  506. SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
  507. SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
  508. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  509. }
  510. break;
  511. case L('t','r'): // Turkish
  512. {
  513. static const unsigned char stress_amps_tr[8] = {16,16, 20,20, 20,24, 24,22 };
  514. static const short stress_lengths_tr[8] = {180,150, 200,180, 0,0, 230,270};
  515. tr = new Translator();
  516. SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
  517. tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
  518. tr->langopts.stress_rule = 3; // stress on the last syllable
  519. tr->langopts.numbers = 0x1009;
  520. tr->langopts.max_initial_consonants = 2;
  521. }
  522. break;
  523. case L('v','i'): // Vietnamese
  524. {
  525. static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 220, 220, 280};
  526. static const unsigned char stress_amps_vi[] = {16,16, 16,16, 24,24, 24,22 };
  527. static wchar_t vowels_vi[] = {
  528. 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a
  529. 0x103, 0x1eb1, 0x1eaf, 0x1eb3, 0x1eb5, 0x1eb7, // ă
  530. 0xe2, 0x1ea7, 0x1ea5, 0x1ea9, 0x1eab, 0x1ead, // â
  531. 0x65, 0xe8, 0xe9, 0x1ebb, 0x1ebd, 0x1eb9, // e
  532. 0xea, 0x1ec1, 0x1ebf, 0x1ec3, 0x1ec5, 0x1ec7, // i
  533. 0x69, 0xec, 0xed, 0x1ec9, 0x129, 0x1ecb, // i
  534. 0x6f, 0xf2, 0xf3, 0x1ecf, 0xf5, 0x1ecd, // o
  535. 0xf4, 0x1ed3, 0x1ed1, 0x1ed5, 0x1ed7, 0x1ed9, // ô
  536. 0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
  537. 0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
  538. 0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
  539. 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
  540. tr = new Translator();
  541. SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
  542. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  543. tr->langopts.stress_rule = 0;
  544. tr->langopts.word_gap = 0x20; // length of a final vowel is less dependent on the next consonant
  545. tr->langopts.vowel_pause = 4;
  546. tr->letter_groups[0] = vowels_vi;
  547. // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  548. tr->langopts.intonation = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  549. tr->langopts.unstressed_wd1 = 2;
  550. }
  551. break;
  552. case L('z','h'):
  553. case L_zhy:
  554. {
  555. static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 230,250};
  556. static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 };
  557. tr = new Translator;
  558. SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
  559. tr->langopts.stress_rule = 3; // stress on final syllable of a "word"
  560. tr->langopts.stress_flags = 1; // don't automatically set diminished stress (may be set in the intonation module)
  561. tr->langopts.vowel_pause = 0;
  562. tr->langopts.intonation = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  563. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  564. tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  565. tr->langopts.ideographs = 1;
  566. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  567. if(name2 == L('z','h'))
  568. {
  569. tr->langopts.textmode = 1;
  570. }
  571. }
  572. break;
  573. default:
  574. tr = new Translator();
  575. break;
  576. }
  577. tr->translator_name = name2;
  578. if(tr->langopts.numbers & 0x8)
  579. {
  580. // use . and ; for thousands and decimal separators
  581. tr->langopts.thousands_sep = '.';
  582. tr->langopts.decimal_sep = ',';
  583. }
  584. if(tr->langopts.numbers & 0x4)
  585. {
  586. tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
  587. }
  588. return(tr);
  589. } // end of SelectTranslator
  590. //**********************************************************************************************************
  591. Translator_Russian::Translator_Russian() : Translator()
  592. {//===================================
  593. static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 };
  594. static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280};
  595. // character codes offset by 0x420
  596. static const char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f,0};
  597. static const char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0};
  598. static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
  599. static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
  600. static const char ru_nothard[] = {0x11,0x12,0x13,0x14,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x27,0x29,0x2c,0};
  601. static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
  602. static const char ru_ivowels[] = {0x2c,0x15,0x31,0x18,0x2e,0x2f,0}; // letter group Y (iotated vowels & soft-sign)
  603. SetupTranslator(this,stress_lengths_ru,stress_amps_ru);
  604. charset_a0 = charsets[18]; // KOI8-R
  605. transpose_offset = 0x42f; // convert cyrillic from unicode into range 0x01 to 0x22
  606. transpose_min = 0x430;
  607. transpose_max = 0x451;
  608. letter_bits_offset = OFFSET_CYRILLIC;
  609. memset(letter_bits,0,sizeof(letter_bits));
  610. SetLetterBits(this,0,ru_vowels);
  611. SetLetterBits(this,1,ru_soft);
  612. SetLetterBits(this,2,ru_consonants);
  613. SetLetterBits(this,3,ru_hard);
  614. SetLetterBits(this,4,ru_nothard);
  615. SetLetterBits(this,5,ru_voiced);
  616. SetLetterBits(this,6,ru_ivowels);
  617. SetLetterBits(this,7,ru_vowels);
  618. langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  619. langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
  620. langopts.param[LOPT_REDUCE] = 2;
  621. langopts.stress_rule = 5;
  622. langopts.stress_flags = 0x0020; // waas 0x1010
  623. langopts.numbers = 0x0409;
  624. langopts.numbers2 = 0xc2; // variant numbers before thousands
  625. langopts.phoneme_change = 1;
  626. langopts.testing = 2;
  627. } // end of Translator_Russian
  628. #define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
  629. #define PY(c1,c2,c3) (c3<<16)+(c2<<8)+c1
  630. /*
  631. typedef struct {
  632. int flags;
  633. unsigned char stress; // stress level of this vowel
  634. unsigned char stress_highest; // the highest stress level of a vowel in this word
  635. unsigned char n_vowels; // number of vowels in the word
  636. unsigned char vowel_this; // syllable number of this vowel (counting from 1)
  637. unsigned char vowel_stressed; // syllable number of the highest stressed vowel
  638. } CHANGEPH;
  639. */
  640. #define RUSSIAN2
  641. #ifdef RUSSIAN2
  642. int Translator_Russian::ChangePhonemes(PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
  643. {//==============================================================================================================
  644. // Called for each phoneme in the phoneme list, to allow a language to make changes
  645. // ph The current phoneme
  646. int variant;
  647. int vowelix;
  648. PHONEME_TAB *prev, *next;
  649. if(ch->flags & 8)
  650. return(0); // full phoneme translation has already been given
  651. // Russian vowel softening and reduction rules
  652. if(ph->type == phVOWEL)
  653. {
  654. int prestressed = ch->vowel_stressed==ch->vowel_this+1; // the next vowel after this has the main stress
  655. #define N_VOWELS_RU 11
  656. static unsigned int vowels_ru[N_VOWELS_RU] = {'a','V','O','I',PH('I','#'),PH('E','#'),PH('E','2'),
  657. PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
  658. static unsigned int vowel_replace[N_VOWELS_RU][6] = {
  659. // stressed, soft, soft-stressed, j+stressed, j+soft, j+soft-stressed
  660. /*0*/ {'A', 'I', PH('j','a'), 'a', 'a', 'a'}, // a Uses 3,4,5 columns.
  661. /*1*/ {'A', 'V', PH('j','a'), 'a', 'V', 'a'}, // V Uses 3,4,5 columns.
  662. /*2*/ {'o', '8', '8', 'o', '8', '8'}, // O
  663. /*3*/ {'i', 'I', 'i', 'a', 'I', 'a'}, // I Uses 3,4,5 columns.
  664. /*4*/ {'i', PH('I','#'), 'i', 'i', PH('I','#'), 'i'}, // I#
  665. /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
  666. /*6*/ {'E', PH('E','2'), 'E', 'e', PH('E','2'), 'e'}, // E2 Uses 3,4,5 columns.
  667. /*7*/ {PH('j','a'), 'V', PH('j','a'), 'A', 'V', 'A'}, // V#
  668. /*8*/ {PH('j','a'), 'I', PH('j','a'), 'e', 'I', 'e'}, // I3 Uses 3,4,5 columns.
  669. /*9*/ {'e', 'I', 'e', 'e', 'I', 'e'}, // I2
  670. /*10*/ {'e', PH('E', '2'), 'e', 'e', PH('E','2'), 'e'} // E3
  671. };
  672. prev = phoneme_tab[phlist[index-1].phcode];
  673. next = phoneme_tab[phlist[index+1].phcode];
  674. // lookup the vowel name to get an index into the vowel_replace[] table
  675. for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
  676. {
  677. if(vowels_ru[vowelix] == ph->mnemonic)
  678. break;
  679. }
  680. if(vowelix == N_VOWELS_RU)
  681. return(0);
  682. if(prestressed)
  683. {
  684. if((vowelix==6)&&(prev->mnemonic=='j'))
  685. vowelix=8;
  686. if(vowelix==1)
  687. vowelix=0;
  688. if(vowelix==4)
  689. vowelix=3;
  690. if(vowelix==6)
  691. vowelix=5;
  692. if(vowelix==7)
  693. vowelix=8;
  694. if(vowelix==10)
  695. vowelix=9;
  696. }
  697. // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
  698. variant = -1;
  699. int stressed = ch->flags & 2;
  700. int soft=prev->phflags & phPALATAL;
  701. if (soft && stressed)
  702. variant = 2; else
  703. if (stressed)
  704. variant = 0; else
  705. if (soft)
  706. variant = 1;
  707. if(variant >= 0)
  708. {
  709. if(prev->mnemonic == 'j')
  710. variant += 3;
  711. phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
  712. }
  713. else
  714. {
  715. phlist[index].phcode = PhonemeCode(vowels_ru[vowelix]);
  716. }
  717. }
  718. return(0);
  719. }
  720. #else
  721. int Translator_Russian::ChangePhonemes(PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
  722. {//===============================================================================================================
  723. // Called for each phoneme in the phoneme list, to allow a language to make changes
  724. // flags: bit 0=1 last phoneme in a word
  725. // bit 1=1 this is the highest stressed vowel in the current word
  726. // bit 2=1 after the highest stressed vowel in the current word
  727. // bit 3=1 the phonemes were specified explicitly, or found from an entry in the xx_list dictionary
  728. // ph The current phoneme
  729. int variant;
  730. int vowelix;
  731. PHONEME_TAB *prev, *next;
  732. if(ch->flags & 8)
  733. return(0); // full phoneme translation has already been given
  734. // Russian vowel softening and reduction rules
  735. if(ph->type == phVOWEL)
  736. {
  737. #define N_VOWELS_RU 7
  738. static unsigned char vowels_ru[N_VOWELS_RU] = {'a','A','o','E','i','u','y'};
  739. // each line gives: soft, reduced, soft-reduced, post-tonic
  740. static unsigned short vowel_replace[N_VOWELS_RU][4] = {
  741. {'&', 'V', 'I', 'V'}, // a
  742. {'&', 'V', 'I', 'V'}, // A
  743. {'8', 'V', 'I', 'V'}, // o
  744. {'e', 'I', 'I', 'I'}, // E
  745. {'i', 'I', 'I', 'I'}, // i
  746. {'u'+('"'<<8), 'U', 'U', 'U'}, // u
  747. {'y', 'Y', 'Y', 'Y'}}; // y
  748. prev = phoneme_tab[phlist[index-1].phcode];
  749. next = phoneme_tab[phlist[index+1].phcode];
  750. if(prev->mnemonic == 'j')
  751. return(0);
  752. // lookup the vowel name to get an index into the vowel_replace[] table
  753. for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
  754. {
  755. if(vowels_ru[vowelix] == ph->mnemonic)
  756. break;
  757. }
  758. if(vowelix == N_VOWELS_RU)
  759. return(0);
  760. // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
  761. variant = -1;
  762. if(ch->flags & 2)
  763. {
  764. // a stressed vowel
  765. if((prev->phflags & phPALATAL) && ((next->phflags & phPALATAL) || phoneme_tab[phlist[index+2].phcode]->mnemonic == ';'))
  766. {
  767. // between two palatal consonants, use the soft variant
  768. variant = 0;
  769. }
  770. }
  771. else
  772. {
  773. // an unstressed vowel
  774. if(prev->phflags & phPALATAL)
  775. {
  776. variant = 2; // unstressed soft
  777. }
  778. else
  779. if((ph->mnemonic == 'o') && ((prev->phflags & phPLACE) == phPLACE_pla))
  780. {
  781. variant = 2; // unstressed soft ([o] vowel following: ш ж
  782. }
  783. else
  784. if(ch->flags & 4)
  785. {
  786. variant = 3; // post tonic
  787. }
  788. else
  789. {
  790. variant = 1; // unstressed
  791. }
  792. }
  793. if(variant >= 0)
  794. {
  795. phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
  796. }
  797. }
  798. return(0);
  799. }
  800. #endif
  801. //**********************************************************************************************************
  802. Translator_Afrikaans::Translator_Afrikaans() : Translator()
  803. {//=========================================
  804. // Initialise options for this language
  805. static const short stress_lengths2[8] = {170,140, 220,220, 0, 0, 250,270};
  806. langopts.stress_rule = 0;
  807. langopts.vowel_pause = 0x30;
  808. langopts.param[LOPT_DIERESES] = 1;
  809. langopts.param[LOPT_PREFIXES] = 1;
  810. SetLetterVowel(this,'y'); // add 'y' to vowels
  811. langopts.numbers = 0x0d1 + NUM_ROMAN;
  812. memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths));
  813. }
  814. int Translator_Afrikaans::TranslateChar(char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
  815. {//===============================================================================================================
  816. // look for 'n and replace by a special character (unicode: schwa)
  817. if(!iswalpha(prev_in))
  818. {
  819. if((c == '\'') && (next_in == 'n'))
  820. {
  821. // n preceded by either apostrophe or U2019 "right single quotation mark"
  822. ptr[0] = ' '; // delete the n
  823. return(0x0259); // replace ' by unicode schwa character
  824. }
  825. }
  826. return(c);
  827. }