The #defines should be renamed to better convey their meaning.master
switch (tr->langopts.stress_rule) | 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 | // stress on first syllable, unless it is a light syllable followed by a heavy syllable | ||||
if ((syllable_weight[1] > 0) || (syllable_weight[2] == 0)) | if ((syllable_weight[1] > 0) || (syllable_weight[2] == 0)) | ||||
break; | break; | ||||
// fallthrough: | // fallthrough: | ||||
case 1: | |||||
case STRESSPOSN_2L: | |||||
// stress on second syllable | // stress on second syllable | ||||
if ((stressed_syllable == 0) && (vowel_count > 2)) { | if ((stressed_syllable == 0) && (vowel_count > 2)) { | ||||
stressed_syllable = 2; | stressed_syllable = 2; | ||||
} | } | ||||
} | } | ||||
// fallthrough: | // fallthrough: | ||||
case 2: | |||||
case STRESSPOSN_2R: | |||||
// a language with stress on penultimate vowel | // a language with stress on penultimate vowel | ||||
if (stressed_syllable == 0) { | if (stressed_syllable == 0) { | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case 3: | |||||
case STRESSPOSN_1R: | |||||
// stress on last vowel | // stress on last vowel | ||||
if (stressed_syllable == 0) { | if (stressed_syllable == 0) { | ||||
// no explicit stress - stress the final vowel | // no explicit stress - stress the final vowel | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | break; | ||||
case 4: // stress on antipenultimate vowel | |||||
case STRESSPOSN_3R: // stress on antipenultimate vowel | |||||
if (stressed_syllable == 0) { | if (stressed_syllable == 0) { | ||||
stressed_syllable = vowel_count - 3; | stressed_syllable = vowel_count - 3; | ||||
if (stressed_syllable < 1) | if (stressed_syllable < 1) | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | break; | ||||
case 5: | |||||
case STRESSPOSN_SYLCOUNT: | |||||
// LANG=Russian | // LANG=Russian | ||||
if (stressed_syllable == 0) { | if (stressed_syllable == 0) { | ||||
// no explicit stress - guess the stress from the number of syllables | // no explicit stress - guess the stress from the number of syllables | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | 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) { | if (stressed_syllable == 0) { | ||||
int wt; | int wt; | ||||
int max_weight = -1; | int max_weight = -1; | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | 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) { | if (stressed_syllable == 0) { | ||||
stressed_syllable = vowel_count - 1; | stressed_syllable = vowel_count - 1; | ||||
for (ix = 1; ix < vowel_count; ix++) { | for (ix = 1; ix < vowel_count; ix++) { | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | break; | ||||
case 9: // mark all as stressed | |||||
case STRESSPOSN_ALL: // mark all as stressed | |||||
for (ix = 1; ix < vowel_count; ix++) { | for (ix = 1; ix < vowel_count; ix++) { | ||||
if (vowel_stress[ix] < STRESS_IS_DIMINISHED) | if (vowel_stress[ix] < STRESS_IS_DIMINISHED) | ||||
vowel_stress[ix] = STRESS_IS_PRIMARY; | vowel_stress[ix] = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | break; | ||||
case 12: // LANG=kl (Greenlandic) | |||||
case STRESSPOSN_GREENLANDIC: // LANG=kl (Greenlandic) | |||||
long_vowel = 0; | long_vowel = 0; | ||||
for (ix = 1; ix < vowel_count; ix++) { | for (ix = 1; ix < vowel_count; ix++) { | ||||
if (vowel_stress[ix] == STRESS_IS_PRIMARY) | if (vowel_stress[ix] == STRESS_IS_PRIMARY) | ||||
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; | vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
break; | 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) { | if (stressed_syllable == 0) { | ||||
stressed_syllable = 1; | stressed_syllable = 1; | ||||
if ((vowel_length[1] == 0) && (vowel_count > 2) && (vowel_length[2] > 0)) | if ((vowel_length[1] == 0) && (vowel_count > 2) && (vowel_length[2] > 0)) | ||||
max_stress = STRESS_IS_PRIMARY; | max_stress = STRESS_IS_PRIMARY; | ||||
} | } | ||||
break; | 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)) { | if ((stressed_syllable == 0) && (vowel_count > 2)) { | ||||
for (ix = 1; ix < vowel_count; ix++) { | for (ix = 1; ix < vowel_count; ix++) { | ||||
vowel_stress[ix] = STRESS_IS_DIMINISHED; | vowel_stress[ix] = STRESS_IS_DIMINISHED; |
tr->encoding = ESPEAKNG_ENCODING_ISCII; | tr->encoding = ESPEAKNG_ENCODING_ISCII; | ||||
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable | 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.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable | ||||
tr->langopts.numbers = NUM_SWAP_TENS; | tr->langopts.numbers = NUM_SWAP_TENS; | ||||
tr->langopts.break_numbers = BREAK_LAKH_HI; | tr->langopts.break_numbers = BREAK_LAKH_HI; | ||||
SetupTranslator(tr, stress_lengths_tr, stress_amps_tr); | 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.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.lengthen_tonic = 0; | ||||
tr->langopts.param[LOPT_SUFFIX] = 1; | tr->langopts.param[LOPT_SUFFIX] = 1; | ||||
case L('k', 'l'): // Greenlandic | case L('k', 'l'): // Greenlandic | ||||
{ | { | ||||
SetupTranslator(tr, stress_lengths_equal, stress_amps_equal); | 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.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; | 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; | ||||
} | } | ||||
SetLetterBits(tr, LETTERGP_Y, ko_ivowels); | SetLetterBits(tr, LETTERGP_Y, ko_ivowels); | ||||
SetLetterBits(tr, LETTERGP_G, (const char *)ko_voiced); | 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.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words | ||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED; | tr->langopts.numbers = NUM_OMIT_1_HUNDRED; | ||||
tr->langopts.numbers2 = NUM2_MYRIADS; | tr->langopts.numbers2 = NUM2_MYRIADS; | ||||
SetupTranslator(tr, stress_lengths_ku, stress_amps_ku); | SetupTranslator(tr, stress_lengths_ku, stress_amps_ku); | ||||
tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9; | 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.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED; | ||||
tr->langopts.max_initial_consonants = 2; | tr->langopts.max_initial_consonants = 2; | ||||
tr->letter_bits_offset = OFFSET_MALAYALAM; | tr->letter_bits_offset = OFFSET_MALAYALAM; | ||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_OMIT_1_HUNDRED; | tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_OMIT_1_HUNDRED; | ||||
tr->langopts.numbers2 = NUM2_OMIT_1_HUNDRED_ONLY; | 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')) { | } else if (name2 == L('k', 'n')) { | ||||
tr->letter_bits_offset = OFFSET_KANNADA; | tr->letter_bits_offset = OFFSET_KANNADA; | ||||
tr->langopts.numbers = NUM_DEFAULT; | tr->langopts.numbers = NUM_DEFAULT; | ||||
SetupTranslator(tr, stress_lengths_tr, stress_amps_tr); | SetupTranslator(tr, stress_lengths_tr, stress_amps_tr); | ||||
tr->encoding = ESPEAKNG_ENCODING_ISO_8859_9; | 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.stress_flags = S_NO_AUTO_2; // no automatic secondary stress | ||||
tr->langopts.dotless_i = 1; | tr->langopts.dotless_i = 1; | ||||
tr->langopts.param[LOPT_SUFFIX] = 1; | tr->langopts.param[LOPT_SUFFIX] = 1; | ||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word | 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_REGRESSIVE_VOICING] = 1; | ||||
tr->langopts.param[LOPT_REDUCE] = 2; | 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.stress_flags = S_NO_AUTO_2; | ||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED; | tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED; |
#define STRESSPOSN_2R 2 // penultimate | #define STRESSPOSN_2R 2 // penultimate | ||||
#define STRESSPOSN_1R 3 // final syllable | #define STRESSPOSN_1R 3 // final syllable | ||||
#define STRESSPOSN_3R 4 // antipenultimate | #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 { | typedef struct { | ||||
// bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme) | // bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme) | ||||
// bit5=length of a final vowel doesn't depend on the next phoneme | // bit5=length of a final vowel doesn't depend on the next phoneme | ||||
int word_gap; | int word_gap; | ||||
int vowel_pause; | 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_NO_DIM 0x02 | ||||
#define S_FINAL_DIM 0x04 | #define S_FINAL_DIM 0x04 |