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

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