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

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