tr_languages.cpp 67 KB

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