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 68KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2013 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. #define L_qa 0x716100
  33. #define L_grc 0x677263 // grc Ancient Greek
  34. #define L_jbo 0x6a626f // jbo Lojban
  35. #define L_pap 0x706170 // pap Papiamento]
  36. #define L_qvi 0x717669 // qvi Kichwa
  37. #define L_shs 0x736873 // shs Shuswap / Secwepemctsin
  38. #define L_zhy 0x7a6879 // zhy
  39. // start of unicode pages for character sets
  40. #define OFFSET_GREEK 0x380
  41. #define OFFSET_CYRILLIC 0x420
  42. #define OFFSET_ARMENIAN 0x530
  43. #define OFFSET_HEBREW 0x590
  44. #define OFFSET_ARABIC 0x600
  45. #define OFFSET_THAANA 0x780 // Divehi/Maldives
  46. #define OFFSET_DEVANAGARI 0x900
  47. #define OFFSET_BENGALI 0x980
  48. #define OFFSET_GURMUKHI 0xa00
  49. #define OFFSET_GUJARATI 0xa80
  50. #define OFFSET_ORIYA 0xb00
  51. #define OFFSET_TAMIL 0xb80
  52. #define OFFSET_TELUGU 0xc00
  53. #define OFFSET_KANNADA 0xc80
  54. #define OFFSET_MALAYALAM 0xd00
  55. #define OFFSET_SINHALA 0x0d80
  56. #define OFFSET_THAI 0x0e00
  57. #define OFFSET_LAO 0x0e80
  58. #define OFFSET_TIBET 0x0f00
  59. #define OFFSET_MYANMAR 0x1000
  60. #define OFFSET_GEORGIAN 0x10a0
  61. #define OFFSET_KOREAN 0x1100
  62. #define OFFSET_ETHIOPIC 0x1200
  63. ALPHABET alphabets [] = {
  64. {"_el", OFFSET_GREEK, 0x380, 0x3ff, L('e','l'), AL_DONT_NAME | AL_NOT_LETTERS},
  65. {"_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0},
  66. {"_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h','y'), AL_WORDS},
  67. {"_he", OFFSET_HEBREW, 0x590, 0x5ff, 0, 0},
  68. {"_ar", OFFSET_ARABIC, 0x600, 0x6ff, 0, 0},
  69. {"_dv", OFFSET_THAANA, 0x780, 0x7bf, 0, 0},
  70. {"_hi", OFFSET_DEVANAGARI, 0x900, 0x97f,L('h','i'), AL_WORDS},
  71. {"_bn", OFFSET_BENGALI, 0x0980, 0x9ff, 0, 0},
  72. {"_gur", OFFSET_GURMUKHI, 0xa00, 0xa7f, 0, 0},
  73. {"_gu", OFFSET_GUJARATI, 0xa80, 0xaff, 0, 0},
  74. {"_or", OFFSET_ORIYA, 0xb00, 0xb7f, 0, 0},
  75. {"_ta", OFFSET_TAMIL, 0xb80, 0xbff, L('t','a'), AL_WORDS},
  76. {"_te", OFFSET_TELUGU, 0xc00, 0xc7f, L('t','e'), 0},
  77. {"_kn", OFFSET_KANNADA, 0xc80, 0xcff, L('k','n'), AL_WORDS},
  78. {"_ml", OFFSET_MALAYALAM,0xd00, 0xd7f, L('m','l'), AL_WORDS},
  79. {"_si", OFFSET_SINHALA, 0xd80, 0xdff, 0, 0},
  80. {"_th", OFFSET_THAI, 0xe00, 0xe7f, 0, 0},
  81. {"_lo", OFFSET_LAO, 0xe80, 0xeff, 0, 0},
  82. {"_ti", OFFSET_TIBET, 0xf00, 0xfff, 0, 0},
  83. {"_my", OFFSET_MYANMAR, 0x1000,0x109f, 0, 0},
  84. {"_ka", OFFSET_GEORGIAN, 0x10a0,0x10ff, L('k','a'), AL_WORDS},
  85. {"_ko", OFFSET_KOREAN, 0x1100,0x11ff, 0, 0},
  86. {"_eth", OFFSET_ETHIOPIC, 0x1200,0x139f, 0, 0},
  87. {NULL, 0, 0, 0, 0, 0}
  88. };
  89. ALPHABET *AlphabetFromChar(int c)
  90. {//===============================
  91. // Find the alphabet from a character.
  92. ALPHABET *alphabet = alphabets;
  93. while(alphabet->name != NULL)
  94. {
  95. if((c >= alphabet->range_min) && (c <= alphabet->range_max))
  96. {
  97. return(alphabet);
  98. }
  99. alphabet++;
  100. }
  101. return(NULL);
  102. }
  103. static void Translator_Russian(Translator *tr);
  104. static void SetLetterVowel(Translator *tr, int c)
  105. {//==============================================
  106. tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
  107. }
  108. static void ResetLetterBits(Translator *tr, int groups)
  109. {//====================================================
  110. // Clear all the specified groups
  111. unsigned int ix;
  112. unsigned int mask;
  113. mask = ~groups;
  114. for(ix=0; ix<sizeof(tr->letter_bits); ix++)
  115. {
  116. tr->letter_bits[ix] &= mask;
  117. }
  118. }
  119. static void SetLetterBits(Translator *tr, int group, const char *string)
  120. {//=====================================================================
  121. int bits;
  122. unsigned char c;
  123. bits = (1L << group);
  124. while((c = *string++) != 0)
  125. tr->letter_bits[c] |= bits;
  126. }
  127. static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
  128. {//===========================================================================
  129. int bits;
  130. int ix;
  131. bits = (1L << group);
  132. for(ix=first; ix<=last; ix++)
  133. {
  134. tr->letter_bits[ix] |= bits;
  135. }
  136. }
  137. // ignore these characters
  138. static const unsigned short chars_ignore_default[] = {
  139. 0xad, 1, // soft hyphen
  140. 0x200c, 1, // zero width non-joiner
  141. 0x200d, 1, // zero width joiner
  142. 0, 0 };
  143. // alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
  144. static const unsigned short chars_ignore_zwnj_hyphen[] = {
  145. 0xad, 1, // soft hyphen
  146. 0x200c, '-', // zero width non-joiner, replace with hyphen
  147. 0x200d, 1, // zero width joiner
  148. 0, 0 };
  149. static Translator* NewTranslator(void)
  150. {//===================================
  151. Translator *tr;
  152. int ix;
  153. static const unsigned char stress_amps2[] = {18,18, 20,20, 20,22, 22,20 };
  154. static const short stress_lengths2[8] = {182,140, 220,220, 220,240, 260,280};
  155. static const wchar_t empty_wstring[1] = {0};
  156. static const wchar_t punct_in_word[2] = {'\'', 0}; // allow hyphen within words
  157. static const unsigned char default_tunes[6] = {0, 1, 2, 3, 0, 0};
  158. // Translates character codes in the range transpose_min to transpose_max to
  159. // a number in the range 1 to 63. 0 indicates there is no translation.
  160. // Used up to 57 (max of 63)
  161. static const char transpose_map_latin[] = {
  162. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x60
  163. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x70
  164. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
  165. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
  166. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
  167. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
  168. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
  169. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
  170. 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 0, 37, 38, 0, // 0xe0
  171. 0, 0, 0, 39, 0, 0, 40, 0, 41, 0, 42, 0, 43, 0, 0, 0, // 0xf0
  172. 0, 0, 0, 44, 0, 45, 0, 46, 0, 0, 0, 0, 0, 47, 0, 0, // 0x100
  173. 0, 48, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, // 0x110
  174. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x120
  175. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x130
  176. 0, 0, 50, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x140
  177. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, // 0x150
  178. 0, 53, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x160
  179. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170
  180. };
  181. tr = (Translator *)Alloc(sizeof(Translator));
  182. if(tr == NULL)
  183. return(NULL);
  184. tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
  185. dictionary_name[0] = 0;
  186. tr->dict_condition=0;
  187. tr->data_dictrules = NULL; // language_1 translation rules file
  188. tr->data_dictlist = NULL; // language_2 dictionary lookup file
  189. tr->transpose_min = 0x60;
  190. tr->transpose_max = 0x17f;
  191. tr->transpose_map = transpose_map_latin;
  192. tr->frequent_pairs = NULL;
  193. // only need lower case
  194. tr->letter_bits_offset = 0;
  195. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  196. memset(tr->letter_groups,0,sizeof(tr->letter_groups));
  197. // 0-6 sets of characters matched by A B C H F G Y in pronunciation rules
  198. // these may be set differently for different languages
  199. SetLetterBits(tr,0,"aeiou"); // A vowels, except y
  200. SetLetterBits(tr,1,"bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
  201. SetLetterBits(tr,2,"bcdfghjklmnpqrstvwxz"); // C all consonants
  202. SetLetterBits(tr,3,"hlmnr"); // H 'soft' consonants
  203. SetLetterBits(tr,4,"cfhkpqstx"); // F voiceless consonants
  204. SetLetterBits(tr,5,"bdgjlmnrvwyz"); // G voiced
  205. SetLetterBits(tr,6,"eiy"); // Letter group Y, front vowels
  206. SetLetterBits(tr,7,"aeiouy"); // vowels, including y
  207. tr->char_plus_apostrophe = empty_wstring;
  208. tr->punct_within_word = punct_in_word;
  209. tr->chars_ignore = chars_ignore_default;
  210. for(ix=0; ix<8; ix++)
  211. {
  212. tr->stress_amps[ix] = stress_amps2[ix];
  213. tr->stress_amps_r[ix] = stress_amps2[ix] - 1;
  214. tr->stress_lengths[ix] = stress_lengths2[ix];
  215. }
  216. memset(&(tr->langopts),0,sizeof(tr->langopts));
  217. tr->langopts.max_lengthmod = 500;
  218. tr->langopts.lengthen_tonic = 20;
  219. tr->langopts.stress_rule = STRESSPOSN_2R;
  220. tr->langopts.unstressed_wd1 = 1;
  221. tr->langopts.unstressed_wd2 = 3;
  222. tr->langopts.param[LOPT_SONORANT_MIN] = 95;
  223. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 190/2;
  224. tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
  225. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
  226. tr->langopts.param[LOPT_BRACKET_PAUSE] = 4; // pause at bracket
  227. tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
  228. tr->langopts.max_initial_consonants = 3;
  229. tr->langopts.replace_chars = NULL;
  230. tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
  231. SetLengthMods(tr,201);
  232. // tr->langopts.length_mods = length_mods_en;
  233. // tr->langopts.length_mods0 = length_mods_en0;
  234. tr->langopts.long_stop = 100;
  235. tr->langopts.max_roman = 49;
  236. tr->langopts.min_roman = 2;
  237. tr->langopts.thousands_sep = ',';
  238. tr->langopts.decimal_sep = '.';
  239. tr->langopts.break_numbers = BREAK_THOUSANDS; // 1000, 1000,000 1,000,000 etc
  240. tr->langopts.max_digits = 14;
  241. memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
  242. memcpy(tr->langopts.tunes, default_tunes, sizeof(tr->langopts.tunes));
  243. return(tr);
  244. }
  245. // common letter pairs, encode these as a single byte
  246. // 2 bytes, using the transposed character codes
  247. static const short pairs_ru[] = {
  248. 0x010c, // ла 21052 0x23
  249. 0x010e, // на 18400
  250. 0x0113, // та 14254
  251. 0x0301, // ав 31083
  252. 0x030f, // ов 13420
  253. 0x060e, // не 21798
  254. 0x0611, // ре 19458
  255. 0x0903, // ви 16226
  256. 0x0b01, // ак 14456
  257. 0x0b0f, // ок 17836
  258. 0x0c01, // ал 13324
  259. 0x0c09, // ил 16877
  260. 0x0e01, // ан 15359
  261. 0x0e06, // ен 13543 0x30
  262. 0x0e09, // ин 17168
  263. 0x0e0e, // нн 15973
  264. 0x0e0f, // он 22373
  265. 0x0e1c, // ын 15052
  266. 0x0f03, // во 24947
  267. 0x0f11, // ро 13552
  268. 0x0f12, // со 16368
  269. 0x100f, // оп 19054
  270. 0x1011, // рп 17067
  271. 0x1101, // ар 23967
  272. 0x1106, // ер 18795
  273. 0x1109, // ир 13797
  274. 0x110f, // ор 21737
  275. 0x1213, // тс 25076
  276. 0x1220, // яс 14310
  277. 0x7fff};
  278. //0x040f ог 12976
  279. //0x1306 ет 12826
  280. //0x0f0d мо 12688
  281. static const unsigned int replace_cyrillic_latin[] =
  282. {0x430,'a',
  283. 0x431,'b',
  284. 0x446,'c',
  285. 0x45b,0x107,
  286. 0x447,0x10d,
  287. 0x45f,'d'+(0x17e<<16),
  288. 0x455,'d'+('z'<<16),
  289. 0x434,'d',
  290. 0x452,0x111,
  291. 0x435,'e',
  292. 0x444,'f',
  293. 0x433,'g',
  294. 0x445,'h',
  295. 0x438,'i',
  296. 0x458,'j',
  297. 0x43a,'k',
  298. 0x459,'l'+('j'<<16),
  299. 0x43b,'l',
  300. 0x43c,'m',
  301. 0x45a,'n'+('j'<<16),
  302. 0x43d,'n',
  303. 0x43e,'o',
  304. 0x43f,'p',
  305. 0x440,'r',
  306. 0x441,'s',
  307. 0x448,0x161,
  308. 0x442,'t',
  309. 0x443,'u',
  310. 0x432,'v',
  311. 0x437,'z',
  312. 0x436,0x17e,
  313. 0x453,0x111,
  314. 0x45c,0x107,
  315. 0}; // ѓ ѕ ќ
  316. static const unsigned char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f, 0xb9,0xc9,0x91,0x8f,0x36,0}; //also kazakh
  317. static const unsigned 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, 0x73,0x7b,0x83,0x9b,0};
  318. static void SetCyrillicLetters(Translator *tr)
  319. {//===========================================
  320. // character codes offset by 0x420
  321. static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
  322. static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
  323. 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};
  324. static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
  325. static const char ru_ivowels[] = {0x2c,0x2e,0x2f,0x31,0}; // letter group Y (iotated vowels & soft-sign)
  326. tr->charset_a0 = charsets[18]; // KOI8-R
  327. tr->transpose_min = 0x430; // convert cyrillic from unicode into range 0x01 to 0x22
  328. tr->transpose_max = 0x451;
  329. tr->transpose_map = NULL;
  330. tr->frequent_pairs = pairs_ru;
  331. tr->letter_bits_offset = OFFSET_CYRILLIC;
  332. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  333. SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
  334. SetLetterBits(tr,LETTERGP_B,ru_soft);
  335. SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
  336. SetLetterBits(tr,LETTERGP_H,ru_hard);
  337. SetLetterBits(tr,LETTERGP_F,ru_nothard);
  338. SetLetterBits(tr,LETTERGP_G,ru_voiced);
  339. SetLetterBits(tr,LETTERGP_Y,ru_ivowels);
  340. SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
  341. } // end of SetCyrillicLetters
  342. void SetIndicLetters(Translator *tr)
  343. {//=================================
  344. // Set letter types for Indic scripts, Devanagari, Tamill, etc
  345. static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x7b,0x7c,0x7e,0x7f,0};
  346. static const char dev_vowels2[] = {0x60,0x61, 0x55,0x56,0x57,0x62,0x63,0}; // non-consecutive vowels and vowel-signs
  347. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  348. SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters
  349. SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4d); // + vowel signs, and virama
  350. SetLetterBits(tr,LETTERGP_A, dev_vowels2); // + extra vowels and vowel signs
  351. SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
  352. SetLetterBits(tr,LETTERGP_B, dev_vowels2); // + extra vowels and vowel signs
  353. SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
  354. SetLetterBits(tr,LETTERGP_C,dev_consonants2); // + additional consonants
  355. SetLetterBitsRange(tr,LETTERGP_Y,0x04,0x14); // vowel letters
  356. SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
  357. SetLetterBits(tr,LETTERGP_Y, dev_vowels2); // + extra vowels and vowel signs
  358. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  359. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; //virama
  360. }
  361. void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
  362. {//==================================================================================
  363. if(lengths != NULL)
  364. memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths));
  365. if(amps != NULL)
  366. memcpy(tr->stress_amps,amps,sizeof(tr->stress_amps));
  367. }
  368. Translator *SelectTranslator(const char *name)
  369. {//===========================================
  370. int name2 = 0;
  371. Translator *tr;
  372. static const short stress_lengths_equal[8] = {250, 250, 250, 250, 0, 0, 250, 250};
  373. static const unsigned char stress_amps_equal[8] = {18,18, 18,18, 18,18, 18,18 };
  374. static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 190, 240};
  375. static const unsigned char stress_amps_fr[8] = {18,16, 18,18, 18,18, 18,18 };
  376. static const unsigned char stress_amps_sk[8] = {17,16, 20,20, 20,22, 22,21 };
  377. static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
  378. static const short stress_lengths_ta[8] = {240, 240, 250, 250, 0, 0, 270, 270};
  379. static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
  380. // convert name string into a word of up to 4 characters, for the switch()
  381. while(*name != 0)
  382. name2 = (name2 << 8) + *name++;
  383. tr = NewTranslator();
  384. switch(name2)
  385. {
  386. case L('a','f'):
  387. {
  388. static const short stress_lengths_af[8] = {170,140, 220,220, 0, 0, 250,270};
  389. SetupTranslator(tr,stress_lengths_af,NULL);
  390. tr->langopts.stress_rule = STRESSPOSN_1L;
  391. tr->langopts.vowel_pause = 0x30;
  392. tr->langopts.param[LOPT_DIERESES] = 1;
  393. tr->langopts.param[LOPT_PREFIXES] = 1;
  394. SetLetterVowel(tr,'y'); // add 'y' to vowels
  395. tr->langopts.numbers = NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_ROMAN | NUM_1900;
  396. tr->langopts.accents = 1;
  397. }
  398. break;
  399. case L('a','m'): // Amharic, Ethiopia
  400. {
  401. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  402. tr->letter_bits_offset = OFFSET_ETHIOPIC;
  403. tr->langopts.stress_rule = STRESSPOSN_1L;
  404. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  405. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  406. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  407. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  408. }
  409. break;
  410. case L('a','r'): // Arabic
  411. tr->letter_bits_offset = OFFSET_ARABIC;
  412. tr->langopts.numbers = NUM_SWAP_TENS | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED | NUM_THOUSAND_AND | NUM_OMIT_1_THOUSAND;
  413. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  414. break;
  415. case L('b','g'): //Bulgarian
  416. {
  417. SetCyrillicLetters(tr);
  418. SetLetterVowel(tr,0x2a);
  419. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  420. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x107; // devoice at end of word, and change voicing to match a following consonant (except v)
  421. tr->langopts.param[LOPT_REDUCE] = 2;
  422. tr->langopts.stress_rule = STRESSPOSN_2R;
  423. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_SINGLE_AND | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS ;
  424. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  425. }
  426. break;
  427. case L('b','n'): // Bengali
  428. {
  429. static const short stress_lengths_bn[8] = {180, 180, 210, 210, 0, 0, 230, 240};
  430. static const unsigned char stress_amps_bn[8] = {18,18, 18,18, 20,20, 22,22 };
  431. SetupTranslator(tr,stress_lengths_bn,stress_amps_bn);
  432. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  433. tr->langopts.stress_rule = STRESSPOSN_1L;
  434. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  435. tr->letter_bits_offset = OFFSET_BENGALI;
  436. SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
  437. SetLetterBitsRange(tr,LETTERGP_F,0x3e,0x4c); // vowel signs, but not virama
  438. tr->langopts.numbers = 0x1;
  439. tr->langopts.break_numbers = 0x24924aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  440. }
  441. break;
  442. case L('b','o'): // Tibet
  443. {
  444. tr->langopts.stress_rule = STRESSPOSN_1L;
  445. tr->letter_bits_offset = OFFSET_TIBET;
  446. SetLetterBitsRange(tr,LETTERGP_A,0x71,0x7d); // vowel signs
  447. SetLetterBitsRange(tr,LETTERGP_B,0x71,0x81); // vowel signs and subjoined letters
  448. SetLetterBitsRange(tr,LETTERGP_B,0x90,0xbc);
  449. SetLetterBitsRange(tr,LETTERGP_C,0x40,0x6c); // consonant letters (not subjoined)
  450. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  451. tr->langopts.numbers = 1;
  452. }
  453. break;
  454. case L('c','y'): // Welsh
  455. {
  456. static const short stress_lengths_cy[8] = {170,220, 180,180, 0, 0, 250,270};
  457. static const unsigned char stress_amps_cy[8] = {17,15, 18,18, 0,0, 22,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  458. SetupTranslator(tr,stress_lengths_cy,stress_amps_cy);
  459. tr->charset_a0 = charsets[14]; // ISO-8859-14
  460. // tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  461. tr->langopts.stress_rule = STRESSPOSN_2R;
  462. // tr->langopts.intonation_group = 4;
  463. // 'diminished' is an unstressed final syllable
  464. tr->langopts.stress_flags = 0x6 | 0x10;
  465. tr->langopts.unstressed_wd1 = 0;
  466. tr->langopts.unstressed_wd2 = 2;
  467. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  468. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  469. SetLetterVowel(tr,'w'); // add letter to vowels and remove from consonants
  470. SetLetterVowel(tr,'y');
  471. }
  472. break;
  473. case L('d','a'): // Danish
  474. {
  475. static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,230};
  476. SetupTranslator(tr,stress_lengths_da,NULL);
  477. tr->langopts.stress_rule = STRESSPOSN_1L;
  478. tr->langopts.param[LOPT_PREFIXES] = 1;
  479. SetLetterVowel(tr,'y');
  480. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  481. }
  482. break;
  483. case L('d','e'):
  484. {
  485. static const short stress_lengths_de[8] = {150,130, 200,200, 0, 0, 270,270};
  486. static const unsigned char stress_amps_de[] = {20,20, 20,20, 20,22, 22,20 };
  487. SetupTranslator(tr, stress_lengths_de, stress_amps_de);
  488. tr->langopts.stress_rule = STRESSPOSN_1L;
  489. tr->langopts.word_gap = 0x8; // don't use linking phonemes
  490. tr->langopts.vowel_pause = 0x30;
  491. tr->langopts.param[LOPT_PREFIXES] = 1;
  492. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  493. tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
  494. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
  495. // tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
  496. SetLetterVowel(tr,'y');
  497. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use de_rules for unpronouncable rules
  498. }
  499. break;
  500. case L('d','v'): // Divehi (Maldives)
  501. {
  502. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  503. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  504. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  505. tr->letter_bits_offset = OFFSET_THAANA;
  506. tr->langopts.stress_rule = STRESSPOSN_1L;
  507. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  508. SetLetterBitsRange(tr,LETTERGP_B,0x26,0x30); // vowel signs, and virama
  509. tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
  510. tr->langopts.numbers = 1;
  511. }
  512. break;
  513. case L('e','n'):
  514. {
  515. static const short stress_lengths_en[8] = {182,140, 220,220, 0,0, 248,275};
  516. SetupTranslator(tr,stress_lengths_en,NULL);
  517. tr->langopts.stress_rule = STRESSPOSN_1L;
  518. tr->langopts.stress_flags = 0x08;
  519. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
  520. tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
  521. tr->langopts.suffix_add_e = 'e';
  522. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use en_rules for unpronouncable rules
  523. SetLetterBits(tr,6,"aeiouy"); // Group Y: vowels, including y
  524. }
  525. break;
  526. case L('e','l'): // Greek
  527. case L_grc: // Ancient Greek
  528. {
  529. static const short stress_lengths_el[8] = {155, 180, 210, 210, 0, 0, 270, 300};
  530. static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  531. // character codes offset by 0x380
  532. 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};
  533. static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι υ έ ή ί ύ
  534. static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ
  535. static const char el_consonants[]={0x32,0x33,0x34,0x36,0x38,0x3a,0x3b,0x3c,0x3d,0x3e,0x40,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0};
  536. static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ
  537. SetupTranslator(tr,stress_lengths_el,stress_amps_el);
  538. tr->charset_a0 = charsets[7]; // ISO-8859-7
  539. tr->char_plus_apostrophe = el_char_apostrophe;
  540. tr->letter_bits_offset = OFFSET_GREEK;
  541. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  542. SetLetterBits(tr,LETTERGP_A,el_vowels);
  543. SetLetterBits(tr,LETTERGP_VOWEL2,el_vowels);
  544. SetLetterBits(tr,LETTERGP_B,el_voiceless);
  545. SetLetterBits(tr,LETTERGP_C,el_consonants);
  546. SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
  547. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  548. tr->langopts.stress_rule = STRESSPOSN_2R;
  549. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  550. tr->langopts.unstressed_wd1 = 0;
  551. tr->langopts.unstressed_wd2 = 2;
  552. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  553. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA;
  554. tr->langopts.numbers2 = 0x2 | NUM2_MULTIPLE_ORDINAL; // variant form of numbers before thousands
  555. if(name2 == L_grc)
  556. {
  557. // ancient greek
  558. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1;
  559. }
  560. }
  561. break;
  562. case L('e','o'):
  563. {
  564. static const short stress_lengths_eo[8] = {150, 150, 230, 180, 0, 0, 300, 320};
  565. static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,22, 22,21 };
  566. static const wchar_t eo_char_apostrophe[2] = {'l',0};
  567. SetupTranslator(tr,stress_lengths_eo,stress_amps_eo);
  568. tr->charset_a0 = charsets[3]; // ISO-8859-3
  569. tr->char_plus_apostrophe = eo_char_apostrophe;
  570. // tr->langopts.word_gap = 1;
  571. tr->langopts.vowel_pause = 2;
  572. tr->langopts.stress_rule = STRESSPOSN_2R;
  573. tr->langopts.stress_flags = 0x6 | 0x10;
  574. // tr->langopts.unstressed_wd1 = 3;
  575. tr->langopts.unstressed_wd2 = 2;
  576. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_ROMAN;
  577. }
  578. break;
  579. case L('e','s'): // Spanish
  580. case L('a','n'): // Aragonese
  581. case L('c','a'): // Catalan
  582. case L_pap: // Papiamento
  583. {
  584. static const short stress_lengths_es[8] = {180, 190, 230, 180, 0, 0, 240, 270};
  585. static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,20, 20,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  586. static const wchar_t ca_punct_within_word[] = {'\'',0xb7,0}; // ca: allow middle-dot within word
  587. SetupTranslator(tr,stress_lengths_es,stress_amps_es);
  588. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  589. tr->langopts.stress_rule = STRESSPOSN_2R;
  590. // stress last syllable if it doesn't end in vowel or "s" or "n"
  591. // 'diminished' is an unstressed final syllable
  592. tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
  593. tr->langopts.unstressed_wd1 = 0;
  594. tr->langopts.unstressed_wd2 = 2;
  595. tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
  596. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER;
  597. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL;
  598. if(name2 == L('c','a'))
  599. {
  600. tr->punct_within_word = ca_punct_within_word;
  601. tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
  602. }
  603. else
  604. if(name2 == L('a','n'))
  605. {
  606. tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
  607. }
  608. else
  609. if(name2 == L_pap)
  610. {
  611. tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
  612. }
  613. else
  614. {
  615. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
  616. }
  617. }
  618. break;
  619. case L('e','u'): // basque
  620. {
  621. static const short stress_lengths_eu[8] = {200, 200, 200, 200, 0, 0, 210, 230}; // very weak stress
  622. static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
  623. SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
  624. tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable ??
  625. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_VIGESIMAL;
  626. }
  627. break;
  628. case L('f','a'): // Farsi
  629. {
  630. // Convert characters in the range 0x620 to 0x6cc to the range 1 to 63.
  631. // 0 indicates no translation for this character
  632. static const char transpose_map_fa[] = {
  633. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x620
  634. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x630
  635. 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, // 0x640
  636. 42, 43, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x650
  637. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x660
  638. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, // 0x670
  639. 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x680
  640. 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, // 0x690
  641. 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 49, // 0x6a0
  642. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x6b0
  643. 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 }; // 0x6c0
  644. tr->transpose_min = 0x620;
  645. tr->transpose_max = 0x6cc;
  646. tr->transpose_map = transpose_map_fa;
  647. tr->letter_bits_offset = OFFSET_ARABIC;
  648. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
  649. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  650. tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
  651. }
  652. break;
  653. case L('e','t'): // Estonian
  654. tr->charset_a0 = charsets[4]; // ISO-8859-4
  655. // drop through to Finnish
  656. case L('f','i'): // Finnish
  657. {
  658. static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 };
  659. static const short stress_lengths_fi[8] = {150,180, 200,200, 0,0, 210,250};
  660. SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
  661. tr->langopts.stress_rule = STRESSPOSN_1L;
  662. tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
  663. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  664. tr->langopts.long_stop = 130;
  665. tr->langopts.numbers = NUM_DECIMAL_COMMA + NUM_ALLOW_SPACE;
  666. SetLetterVowel(tr,'y');
  667. // tr->langopts.max_initial_consonants = 2; // BUT foreign words may have 3
  668. tr->langopts.spelling_stress = 1;
  669. tr->langopts.intonation_group = 3; // less intonation, don't raise pitch at comma
  670. }
  671. break;
  672. case L('f','r'): // french
  673. {
  674. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  675. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  676. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  677. tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
  678. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  679. tr->langopts.accents = 2; // Say "Capital" after the letter.
  680. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER | NUM_VIGESIMAL | NUM_DFRACTION_4;
  681. SetLetterVowel(tr,'y');
  682. }
  683. break;
  684. case L('g','a'): // irish
  685. {
  686. tr->langopts.stress_rule = STRESSPOSN_1L;
  687. tr->langopts.numbers = 1;
  688. }
  689. break;
  690. case L('h','i'): // Hindi
  691. case L('n','e'): // Nepali
  692. case L('p','a'): // Punjabi
  693. {
  694. static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
  695. static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,22, 22,21 };
  696. SetupTranslator(tr,stress_lengths_hi,stress_amps_hi);
  697. tr->charset_a0 = charsets[19]; // ISCII
  698. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  699. tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
  700. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  701. tr->langopts.numbers = NUM_SWAP_TENS;
  702. tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  703. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  704. if(name2 == L('p','a'))
  705. {
  706. tr->letter_bits_offset = OFFSET_GURMUKHI;
  707. }
  708. else
  709. if(name2 == L('g','u'))
  710. {
  711. SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
  712. tr->letter_bits_offset = OFFSET_GUJARATI;
  713. tr->langopts.stress_rule = STRESSPOSN_2R;
  714. }
  715. else
  716. if(name2 == L('n','e'))
  717. {
  718. SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
  719. tr->langopts.break_numbers = 0x2aaaa8;
  720. tr->langopts.max_digits = 22;
  721. tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
  722. }
  723. SetIndicLetters(tr);
  724. }
  725. break;
  726. case L('h','r'): // Croatian
  727. case L('b','s'): // Bosnian
  728. case L('s','r'): // Serbian
  729. {
  730. static const unsigned char stress_amps_hr[8] = {17,17, 20,20, 20,22, 22,21 };
  731. static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
  732. static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
  733. if(name2 == L('s','r'))
  734. SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
  735. else
  736. SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
  737. tr->charset_a0 = charsets[2]; // ISO-8859-2
  738. tr->langopts.stress_rule = STRESSPOSN_1L;
  739. tr->langopts.stress_flags = 0x10;
  740. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  741. tr->langopts.max_initial_consonants = 5;
  742. tr->langopts.spelling_stress = 1;
  743. tr->langopts.accents = 1;
  744. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
  745. tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards
  746. tr->langopts.replace_chars = replace_cyrillic_latin;
  747. SetLetterVowel(tr,'y');
  748. SetLetterVowel(tr,'r');
  749. }
  750. break;
  751. case L('h','t'): // Haitian Creole
  752. // memcpy(tr->stress_lengths,stress_lengths_fr,sizeof(tr->stress_lengths));
  753. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  754. tr->langopts.stress_flags = 0x0024; // don't use secondary stress
  755. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
  756. break;
  757. case L('h','u'): // Hungarian
  758. {
  759. static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,22, 22,21 };
  760. static const short stress_lengths_hu[8] = {185,195, 195,190, 0,0, 210,220};
  761. SetupTranslator(tr,stress_lengths_hu,stress_amps_hu);
  762. tr->charset_a0 = charsets[2]; // ISO-8859-2
  763. tr->langopts.vowel_pause = 0x20;
  764. tr->langopts.stress_rule = STRESSPOSN_1L;
  765. tr->langopts.stress_flags = 0x8036 | S_HYPEN_UNSTRESS;
  766. tr->langopts.unstressed_wd1 = 2;
  767. tr->langopts.param[LOPT_IT_DOUBLING] = 1;
  768. tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
  769. tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
  770. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  771. tr->langopts.decimal_sep = ',';
  772. tr->langopts.max_roman = 899;
  773. tr->langopts.min_roman = 1;
  774. SetLetterVowel(tr,'y');
  775. tr->langopts.spelling_stress = 1;
  776. SetLengthMods(tr,3); // all equal
  777. }
  778. break;
  779. case L('h','y'): // Armenian
  780. {
  781. static const short stress_lengths_hy[8] = {250, 200, 250, 250, 0, 0, 250, 250};
  782. static const char hy_vowels[] = {0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0};
  783. static const char hy_consonants[] = {0x32,0x33,0x34,0x36,0x39,0x3a,0x3c,0x3d,0x3e,0x3f,
  784. 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
  785. SetupTranslator(tr,stress_lengths_hy,NULL);
  786. tr->langopts.stress_rule = STRESSPOSN_1R; // default stress on final syllable
  787. tr->letter_bits_offset = OFFSET_ARMENIAN;
  788. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  789. SetLetterBits(tr,LETTERGP_A,hy_vowels);
  790. SetLetterBits(tr,LETTERGP_VOWEL2,hy_vowels);
  791. SetLetterBits(tr,LETTERGP_C,hy_consonants);
  792. tr->langopts.max_initial_consonants = 6;
  793. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
  794. // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  795. }
  796. break;
  797. case L('i','d'): // Indonesian
  798. {
  799. static const short stress_lengths_id[8] = {160, 200, 180, 180, 0, 0, 220, 240};
  800. static const unsigned char stress_amps_id[8] = {16,18, 18,18, 20,22, 22,21 };
  801. SetupTranslator(tr,stress_lengths_id,stress_amps_id);
  802. tr->langopts.stress_rule = STRESSPOSN_2R;
  803. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_ROMAN;
  804. tr->langopts.stress_flags = 0x6 | 0x10;
  805. tr->langopts.accents = 2; // "capital" after letter name
  806. }
  807. break;
  808. case L('i','s'): // Icelandic
  809. {
  810. static const short stress_lengths_is[8] = {180,160, 200,200, 0,0, 240,250};
  811. static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's'
  812. SetupTranslator(tr,stress_lengths_is,NULL);
  813. tr->langopts.stress_rule = STRESSPOSN_1L;
  814. tr->langopts.stress_flags = 0x10;
  815. tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
  816. tr->langopts.param[LOPT_REDUCE] = 2;
  817. ResetLetterBits(tr,0x18);
  818. SetLetterBits(tr,4,"kpst"); // Letter group F
  819. SetLetterBits(tr,3,"jvr"); // Letter group H
  820. tr->letter_groups[1] = is_lettergroup_B;
  821. SetLetterVowel(tr,'y');
  822. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SINGLE_AND | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_1900;
  823. tr->langopts.numbers2 = 0x2;
  824. }
  825. break;
  826. case L('i','t'): // Italian
  827. {
  828. static const short stress_lengths_it[8] = {150, 140, 170, 170, 0, 0, 300, 330};
  829. static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,22, 22,20 };
  830. SetupTranslator(tr,stress_lengths_it,stress_amps_it);
  831. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  832. tr->langopts.stress_rule = STRESSPOSN_2R;
  833. tr->langopts.stress_flags = 0x10 | 0x20000;
  834. tr->langopts.vowel_pause = 1;
  835. tr->langopts.unstressed_wd1 = 2;
  836. tr->langopts.unstressed_wd2 = 2;
  837. tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
  838. tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
  839. tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
  840. tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
  841. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  842. tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_ROMAN | NUM_DFRACTION_1;
  843. tr->langopts.accents = 2; // Say "Capital" after the letter.
  844. SetLetterVowel(tr,'y');
  845. }
  846. break;
  847. case L_jbo: // Lojban
  848. {
  849. static const short stress_lengths_jbo[8] = {145,145, 170,160, 0,0, 330,350};
  850. static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker (from LOPT_CAPS_IN_WORD)
  851. SetupTranslator(tr,stress_lengths_jbo,NULL);
  852. tr->langopts.stress_rule = STRESSPOSN_2R;
  853. tr->langopts.vowel_pause = 0x20c; // pause before a word which starts with a vowel, or after a word which ends in a consonant
  854. // tr->langopts.word_gap = 1;
  855. tr->punct_within_word = jbo_punct_within_word;
  856. tr->langopts.param[LOPT_CAPS_IN_WORD] = 2; // capitals indicate stressed syllables
  857. SetLetterVowel(tr,'y');
  858. tr->langopts.max_lengthmod = 368;
  859. }
  860. break;
  861. case L('k','a'): // Georgian
  862. {
  863. // character codes offset by 0x1080
  864. static const char ka_vowels[] = {0x50,0x54,0x58,0x5d,0x63,0x75,0x77,0};
  865. static const char ka_consonants[] = {0x51,0x52,0x53,0x55,0x56,0x57,0x59,0x5a,0x5b,0x5c,0x5e,0x5f,0x60,0x61,0x62,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x76,0};
  866. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  867. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  868. SetLetterBits(tr,LETTERGP_A,ka_vowels);
  869. SetLetterBits(tr,LETTERGP_C,ka_consonants);
  870. SetLetterBits(tr,LETTERGP_VOWEL2,ka_vowels);
  871. tr->langopts.stress_rule = STRESSPOSN_1L;
  872. tr->langopts.stress_flags = S_FINAL_NO_2;
  873. tr->letter_bits_offset = OFFSET_GEORGIAN;
  874. // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  875. tr->langopts.max_initial_consonants = 7;
  876. tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
  877. }
  878. break;
  879. case L('k','k'): // Kazakh
  880. {
  881. static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
  882. static const short stress_lengths_tr[8] = {190,180, 230,230, 0,0, 250,250};
  883. tr->letter_bits_offset = OFFSET_CYRILLIC;
  884. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  885. SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
  886. SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
  887. SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
  888. SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
  889. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  890. tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; //no automatic secondary stress, don't lengthen at end-of-clause
  891. tr->langopts.lengthen_tonic = 0;
  892. tr->langopts.param[LOPT_SUFFIX] = 1;
  893. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_6 ;
  894. tr->langopts.max_initial_consonants = 2;
  895. SetLengthMods(tr,3); // all equal
  896. }
  897. break;
  898. case L('k','l'): // Greenlandic
  899. {
  900. tr->langopts.stress_rule = 12;
  901. tr->langopts.stress_flags = S_NO_AUTO_2;
  902. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
  903. }
  904. break;
  905. case L('k','o'): // Korean, TEST
  906. {
  907. static const char ko_ivowels[] = {0x63,0x64,0x67,0x68,0x6d,0x72,0x74,0x75,0}; // y and i vowels
  908. static const unsigned char ko_voiced[] = {0x02,0x05,0x06,0xab,0xaf,0xb7,0xbc,0}; // voiced consonants, l,m,n,N
  909. tr->letter_bits_offset = OFFSET_KOREAN;
  910. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  911. SetLetterBitsRange(tr,LETTERGP_A,0x61,0x75);
  912. SetLetterBits(tr,LETTERGP_Y,ko_ivowels);
  913. SetLetterBits(tr,LETTERGP_G,(const char *)ko_voiced);
  914. tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
  915. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  916. tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
  917. tr->langopts.numbers2 = NUM2_MYRIADS;
  918. tr->langopts.break_numbers = 0x1111110;
  919. tr->langopts.max_digits = 20;
  920. }
  921. break;
  922. case L('k','u'): // Kurdish
  923. {
  924. static const unsigned char stress_amps_ku[8] = {18,18, 20,20, 20,22, 22,21 };
  925. static const short stress_lengths_ku[8] = {180,180, 190,180, 0,0, 230,240};
  926. SetupTranslator(tr,stress_lengths_ku,stress_amps_ku);
  927. tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
  928. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  929. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED;
  930. tr->langopts.max_initial_consonants = 2;
  931. }
  932. break;
  933. case L('l','a'): //Latin
  934. {
  935. tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
  936. tr->langopts.stress_rule = STRESSPOSN_2R;
  937. tr->langopts.stress_flags = 0x20;
  938. tr->langopts.unstressed_wd1 = 0;
  939. tr->langopts.unstressed_wd2 = 2;
  940. tr->langopts.param[LOPT_DIERESES] = 1;
  941. tr->langopts.numbers = NUM_ROMAN;
  942. tr->langopts.max_roman = 5000;
  943. }
  944. break;
  945. case L('l','t'): // Lithuanian
  946. {
  947. tr->charset_a0 = charsets[4]; // ISO-8859-4
  948. tr->langopts.stress_rule = STRESSPOSN_2R;
  949. tr->langopts.stress_flags = 0x20;
  950. tr->langopts.unstressed_wd1 = 0;
  951. tr->langopts.unstressed_wd2 = 2;
  952. tr->langopts.param[LOPT_DIERESES] = 1;
  953. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  954. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
  955. tr->langopts.max_roman = 5000;
  956. }
  957. break;
  958. case L('l','v'): // latvian
  959. {
  960. static const unsigned char stress_amps_lv[8] = {17,13, 20,20, 20,22, 22,21 };
  961. static const short stress_lengths_lv[8] = {180,130, 210,210, 0,0, 210,210};
  962. SetupTranslator(tr,stress_lengths_lv,stress_amps_lv);
  963. tr->langopts.stress_rule = STRESSPOSN_1L;
  964. tr->langopts.spelling_stress = 1;
  965. tr->charset_a0 = charsets[4]; // ISO-8859-4
  966. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
  967. tr->langopts.stress_flags = 0x16 + 0x40000;
  968. }
  969. break;
  970. case L('m','k'): // Macedonian
  971. {
  972. static wchar_t vowels_cyrillic[] = {0x440, // also include 'р' [R]
  973. 0x430,0x435,0x438,0x439,0x43e,0x443,0x44b,0x44d,0x44e,0x44f,0x450,0x451,0x456,0x457,0x45d,0x45e,0};
  974. static const unsigned char stress_amps_mk[8] = {17,17, 20,20, 20,22, 22,21 };
  975. static const short stress_lengths_mk[8] = {180,160, 200,200, 0,0, 220,230};
  976. SetupTranslator(tr,stress_lengths_mk,stress_amps_mk);
  977. tr->charset_a0 = charsets[5]; // ISO-8859-5
  978. tr->letter_groups[0] = tr->letter_groups[7] = vowels_cyrillic;
  979. tr->langopts.stress_rule = STRESSPOSN_3R; // antipenultimate
  980. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  981. tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
  982. }
  983. break;
  984. case L('m','t'): // Maltese
  985. {
  986. tr->charset_a0 = charsets[3]; // ISO-8859-3
  987. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  988. tr->langopts.stress_rule = STRESSPOSN_2R; // penultimate
  989. tr->langopts.numbers = 1;
  990. }
  991. break;
  992. case L('n','l'): // Dutch
  993. {
  994. static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280};
  995. tr->langopts.stress_rule = STRESSPOSN_1L;
  996. tr->langopts.vowel_pause = 0x30; // ??
  997. tr->langopts.param[LOPT_DIERESES] = 1;
  998. tr->langopts.param[LOPT_PREFIXES] = 1;
  999. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
  1000. SetLetterVowel(tr,'y');
  1001. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  1002. tr->langopts.ordinal_indicator = "e";
  1003. tr->langopts.stress_flags = S_FIRST_PRIMARY;
  1004. memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
  1005. }
  1006. break;
  1007. case L('n','o'): // Norwegian
  1008. {
  1009. static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,230};
  1010. SetupTranslator(tr,stress_lengths_no,NULL);
  1011. tr->langopts.stress_rule = STRESSPOSN_1L;
  1012. SetLetterVowel(tr,'y');
  1013. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
  1014. }
  1015. break;
  1016. case L('o','m'):
  1017. {
  1018. static const unsigned char stress_amps_om[] = {18,15, 20,20, 20,22, 22,22 };
  1019. static const short stress_lengths_om[8] = {200,200, 200,200, 0,0, 200,200};
  1020. SetupTranslator(tr,stress_lengths_om,stress_amps_om);
  1021. tr->langopts.stress_rule = STRESSPOSN_2R;
  1022. tr->langopts.stress_flags = 0x16 + 0x80000;
  1023. }
  1024. break;
  1025. case L('p','l'): // Polish
  1026. {
  1027. static const short stress_lengths_pl[8] = {160, 190, 175, 175, 0, 0, 200, 210};
  1028. static const unsigned char stress_amps_pl[8] = {17,13, 19,19, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  1029. SetupTranslator(tr,stress_lengths_pl,stress_amps_pl);
  1030. tr->charset_a0 = charsets[2]; // ISO-8859-2
  1031. tr->langopts.stress_rule = STRESSPOSN_2R;
  1032. tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
  1033. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
  1034. tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
  1035. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
  1036. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
  1037. tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
  1038. SetLetterVowel(tr,'y');
  1039. }
  1040. break;
  1041. case L('p','t'): // Portuguese
  1042. {
  1043. static const short stress_lengths_pt[8] = {170, 115, 210, 240, 0, 0, 260, 280};
  1044. static const unsigned char stress_amps_pt[8] = {16,11, 19,21, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
  1045. SetupTranslator(tr,stress_lengths_pt,stress_amps_pt);
  1046. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1047. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  1048. tr->langopts.stress_flags = 0x6 | 0x10 | 0x2000 | 0x20000;
  1049. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
  1050. tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS;
  1051. SetLetterVowel(tr,'y');
  1052. ResetLetterBits(tr,0x2);
  1053. SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
  1054. tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
  1055. }
  1056. break;
  1057. case L('r','o'): // Romanian
  1058. {
  1059. static const short stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260};
  1060. static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,21 };
  1061. SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
  1062. tr->langopts.stress_rule = STRESSPOSN_2R;
  1063. tr->langopts.stress_flags = 0x100 + 0x6;
  1064. tr->charset_a0 = charsets[2]; // ISO-8859-2
  1065. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_3 | NUM_AND_UNITS | NUM_ROMAN;
  1066. tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
  1067. }
  1068. break;
  1069. case L('r','u'): // Russian
  1070. Translator_Russian(tr);
  1071. break;
  1072. case L('r','w'): // Kiryarwanda
  1073. {
  1074. tr->langopts.stress_rule = STRESSPOSN_2R;
  1075. tr->langopts.stress_flags = 0x16;
  1076. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1077. tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_2 | NUM_AND_HUNDRED;
  1078. tr->langopts.numbers2 = 0x200; // say "thousands" before its number
  1079. }
  1080. break;
  1081. case L('s','k'): // Slovak
  1082. case L('c','s'): // Czech
  1083. {
  1084. static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
  1085. SetupTranslator(tr,stress_lengths_sk,stress_amps_sk);
  1086. tr->charset_a0 = charsets[2]; // ISO-8859-2
  1087. tr->langopts.stress_rule = STRESSPOSN_1L;
  1088. tr->langopts.stress_flags = 0x16;
  1089. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
  1090. tr->langopts.max_initial_consonants = 5;
  1091. tr->langopts.spelling_stress = 1;
  1092. tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
  1093. tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
  1094. tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
  1095. tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator
  1096. tr->langopts.decimal_sep = ',';
  1097. if(name2 == L('c','s'))
  1098. {
  1099. tr->langopts.numbers2 = 0x108; // variant numbers before milliards
  1100. }
  1101. SetLetterVowel(tr,'y');
  1102. SetLetterVowel(tr,'r');
  1103. ResetLetterBits(tr,0x20);
  1104. SetLetterBits(tr,5,sk_voiced);
  1105. }
  1106. break;
  1107. case L('s','i'): // Sinhala
  1108. {
  1109. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  1110. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1111. tr->langopts.stress_rule = STRESSPOSN_1L;
  1112. tr->langopts.stress_flags = S_FINAL_DIM | S_NO_AUTO_DIM | S_FINAL_NO_2;
  1113. tr->langopts.spelling_stress = 1;
  1114. tr->letter_bits_offset = OFFSET_SINHALA;
  1115. memset(tr->letter_bits,0,sizeof(tr->letter_bits));
  1116. SetLetterBitsRange(tr,LETTERGP_A,0x05,0x16); // vowel letters
  1117. SetLetterBitsRange(tr,LETTERGP_A,0x4a,0x73); // + vowel signs, and virama
  1118. SetLetterBitsRange(tr,LETTERGP_B,0x4a,0x73); // vowel signs, and virama
  1119. SetLetterBitsRange(tr,LETTERGP_C,0x1a,0x46); // the main consonant range
  1120. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1121. tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4a; //virama
  1122. tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS_L | NUM_DFRACTION_7;
  1123. tr->langopts.numbers2 = NUM2_PERCENT_BEFORE;
  1124. tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  1125. }
  1126. break;
  1127. case L('s','l'): // Slovenian
  1128. tr->charset_a0 = charsets[2]; // ISO-8859-2
  1129. tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
  1130. tr->langopts.stress_flags = 0x20;
  1131. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
  1132. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x76; // [v] don't count this character at start of word
  1133. tr->letter_bits['r'] |= 0x80; // add 'r' to letter group 7, vowels for Unpronouncable test
  1134. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ORDINAL_DOT | NUM_ROMAN;
  1135. tr->langopts.numbers2 = 0x100; // plural forms of millions etc
  1136. tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
  1137. break;
  1138. case L('s','q'): // Albanian
  1139. {
  1140. static const short stress_lengths_sq[8] = {150, 150, 180, 180, 0, 0, 300, 300};
  1141. static const unsigned char stress_amps_sq[8] = {16,12, 16,16, 20,20, 21,19 };
  1142. SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
  1143. tr->langopts.stress_rule = STRESSPOSN_2R;
  1144. tr->langopts.stress_flags = 0x16 + 0x100;
  1145. SetLetterVowel(tr,'y');
  1146. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_4;
  1147. tr->langopts.accents = 2; // "capital" after letter name
  1148. }
  1149. break;
  1150. case L('s','v'): // Swedish
  1151. {
  1152. static const unsigned char stress_amps_sv[] = {16,16, 20,20, 20,22, 22,21 };
  1153. static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280};
  1154. SetupTranslator(tr,stress_lengths_sv,stress_amps_sv);
  1155. tr->langopts.stress_rule = STRESSPOSN_1L;
  1156. SetLetterVowel(tr,'y');
  1157. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_1900;
  1158. tr->langopts.accents = 1;
  1159. }
  1160. break;
  1161. case L('s','w'): // Swahili
  1162. case L('t','n'): // Setswana
  1163. {
  1164. static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340};
  1165. static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,22, 22,21 };
  1166. SetupTranslator(tr,stress_lengths_sw,stress_amps_sw);
  1167. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1168. tr->langopts.vowel_pause = 1;
  1169. tr->langopts.stress_rule = STRESSPOSN_2R;
  1170. tr->langopts.stress_flags = 0x6 | 0x10;
  1171. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_OMIT_1_HUNDRED;
  1172. tr->langopts.break_numbers = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
  1173. }
  1174. break;
  1175. case L('t','a'): // Tamil
  1176. case L('m','l'): // Malayalam
  1177. case L('k','n'): // Kannada
  1178. case L('m','r'): // Marathi
  1179. case L('t','e'): // Telugu
  1180. {
  1181. SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
  1182. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1183. tr->langopts.stress_rule = STRESSPOSN_1L;
  1184. tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
  1185. tr->langopts.spelling_stress = 1;
  1186. tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
  1187. if(name2 == L('t','a'))
  1188. {
  1189. tr->letter_bits_offset = OFFSET_TAMIL;
  1190. tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
  1191. }
  1192. if(name2 == L('m','r'))
  1193. {
  1194. tr->letter_bits_offset = OFFSET_DEVANAGARI;
  1195. }
  1196. else
  1197. if(name2 == L('m','l'))
  1198. {
  1199. tr->letter_bits_offset = OFFSET_MALAYALAM;
  1200. tr->langopts.numbers = NUM_OMIT_1_THOUSAND;
  1201. }
  1202. else
  1203. if(name2 == L('k','n'))
  1204. {
  1205. tr->letter_bits_offset = OFFSET_KANNADA;
  1206. tr->langopts.numbers = 0x1;
  1207. }
  1208. else
  1209. if(name2 == L('t','e'))
  1210. {
  1211. tr->letter_bits_offset = OFFSET_TELUGU;
  1212. tr->langopts.numbers = 0x1;
  1213. }
  1214. tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
  1215. SetIndicLetters(tr); // call this after setting OFFSET_
  1216. SetLetterBitsRange(tr,LETTERGP_B,0x4e,0x4e); // chillu-virama (unofficial)
  1217. }
  1218. break;
  1219. #ifdef deleted
  1220. case L('t','h'): // Thai
  1221. {
  1222. static const short stress_lengths_th[8] = {230,150, 230,230, 230,0, 230,250};
  1223. static const unsigned char stress_amps_th[] = {22,16, 22,22, 22,22, 22,22 };
  1224. SetupTranslator(tr,stress_lengths_th,stress_amps_th);
  1225. tr->langopts.stress_rule = 0; // stress on final syllable of a "word"
  1226. tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
  1227. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1228. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1229. // tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  1230. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1231. }
  1232. break;
  1233. #endif
  1234. case L('t','r'): // Turkish
  1235. case L('a','z'): // Azerbaijan
  1236. {
  1237. static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
  1238. static const short stress_lengths_tr[8] = {190,180, 200,230, 0,0, 240,250};
  1239. SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
  1240. tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
  1241. tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
  1242. tr->langopts.stress_flags = 0x20; //no automatic secondary stress
  1243. tr->langopts.param[LOPT_SUFFIX] = 1;
  1244. if(name2 == L('a','z'))
  1245. {
  1246. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1247. }
  1248. else
  1249. {
  1250. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
  1251. }
  1252. tr->langopts.max_initial_consonants = 2;
  1253. }
  1254. break;
  1255. case L('t','t'): // Tatar
  1256. {
  1257. SetCyrillicLetters(tr);
  1258. SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
  1259. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
  1260. tr->langopts.stress_flags = 0x20; //no automatic secondary stress
  1261. tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
  1262. }
  1263. break;
  1264. case L('u','k'): // Ukrainian
  1265. {
  1266. SetCyrillicLetters(tr);
  1267. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  1268. }
  1269. break;
  1270. case L('u','r'): // Urdu
  1271. tr->letter_bits_offset = OFFSET_ARABIC;
  1272. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1273. tr->langopts.numbers = NUM_SWAP_TENS;
  1274. tr->langopts.break_numbers = 0x52a8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
  1275. break;
  1276. case L('v','i'): // Vietnamese
  1277. {
  1278. static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 230, 230, 240};
  1279. static const unsigned char stress_amps_vi[] = {16,16, 16,16, 22,22, 22,22 };
  1280. static wchar_t vowels_vi[] = {
  1281. 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a
  1282. 0x103, 0x1eb1, 0x1eaf, 0x1eb3, 0x1eb5, 0x1eb7, // ă
  1283. 0xe2, 0x1ea7, 0x1ea5, 0x1ea9, 0x1eab, 0x1ead, // â
  1284. 0x65, 0xe8, 0xe9, 0x1ebb, 0x1ebd, 0x1eb9, // e
  1285. 0xea, 0x1ec1, 0x1ebf, 0x1ec3, 0x1ec5, 0x1ec7, // i
  1286. 0x69, 0xec, 0xed, 0x1ec9, 0x129, 0x1ecb, // i
  1287. 0x6f, 0xf2, 0xf3, 0x1ecf, 0xf5, 0x1ecd, // o
  1288. 0xf4, 0x1ed3, 0x1ed1, 0x1ed5, 0x1ed7, 0x1ed9, // ô
  1289. 0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
  1290. 0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
  1291. 0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
  1292. 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
  1293. SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
  1294. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1295. tr->langopts.stress_rule = STRESSPOSN_1L;
  1296. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1297. // tr->langopts.vowel_pause = 4;
  1298. tr->letter_groups[0] = tr->letter_groups[7] = vowels_vi;
  1299. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1300. tr->langopts.unstressed_wd1 = 2;
  1301. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND_DIGIT | NUM_DFRACTION_4 | NUM_ZERO_HUNDRED;
  1302. }
  1303. break;
  1304. case L('w','o'):
  1305. tr->langopts.stress_rule = STRESSPOSN_1L;
  1306. tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS;
  1307. break;
  1308. case L('z','h'):
  1309. case L_zhy:
  1310. {
  1311. static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 240,250}; // 1=tone5. end-of-sentence, 6=tone 1&4, 7=tone 2&3
  1312. static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 };
  1313. SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
  1314. tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable of a "word"
  1315. tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
  1316. tr->langopts.vowel_pause = 0;
  1317. tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
  1318. tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
  1319. tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
  1320. tr->langopts.ideographs = 1;
  1321. tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
  1322. if(name2 == L('z','h'))
  1323. {
  1324. tr->langopts.textmode = 1;
  1325. tr->langopts.listx = 1; // compile zh_listx after zh_list
  1326. }
  1327. }
  1328. break;
  1329. default:
  1330. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
  1331. break;
  1332. }
  1333. tr->translator_name = name2;
  1334. if(tr->langopts.numbers & NUM_DECIMAL_COMMA)
  1335. {
  1336. // use . and ; for thousands and decimal separators
  1337. tr->langopts.thousands_sep = '.';
  1338. tr->langopts.decimal_sep = ',';
  1339. }
  1340. if(tr->langopts.numbers & NUM_THOUS_SPACE)
  1341. {
  1342. tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
  1343. }
  1344. return(tr);
  1345. } // end of SelectTranslator
  1346. //**********************************************************************************************************
  1347. static void Translator_Russian(Translator *tr)
  1348. {//===========================================
  1349. static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 };
  1350. static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280};
  1351. static const char ru_ivowels2[] = {0x2c,0x15,0x18,0x2e,0x2f,0}; // add more vowels to letter group Y (iotated vowels & soft-sign)
  1352. SetupTranslator(tr,stress_lengths_ru,stress_amps_ru);
  1353. SetCyrillicLetters(tr);
  1354. SetLetterBits(tr,6,ru_ivowels2);
  1355. tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
  1356. tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
  1357. tr->langopts.param[LOPT_REDUCE] = 2;
  1358. tr->langopts.stress_rule = 5;
  1359. tr->langopts.stress_flags = 0x0020; // waas 0x1010
  1360. tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
  1361. tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
  1362. tr->langopts.phoneme_change = 1;
  1363. tr->langopts.testing = 2;
  1364. } // end of Translator_Russian
  1365. /*
  1366. typedef struct {
  1367. int flags;
  1368. unsigned char stress; // stress level of this vowel
  1369. unsigned char stress_highest; // the highest stress level of a vowel in this word
  1370. unsigned char n_vowels; // number of vowels in the word
  1371. unsigned char vowel_this; // syllable number of this vowel (counting from 1)
  1372. unsigned char vowel_stressed; // syllable number of the highest stressed vowel
  1373. } CHANGEPH;
  1374. */
  1375. #ifdef RUSSIAN2
  1376. // This is now done in the phoneme data, ph_russian
  1377. int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
  1378. {//=============================================================================================================
  1379. // Called for each phoneme in the phoneme list, to allow a language to make changes
  1380. // ph The current phoneme
  1381. int variant;
  1382. int vowelix;
  1383. PHONEME_TAB *prev, *next;
  1384. if(ch->flags & 8)
  1385. return(0); // full phoneme translation has already been given
  1386. // Russian vowel softening and reduction rules
  1387. if(ph->type == phVOWEL)
  1388. {
  1389. int prestressed = ch->vowel_stressed==ch->vowel_this+1; // the next vowel after this has the main stress
  1390. #define N_VOWELS_RU 11
  1391. static unsigned int vowels_ru[N_VOWELS_RU] = {'a','V','O','I',PH('I','#'),PH('E','#'),PH('E','2'),
  1392. PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
  1393. static unsigned int vowel_replace[N_VOWELS_RU][6] = {
  1394. // stressed, soft, soft-stressed, j+stressed, j+soft, j+soft-stressed
  1395. /*0*/ {'A', 'I', PH('j','a'), 'a', 'a', 'a'}, // a Uses 3,4,5 columns.
  1396. /*1*/ {'A', 'V', PH('j','a'), 'a', 'V', 'a'}, // V Uses 3,4,5 columns.
  1397. /*2*/ {'o', '8', '8', 'o', '8', '8'}, // O
  1398. /*3*/ {'i', 'I', 'i', 'a', 'I', 'a'}, // I Uses 3,4,5 columns.
  1399. /*4*/ {'i', PH('I','#'), 'i', 'i', PH('I','#'), 'i'}, // I#
  1400. /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
  1401. /*6*/ {'E', PH('E','2'), 'E', 'e', PH('E','2'), 'e'}, // E2 Uses 3,4,5 columns.
  1402. /*7*/ {PH('j','a'), 'V', PH('j','a'), 'A', 'V', 'A'}, // V#
  1403. /*8*/ {PH('j','a'), 'I', PH('j','a'), 'e', 'I', 'e'}, // I3 Uses 3,4,5 columns.
  1404. /*9*/ {'e', 'I', 'e', 'e', 'I', 'e'}, // I2
  1405. /*10*/ {'e', PH('E', '2'), 'e', 'e', PH('E','2'), 'e'} // E3
  1406. };
  1407. prev = phoneme_tab[phlist[index-1].phcode];
  1408. next = phoneme_tab[phlist[index+1].phcode];
  1409. // lookup the vowel name to get an index into the vowel_replace[] table
  1410. for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
  1411. {
  1412. if(vowels_ru[vowelix] == ph->mnemonic)
  1413. break;
  1414. }
  1415. if(vowelix == N_VOWELS_RU)
  1416. return(0);
  1417. if(prestressed)
  1418. {
  1419. if((vowelix==6)&&(prev->mnemonic=='j'))
  1420. vowelix=8;
  1421. if(vowelix==1)
  1422. vowelix=0;
  1423. if(vowelix==4)
  1424. vowelix=3;
  1425. if(vowelix==6)
  1426. vowelix=5;
  1427. if(vowelix==7)
  1428. vowelix=8;
  1429. if(vowelix==10)
  1430. vowelix=9;
  1431. }
  1432. // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
  1433. variant = -1;
  1434. int stressed = ch->flags & 2;
  1435. int soft=prev->phflags & phPALATAL;
  1436. if (soft && stressed)
  1437. variant = 2; else
  1438. if (stressed)
  1439. variant = 0; else
  1440. if (soft)
  1441. variant = 1;
  1442. if(variant >= 0)
  1443. {
  1444. if(prev->mnemonic == 'j')
  1445. variant += 3;
  1446. phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
  1447. }
  1448. else
  1449. {
  1450. phlist[index].phcode = PhonemeCode(vowels_ru[vowelix]);
  1451. }
  1452. }
  1453. return(0);
  1454. }
  1455. #endif