The #defines should be renamed to better convey their meaning.master
| @@ -1118,12 +1118,12 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| switch (tr->langopts.stress_rule) | |||
| { | |||
| case 8: | |||
| case STRESSPOSN_2LLH: | |||
| // stress on first syllable, unless it is a light syllable followed by a heavy syllable | |||
| if ((syllable_weight[1] > 0) || (syllable_weight[2] == 0)) | |||
| break; | |||
| // fallthrough: | |||
| case 1: | |||
| case STRESSPOSN_2L: | |||
| // stress on second syllable | |||
| if ((stressed_syllable == 0) && (vowel_count > 2)) { | |||
| stressed_syllable = 2; | |||
| @@ -1141,7 +1141,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| } | |||
| } | |||
| // fallthrough: | |||
| case 2: | |||
| case STRESSPOSN_2R: | |||
| // a language with stress on penultimate vowel | |||
| if (stressed_syllable == 0) { | |||
| @@ -1195,7 +1195,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| } | |||
| } | |||
| break; | |||
| case 3: | |||
| case STRESSPOSN_1R: | |||
| // stress on last vowel | |||
| if (stressed_syllable == 0) { | |||
| // no explicit stress - stress the final vowel | |||
| @@ -1212,7 +1212,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 4: // stress on antipenultimate vowel | |||
| case STRESSPOSN_3R: // stress on antipenultimate vowel | |||
| if (stressed_syllable == 0) { | |||
| stressed_syllable = vowel_count - 3; | |||
| if (stressed_syllable < 1) | |||
| @@ -1223,7 +1223,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 5: | |||
| case STRESSPOSN_SYLCOUNT: | |||
| // LANG=Russian | |||
| if (stressed_syllable == 0) { | |||
| // no explicit stress - guess the stress from the number of syllables | |||
| @@ -1244,7 +1244,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 6: // LANG=hi stress on the last heaviest syllable | |||
| case STRESSPOSN_1RH: // LANG=hi stress on the last heaviest syllable | |||
| if (stressed_syllable == 0) { | |||
| int wt; | |||
| int max_weight = -1; | |||
| @@ -1271,7 +1271,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 7: // LANG=tr, the last syllable for any vowel marked explicitly as unstressed | |||
| case STRESSPOSN_1RU : // LANG=tr, the last syllable for any vowel marked explicitly as unstressed | |||
| if (stressed_syllable == 0) { | |||
| stressed_syllable = vowel_count - 1; | |||
| for (ix = 1; ix < vowel_count; ix++) { | |||
| @@ -1284,13 +1284,13 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 9: // mark all as stressed | |||
| case STRESSPOSN_ALL: // mark all as stressed | |||
| for (ix = 1; ix < vowel_count; ix++) { | |||
| if (vowel_stress[ix] < STRESS_IS_DIMINISHED) | |||
| vowel_stress[ix] = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 12: // LANG=kl (Greenlandic) | |||
| case STRESSPOSN_GREENLANDIC: // LANG=kl (Greenlandic) | |||
| long_vowel = 0; | |||
| for (ix = 1; ix < vowel_count; ix++) { | |||
| if (vowel_stress[ix] == STRESS_IS_PRIMARY) | |||
| @@ -1318,7 +1318,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| break; | |||
| case 13: // LANG=ml, 1st unless 1st vowel is short and 2nd is long | |||
| case STRESSPOSN_1SL: // LANG=ml, 1st unless 1st vowel is short and 2nd is long | |||
| if (stressed_syllable == 0) { | |||
| stressed_syllable = 1; | |||
| if ((vowel_length[1] == 0) && (vowel_count > 2) && (vowel_length[2] > 0)) | |||
| @@ -1327,7 +1327,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, | |||
| max_stress = STRESS_IS_PRIMARY; | |||
| } | |||
| break; | |||
| case 15: // LANG=eu. If more than 2 syllables: primary stress in second syllable and secondary on last. | |||
| case STRESSPOSN_EU: // LANG=eu. If more than 2 syllables: primary stress in second syllable and secondary on last. | |||
| if ((stressed_syllable == 0) && (vowel_count > 2)) { | |||
| for (ix = 1; ix < vowel_count; ix++) { | |||
| vowel_stress[ix] = STRESS_IS_DIMINISHED; | |||
| @@ -868,7 +868,7 @@ Translator *SelectTranslator(const char *name) | |||
| tr->encoding = ESPEAKNG_ENCODING_ISCII; | |||
| tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable | |||
| tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable | |||
| tr->langopts.stress_rule = STRESSPOSN_1RH; // stress on last heaviest syllable, excluding final syllable | |||
| tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable | |||
| tr->langopts.numbers = NUM_SWAP_TENS; | |||
| tr->langopts.break_numbers = BREAK_LAKH_HI; | |||
| @@ -1103,7 +1103,7 @@ Translator *SelectTranslator(const char *name) | |||
| SetupTranslator(tr, stress_lengths_tr, stress_amps_tr); | |||
| tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.stress_rule = STRESSPOSN_1RU; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; // no automatic secondary stress, don't lengthen at end-of-clause | |||
| tr->langopts.lengthen_tonic = 0; | |||
| tr->langopts.param[LOPT_SUFFIX] = 1; | |||
| @@ -1116,7 +1116,7 @@ Translator *SelectTranslator(const char *name) | |||
| case L('k', 'l'): // Greenlandic | |||
| { | |||
| SetupTranslator(tr, stress_lengths_equal, stress_amps_equal); | |||
| tr->langopts.stress_rule = 12; | |||
| tr->langopts.stress_rule = STRESSPOSN_GREENLANDIC; | |||
| tr->langopts.stress_flags = S_NO_AUTO_2; | |||
| 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; | |||
| } | |||
| @@ -1133,7 +1133,7 @@ Translator *SelectTranslator(const char *name) | |||
| SetLetterBits(tr, LETTERGP_Y, ko_ivowels); | |||
| SetLetterBits(tr, LETTERGP_G, (const char *)ko_voiced); | |||
| tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable | |||
| tr->langopts.stress_rule = STRESSPOSN_2LLH; // ?? 1st syllable if it is heavy, else 2nd syllable | |||
| tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words | |||
| tr->langopts.numbers = NUM_OMIT_1_HUNDRED; | |||
| tr->langopts.numbers2 = NUM2_MYRIADS; | |||
| @@ -1149,7 +1149,7 @@ Translator *SelectTranslator(const char *name) | |||
| SetupTranslator(tr, stress_lengths_ku, stress_amps_ku); | |||
| tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9; | |||
| tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.stress_rule = STRESSPOSN_1RU; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED; | |||
| tr->langopts.max_initial_consonants = 2; | |||
| @@ -1488,7 +1488,7 @@ Translator *SelectTranslator(const char *name) | |||
| tr->letter_bits_offset = OFFSET_MALAYALAM; | |||
| tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_OMIT_1_HUNDRED; | |||
| tr->langopts.numbers2 = NUM2_OMIT_1_HUNDRED_ONLY; | |||
| tr->langopts.stress_rule = 13; // 1st syllable, unless 1st vowel is short and 2nd is long | |||
| tr->langopts.stress_rule = STRESSPOSN_1SL; // 1st syllable, unless 1st vowel is short and 2nd is long | |||
| } else if (name2 == L('k', 'n')) { | |||
| tr->letter_bits_offset = OFFSET_KANNADA; | |||
| tr->langopts.numbers = NUM_DEFAULT; | |||
| @@ -1510,7 +1510,7 @@ Translator *SelectTranslator(const char *name) | |||
| SetupTranslator(tr, stress_lengths_tr, stress_amps_tr); | |||
| tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9; | |||
| tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.stress_rule = STRESSPOSN_1RU; // stress on the last syllable, before any explicitly unstressed syllable | |||
| tr->langopts.stress_flags = S_NO_AUTO_2; // no automatic secondary stress | |||
| tr->langopts.dotless_i = 1; | |||
| tr->langopts.param[LOPT_SUFFIX] = 1; | |||
| @@ -1649,7 +1649,7 @@ static void Translator_Russian(Translator *tr) | |||
| tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word | |||
| tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1; | |||
| tr->langopts.param[LOPT_REDUCE] = 2; | |||
| tr->langopts.stress_rule = 5; | |||
| tr->langopts.stress_rule = STRESSPOSN_SYLCOUNT; | |||
| tr->langopts.stress_flags = S_NO_AUTO_2; | |||
| tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED; | |||
| @@ -364,6 +364,14 @@ typedef struct { | |||
| #define STRESSPOSN_2R 2 // penultimate | |||
| #define STRESSPOSN_1R 3 // final syllable | |||
| #define STRESSPOSN_3R 4 // antipenultimate | |||
| #define STRESSPOSN_SYLCOUNT 5 // stress depends on syllable count | |||
| #define STRESSPOSN_1RH 6 // last heaviest syllable, excluding final syllable | |||
| #define STRESSPOSN_1RU 7 // stress on the last syllable, before any explicitly unstressed syllable | |||
| #define STRESSPOSN_2LLH 8 // first syllable, unless it is a light syllable followed by a heavy syllable | |||
| #define STRESSPOSN_ALL 9 // mark all stressed | |||
| #define STRESSPOSN_GREENLANDIC 12 | |||
| #define STRESSPOSN_1SL 13 // 1st syllable, unless 1st vowel is short and 2nd is long | |||
| #define STRESSPOSN_EU 15 // If more than 2 syllables: primary stress in second syllable and secondary on last. | |||
| typedef struct { | |||
| // bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme) | |||
| @@ -372,7 +380,7 @@ typedef struct { | |||
| // bit5=length of a final vowel doesn't depend on the next phoneme | |||
| int word_gap; | |||
| int vowel_pause; | |||
| int stress_rule; // 1=first syllable, 2=penultimate, 3=last | |||
| int stress_rule; // see #defines for STRESSPOSN_* | |||
| #define S_NO_DIM 0x02 | |||
| #define S_FINAL_DIM 0x04 | |||