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.c 69KB

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