eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tr_languages.cpp 71KB

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