|
|
@@ -584,11 +584,11 @@ const char *GetTranslatedPhonemeString(int phoneme_mode) |
|
|
|
if (plist->synthflags & SFLAG_SYLLABLE) { |
|
|
|
if ((stress = plist->stresslevel) > 1) { |
|
|
|
c = 0; |
|
|
|
if (stress > 5) stress = 5; |
|
|
|
if (stress > STRESS_IS_PRIORITY) stress = STRESS_IS_PRIORITY; |
|
|
|
|
|
|
|
if (use_ipa) { |
|
|
|
c = 0x2cc; // ipa, secondary stress |
|
|
|
if (stress > 3) |
|
|
|
if (stress > STRESS_IS_SECONDARY) |
|
|
|
c = 0x02c8; // ipa, primary stress |
|
|
|
} else |
|
|
|
c = stress_chars[stress]; |
|
|
@@ -853,7 +853,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * |
|
|
|
int stress = -1; |
|
|
|
int primary_posn = 0; |
|
|
|
|
|
|
|
vowel_stress[0] = 1; |
|
|
|
vowel_stress[0] = STRESS_IS_UNSTRESSED; |
|
|
|
while (((phcode = *phonemes++) != 0) && (count < (N_WORD_PHONEMES/2)-1)) { |
|
|
|
if ((ph = phoneme_tab[phcode]) == NULL) |
|
|
|
continue; |
|
|
@@ -864,20 +864,20 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * |
|
|
|
if (phcode == phonSTRESS_PREV) { |
|
|
|
// primary stress on preceeding vowel |
|
|
|
j = count - 1; |
|
|
|
while ((j > 0) && (*stressed_syllable == 0) && (vowel_stress[j] < 4)) { |
|
|
|
if ((vowel_stress[j] != 0) && (vowel_stress[j] != 1)) { |
|
|
|
while ((j > 0) && (*stressed_syllable == 0) && (vowel_stress[j] < STRESS_IS_PRIMARY)) { |
|
|
|
if ((vowel_stress[j] != STRESS_IS_DIMINISHED) && (vowel_stress[j] != STRESS_IS_UNSTRESSED)) { |
|
|
|
// don't promote a phoneme which must be unstressed |
|
|
|
vowel_stress[j] = 4; |
|
|
|
vowel_stress[j] = STRESS_IS_PRIMARY; |
|
|
|
|
|
|
|
if (max_stress < 4) { |
|
|
|
max_stress = 4; |
|
|
|
if (max_stress < STRESS_IS_PRIMARY) { |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
primary_posn = j; |
|
|
|
} |
|
|
|
|
|
|
|
/* reduce any preceding primary stress markers */ |
|
|
|
for (ix = 1; ix < j; ix++) { |
|
|
|
if (vowel_stress[ix] == 4) |
|
|
|
vowel_stress[ix] = 3; |
|
|
|
if (vowel_stress[ix] == STRESS_IS_PRIMARY) |
|
|
|
vowel_stress[ix] = STRESS_IS_SECONDARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@@ -896,13 +896,13 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * |
|
|
|
|
|
|
|
if ((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) { |
|
|
|
vowel_stress[count] = (char)stress; |
|
|
|
if ((stress >= 4) && (stress >= max_stress)) { |
|
|
|
if ((stress >= STRESS_IS_PRIMARY) && (stress >= max_stress)) { |
|
|
|
primary_posn = count; |
|
|
|
max_stress = stress; |
|
|
|
} |
|
|
|
|
|
|
|
if ((stress < 0) && (control & 1) && (ph->phflags & phUNSTRESSED)) |
|
|
|
vowel_stress[count] = 1; // weak vowel, must be unstressed |
|
|
|
vowel_stress[count] = STRESS_IS_UNSTRESSED; // weak vowel, must be unstressed |
|
|
|
|
|
|
|
count++; |
|
|
|
stress = -1; |
|
|
@@ -910,12 +910,12 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * |
|
|
|
// previous consonant phoneme is syllablic |
|
|
|
vowel_stress[count] = (char)stress; |
|
|
|
if ((stress == 0) && (control & 1)) |
|
|
|
vowel_stress[count++] = 1; // syllabic consonant, usually unstressed |
|
|
|
vowel_stress[count++] = STRESS_IS_UNSTRESSED; // syllabic consonant, usually unstressed |
|
|
|
} |
|
|
|
|
|
|
|
*ph_out++ = phcode; |
|
|
|
} |
|
|
|
vowel_stress[count] = 1; |
|
|
|
vowel_stress[count] = STRESS_IS_UNSTRESSED; |
|
|
|
*ph_out = 0; |
|
|
|
|
|
|
|
// has the position of the primary stress been specified by $1, $2, etc? |
|
|
@@ -923,27 +923,27 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char * |
|
|
|
if (*stressed_syllable >= count) |
|
|
|
*stressed_syllable = count-1; // the final syllable |
|
|
|
|
|
|
|
vowel_stress[*stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[*stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
primary_posn = *stressed_syllable; |
|
|
|
} |
|
|
|
|
|
|
|
if (max_stress == 5) { |
|
|
|
if (max_stress == STRESS_IS_PRIORITY) { |
|
|
|
// priority stress, replaces any other primary stress marker |
|
|
|
for (ix = 1; ix < count; ix++) { |
|
|
|
if (vowel_stress[ix] == 4) { |
|
|
|
if (vowel_stress[ix] == STRESS_IS_PRIMARY) { |
|
|
|
if (tr->langopts.stress_flags & S_PRIORITY_STRESS) |
|
|
|
vowel_stress[ix] = 1; |
|
|
|
vowel_stress[ix] = STRESS_IS_UNSTRESSED; |
|
|
|
else |
|
|
|
vowel_stress[ix] = 3; |
|
|
|
vowel_stress[ix] = STRESS_IS_SECONDARY; |
|
|
|
} |
|
|
|
|
|
|
|
if (vowel_stress[ix] == 5) { |
|
|
|
vowel_stress[ix] = 4; |
|
|
|
if (vowel_stress[ix] == STRESS_IS_PRIORITY) { |
|
|
|
vowel_stress[ix] = STRESS_IS_PRIMARY; |
|
|
|
primary_posn = ix; |
|
|
|
} |
|
|
|
} |
|
|
|
max_stress = 4; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
|
|
|
|
*stressed_syllable = primary_posn; |
|
|
@@ -969,7 +969,7 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress) |
|
|
|
strcpy((char *)phonetic, word); |
|
|
|
max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 0); |
|
|
|
|
|
|
|
if (new_stress >= 4) { |
|
|
|
if (new_stress >= STRESS_IS_PRIMARY) { |
|
|
|
// promote to primary stress |
|
|
|
for (ix = 1; ix < vowel_count; ix++) { |
|
|
|
if (vowel_stress[ix] >= max_stress) { |
|
|
@@ -990,7 +990,7 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress) |
|
|
|
p = phonetic; |
|
|
|
while (*p != 0) { |
|
|
|
if ((phoneme_tab[*p]->type == phVOWEL) && !(phoneme_tab[*p]->phflags & phNONSYLLABIC)) { |
|
|
|
if ((vowel_stress[ix] == 0) || (vowel_stress[ix] > 1)) |
|
|
|
if ((vowel_stress[ix] == STRESS_IS_DIMINISHED) || (vowel_stress[ix] > STRESS_IS_UNSTRESSED)) |
|
|
|
*word++ = stress_phonemes[(unsigned char)vowel_stress[ix]]; |
|
|
|
|
|
|
|
ix++; |
|
|
@@ -1028,13 +1028,11 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
int v_stress; |
|
|
|
int stressed_syllable; // position of stressed syllable |
|
|
|
int max_stress_posn; |
|
|
|
int unstressed_word = 0; |
|
|
|
char *max_output; |
|
|
|
int final_ph; |
|
|
|
int final_ph2; |
|
|
|
int mnem; |
|
|
|
int opt_length; |
|
|
|
int done; |
|
|
|
int stressflags; |
|
|
|
int dflags = 0; |
|
|
|
int first_primary; |
|
|
@@ -1047,13 +1045,6 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
static char consonant_types[16] = { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; |
|
|
|
|
|
|
|
/* stress numbers STRESS_BASE + |
|
|
|
0 diminished, unstressed within a word |
|
|
|
1 unstressed, weak |
|
|
|
2 |
|
|
|
3 secondary stress |
|
|
|
4 main stress */ |
|
|
|
|
|
|
|
stressflags = tr->langopts.stress_flags; |
|
|
|
|
|
|
|
if (dictionary_flags != NULL) |
|
|
@@ -1074,27 +1065,29 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
max_output = output + (N_WORD_PHONEMES-3); // check for overrun |
|
|
|
|
|
|
|
|
|
|
|
// any stress position marked in the xx_list dictionary ? |
|
|
|
bool unstressed_word = false; |
|
|
|
stressed_syllable = dflags & 0x7; |
|
|
|
if (dflags & 0x8) { |
|
|
|
// this indicates a word without a primary stress |
|
|
|
stressed_syllable = dflags & 0x3; |
|
|
|
unstressed_word = 1; |
|
|
|
unstressed_word = true; |
|
|
|
} |
|
|
|
|
|
|
|
max_stress = max_stress_input = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1); |
|
|
|
if ((max_stress < 0) && dictionary_flags) |
|
|
|
max_stress = 0; |
|
|
|
max_stress = STRESS_IS_DIMINISHED; |
|
|
|
|
|
|
|
// heavy or light syllables |
|
|
|
ix = 1; |
|
|
|
for (p = phonetic; *p != 0; p++) { |
|
|
|
if ((phoneme_tab[p[0]]->type == phVOWEL) && !(phoneme_tab[p[0]]->phflags & phNONSYLLABIC)) { |
|
|
|
int weight = 0; |
|
|
|
int lengthened = 0; |
|
|
|
bool lengthened = false; |
|
|
|
|
|
|
|
if (phoneme_tab[p[1]]->code == phonLENGTHEN) |
|
|
|
lengthened = 1; |
|
|
|
lengthened = true; |
|
|
|
|
|
|
|
if (lengthened || (phoneme_tab[p[0]]->phflags & phLONG)) { |
|
|
|
// long vowel, increase syllable weight |
|
|
@@ -1124,16 +1117,16 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
// stress on second syllable |
|
|
|
if ((stressed_syllable == 0) && (vowel_count > 2)) { |
|
|
|
stressed_syllable = 2; |
|
|
|
if (max_stress == 0) |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
if (max_stress == STRESS_IS_DIMINISHED) |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 10: // penultimate, but final if only 1 or 2 syllables |
|
|
|
if (stressed_syllable == 0) { |
|
|
|
if (vowel_count < 4) { |
|
|
|
vowel_stress[vowel_count - 1] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[vowel_count - 1] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@@ -1143,7 +1136,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
if (stressed_syllable == 0) { |
|
|
|
// no explicit stress - stress the penultimate vowel |
|
|
|
max_stress = 4; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
|
|
|
|
if (vowel_count > 2) { |
|
|
|
stressed_syllable = vowel_count - 2; |
|
|
@@ -1174,7 +1167,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
stressed_syllable = vowel_count - 1; |
|
|
|
} |
|
|
|
|
|
|
|
if ((vowel_stress[stressed_syllable] == 0) || (vowel_stress[stressed_syllable] == 1)) { |
|
|
|
if ((vowel_stress[stressed_syllable] == STRESS_IS_DIMINISHED) || (vowel_stress[stressed_syllable] == STRESS_IS_UNSTRESSED)) { |
|
|
|
// but this vowel is explicitly marked as unstressed |
|
|
|
if (stressed_syllable > 1) |
|
|
|
stressed_syllable--; |
|
|
@@ -1187,7 +1180,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
// only set the stress if it's not already marked explicitly |
|
|
|
if (vowel_stress[stressed_syllable] < 0) { |
|
|
|
// don't stress if next and prev syllables are stressed |
|
|
|
if ((vowel_stress[stressed_syllable-1] < 4) || (vowel_stress[stressed_syllable+1] < 4)) |
|
|
|
if ((vowel_stress[stressed_syllable-1] < STRESS_IS_PRIMARY) || (vowel_stress[stressed_syllable+1] < STRESS_IS_PRIMARY)) |
|
|
|
vowel_stress[stressed_syllable] = max_stress; |
|
|
|
} |
|
|
|
} |
|
|
@@ -1200,13 +1193,13 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
while (stressed_syllable > 0) { |
|
|
|
// find the last vowel which is not unstressed |
|
|
|
if (vowel_stress[stressed_syllable] < 0) { |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
if (vowel_stress[stressed_syllable] < STRESS_IS_DIMINISHED) { |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
break; |
|
|
|
} else |
|
|
|
stressed_syllable--; |
|
|
|
} |
|
|
|
max_stress = 4; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: // stress on antipenultimate vowel |
|
|
@@ -1215,9 +1208,9 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
if (stressed_syllable < 1) |
|
|
|
stressed_syllable = 1; |
|
|
|
|
|
|
|
if (max_stress == 0) |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
if (max_stress == STRESS_IS_DIMINISHED) |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
@@ -1237,8 +1230,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
else |
|
|
|
stressed_syllable = guess_ru[vowel_count]; |
|
|
|
} |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 6: // LANG=hi stress on the last heaviest syllable |
|
|
@@ -1248,7 +1241,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
// find the heaviest syllable, excluding the final syllable |
|
|
|
for (ix = 1; ix < (vowel_count-1); ix++) { |
|
|
|
if (vowel_stress[ix] < 0) { |
|
|
|
if (vowel_stress[ix] < STRESS_IS_DIMINISHED) { |
|
|
|
if ((wt = syllable_weight[ix]) >= max_weight) { |
|
|
|
max_weight = wt; |
|
|
|
stressed_syllable = ix; |
|
|
@@ -1264,38 +1257,38 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
stressed_syllable = 1; |
|
|
|
} |
|
|
|
|
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 7: // 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++) { |
|
|
|
if (vowel_stress[ix] == 1) { |
|
|
|
if (vowel_stress[ix] == STRESS_IS_UNSTRESSED) { |
|
|
|
stressed_syllable = ix-1; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 9: // mark all as stressed |
|
|
|
for (ix = 1; ix < vowel_count; ix++) { |
|
|
|
if (vowel_stress[ix] < 0) |
|
|
|
vowel_stress[ix] = 4; |
|
|
|
if (vowel_stress[ix] < STRESS_IS_DIMINISHED) |
|
|
|
vowel_stress[ix] = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
case 12: // LANG=kl (Greenlandic) |
|
|
|
long_vowel = 0; |
|
|
|
for (ix = 1; ix < vowel_count; ix++) { |
|
|
|
if (vowel_stress[ix] == 4) |
|
|
|
vowel_stress[ix] = 3; // change marked stress (consonant clusters) to secondary (except the last) |
|
|
|
if (vowel_stress[ix] == STRESS_IS_PRIMARY) |
|
|
|
vowel_stress[ix] = STRESS_IS_SECONDARY; // change marked stress (consonant clusters) to secondary (except the last) |
|
|
|
|
|
|
|
if (vowel_length[ix] > 0) { |
|
|
|
long_vowel = ix; |
|
|
|
vowel_stress[ix] = 3; // give secondary stress to all long vowels |
|
|
|
vowel_stress[ix] = STRESS_IS_SECONDARY; // give secondary stress to all long vowels |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -1312,68 +1305,68 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
stressed_syllable = vowel_count - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
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 |
|
|
|
if (stressed_syllable == 0) { |
|
|
|
stressed_syllable = 1; |
|
|
|
if ((vowel_length[1] == 0) && (vowel_count > 2) && (vowel_length[2] > 0)) |
|
|
|
stressed_syllable = 2; |
|
|
|
vowel_stress[stressed_syllable] = 4; |
|
|
|
max_stress = 4; |
|
|
|
vowel_stress[stressed_syllable] = STRESS_IS_PRIMARY; |
|
|
|
max_stress = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if ((stressflags & S_FINAL_VOWEL_UNSTRESSED) && ((control & 2) == 0) && (vowel_count > 2) && (max_stress_input < 3) && (vowel_stress[vowel_count - 1] == 4)) { |
|
|
|
if ((stressflags & S_FINAL_VOWEL_UNSTRESSED) && ((control & 2) == 0) && (vowel_count > 2) && (max_stress_input < STRESS_IS_SECONDARY) && (vowel_stress[vowel_count - 1] == STRESS_IS_PRIMARY)) { |
|
|
|
// Don't allow stress on a word-final vowel |
|
|
|
// Only do this if there is no suffix phonemes to be added, and if a stress position was not given explicitly |
|
|
|
if (phoneme_tab[final_ph]->type == phVOWEL) { |
|
|
|
vowel_stress[vowel_count - 1] = 1; |
|
|
|
vowel_stress[vowel_count - 2] = 4; |
|
|
|
vowel_stress[vowel_count - 1] = STRESS_IS_UNSTRESSED; |
|
|
|
vowel_stress[vowel_count - 2] = STRESS_IS_PRIMARY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// now guess the complete stress pattern |
|
|
|
if (max_stress < 4) |
|
|
|
stress = 4; // no primary stress marked, use for 1st syllable |
|
|
|
if (max_stress < STRESS_IS_PRIMARY) |
|
|
|
stress = STRESS_IS_PRIMARY; // no primary stress marked, use for 1st syllable |
|
|
|
else |
|
|
|
stress = 3; |
|
|
|
stress = STRESS_IS_SECONDARY; |
|
|
|
|
|
|
|
if (unstressed_word == 0) { |
|
|
|
if (unstressed_word == false) { |
|
|
|
if ((stressflags & S_2_SYL_2) && (vowel_count == 3)) { |
|
|
|
// Two syllable word, if one syllable has primary stress, then give the other secondary stress |
|
|
|
if (vowel_stress[1] == 4) |
|
|
|
vowel_stress[2] = 3; |
|
|
|
if (vowel_stress[2] == 4) |
|
|
|
vowel_stress[1] = 3; |
|
|
|
if (vowel_stress[1] == STRESS_IS_PRIMARY) |
|
|
|
vowel_stress[2] = STRESS_IS_SECONDARY; |
|
|
|
if (vowel_stress[2] == STRESS_IS_PRIMARY) |
|
|
|
vowel_stress[1] = STRESS_IS_SECONDARY; |
|
|
|
} |
|
|
|
|
|
|
|
if ((stressflags & S_INITIAL_2) && (vowel_stress[1] < 0)) { |
|
|
|
if ((stressflags & S_INITIAL_2) && (vowel_stress[1] < STRESS_IS_DIMINISHED)) { |
|
|
|
// If there is only one syllable before the primary stress, give it a secondary stress |
|
|
|
if ((vowel_count > 3) && (vowel_stress[2] >= 4)) |
|
|
|
vowel_stress[1] = 3; |
|
|
|
if ((vowel_count > 3) && (vowel_stress[2] >= STRESS_IS_PRIMARY)) |
|
|
|
vowel_stress[1] = STRESS_IS_SECONDARY; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
done = 0; |
|
|
|
bool done = false; |
|
|
|
first_primary = 0; |
|
|
|
for (v = 1; v < vowel_count; v++) { |
|
|
|
if (vowel_stress[v] < 0) { |
|
|
|
if ((stressflags & S_FINAL_NO_2) && (stress < 4) && (v == vowel_count-1)) { |
|
|
|
if (vowel_stress[v] < STRESS_IS_DIMINISHED) { |
|
|
|
if ((stressflags & S_FINAL_NO_2) && (stress < STRESS_IS_PRIMARY) && (v == vowel_count-1)) { |
|
|
|
// flag: don't give secondary stress to final vowel |
|
|
|
} else if ((stressflags & 0x8000) && (done == 0)) { |
|
|
|
} else if ((stressflags & 0x8000) && (done == false)) { |
|
|
|
vowel_stress[v] = (char)stress; |
|
|
|
done = 1; |
|
|
|
stress = 3; // use secondary stress for remaining syllables |
|
|
|
} else if ((vowel_stress[v-1] <= 1) && ((vowel_stress[v+1] <= 1) || ((stress == 4) && (vowel_stress[v+1] <= 2)))) { |
|
|
|
done = true; |
|
|
|
stress = STRESS_IS_SECONDARY; // use secondary stress for remaining syllables |
|
|
|
} else if ((vowel_stress[v-1] <= STRESS_IS_UNSTRESSED) && ((vowel_stress[v+1] <= STRESS_IS_UNSTRESSED) || ((stress == STRESS_IS_PRIMARY) && (vowel_stress[v+1] <= STRESS_IS_NOT_STRESSED)))) { |
|
|
|
// trochaic: give stress to vowel surrounded by unstressed vowels |
|
|
|
|
|
|
|
if ((stress == 3) && (stressflags & S_NO_AUTO_2)) |
|
|
|
if ((stress == STRESS_IS_SECONDARY) && (stressflags & S_NO_AUTO_2)) |
|
|
|
continue; // don't use secondary stress |
|
|
|
|
|
|
|
// don't put secondary stress on a light syllable if the rest of the word (excluding last syllable) contains a heavy syllable |
|
|
|
// don't put secondary stress on a light syllable if the rest of the word (excluding last syllable) contains a heavy syllable |
|
|
|
if ((v > 1) && (stressflags & S_2_TO_HEAVY) && (syllable_weight[v] == 0)) { |
|
|
|
bool skip = false; |
|
|
|
for (int i = v; i < vowel_count - 1; i++) { |
|
|
@@ -1394,17 +1387,17 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
// should start with secondary stress on the first syllable, or should it count back from |
|
|
|
// the primary stress and put secondary stress on alternate syllables? |
|
|
|
vowel_stress[v] = (char)stress; |
|
|
|
done = 1; |
|
|
|
stress = 3; // use secondary stress for remaining syllables |
|
|
|
done = true; |
|
|
|
stress = STRESS_IS_SECONDARY; // use secondary stress for remaining syllables |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (vowel_stress[v] >= 4) { |
|
|
|
if (vowel_stress[v] >= STRESS_IS_PRIMARY) { |
|
|
|
if (first_primary == 0) |
|
|
|
first_primary = v; |
|
|
|
else if (stressflags & S_FIRST_PRIMARY) { |
|
|
|
// reduce primary stresses after the first to secondary |
|
|
|
vowel_stress[v] = 3; |
|
|
|
vowel_stress[v] = STRESS_IS_SECONDARY; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -1416,7 +1409,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
tonic = tr->langopts.unstressed_wd2; // more than one syllable, used secondary stress as the main stress |
|
|
|
} |
|
|
|
|
|
|
|
max_stress = 0; |
|
|
|
max_stress = STRESS_IS_DIMINISHED; |
|
|
|
max_stress_posn = 0; |
|
|
|
for (v = 1; v < vowel_count; v++) { |
|
|
|
if (vowel_stress[v] >= max_stress) { |
|
|
@@ -1429,7 +1422,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
// find position of highest stress, and replace it by 'tonic' |
|
|
|
|
|
|
|
// don't disturb an explicitly set stress by 'unstress-at-end' flag |
|
|
|
if ((tonic > max_stress) || (max_stress <= 4)) |
|
|
|
if ((tonic > max_stress) || (max_stress <= STRESS_IS_PRIMARY)) |
|
|
|
vowel_stress[max_stress_posn] = (char)tonic; |
|
|
|
max_stress = tonic; |
|
|
|
} |
|
|
@@ -1447,7 +1440,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
if ((tr->langopts.vowel_pause & 0x30) && (ph->type == phVOWEL)) { |
|
|
|
// word starts with a vowel |
|
|
|
|
|
|
|
if ((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4)) |
|
|
|
if ((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= STRESS_IS_PRIMARY)) |
|
|
|
*output++ = phonPAUSE_NOLINK; // not to be replaced by link |
|
|
|
else |
|
|
|
*output++ = phonPAUSE_VSHORT; // break, but no pause |
|
|
@@ -1467,26 +1460,26 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
v_stress = vowel_stress[v]; |
|
|
|
tr->prev_last_stress = v_stress; |
|
|
|
|
|
|
|
if (v_stress <= 1) { |
|
|
|
if (v_stress <= STRESS_IS_UNSTRESSED) { |
|
|
|
if ((v > 1) && (max_stress >= 2) && (stressflags & S_FINAL_DIM) && (v == (vowel_count-1))) { |
|
|
|
// option: mark unstressed final syllable as diminished |
|
|
|
v_stress = 0; |
|
|
|
v_stress = STRESS_IS_DIMINISHED; |
|
|
|
} else if ((stressflags & S_NO_DIM) || (v == 1) || (v == (vowel_count-1))) { |
|
|
|
// first or last syllable, or option 'don't set diminished stress' |
|
|
|
v_stress = 1; |
|
|
|
} else if ((v == (vowel_count-2)) && (vowel_stress[vowel_count-1] <= 1)) { |
|
|
|
v_stress = STRESS_IS_UNSTRESSED; |
|
|
|
} else if ((v == (vowel_count-2)) && (vowel_stress[vowel_count-1] <= STRESS_IS_UNSTRESSED)) { |
|
|
|
// penultimate syllable, followed by an unstressed final syllable |
|
|
|
v_stress = 1; |
|
|
|
v_stress = STRESS_IS_UNSTRESSED; |
|
|
|
} else { |
|
|
|
// unstressed syllable within a word |
|
|
|
if ((vowel_stress[v-1] < 0) || ((stressflags & S_MID_DIM) == 0)) { |
|
|
|
v_stress = 0; // change to 0 (diminished stress) |
|
|
|
if ((vowel_stress[v-1] < STRESS_IS_DIMINISHED) || ((stressflags & S_MID_DIM) == 0)) { |
|
|
|
v_stress = STRESS_IS_DIMINISHED; |
|
|
|
vowel_stress[v] = v_stress; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ((v_stress == 0) || (v_stress > 1)) |
|
|
|
if ((v_stress == STRESS_IS_DIMINISHED) || (v_stress > STRESS_IS_UNSTRESSED)) |
|
|
|
*output++ = stress_phonemes[v_stress]; // mark stress of all vowels except 1 (unstressed) |
|
|
|
|
|
|
|
if (vowel_stress[v] > max_stress) |
|
|
@@ -1494,15 +1487,15 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, |
|
|
|
|
|
|
|
if ((*p == phonLENGTHEN) && ((opt_length = tr->langopts.param[LOPT_IT_LENGTHEN]) & 1)) { |
|
|
|
// remove lengthen indicator from non-stressed syllables |
|
|
|
int shorten = 0; |
|
|
|
bool shorten = false; |
|
|
|
|
|
|
|
if (opt_length & 0x10) { |
|
|
|
// only allow lengthen indicator on the highest stress syllable in the word |
|
|
|
if (v != max_stress_posn) |
|
|
|
shorten = 1; |
|
|
|
} else if (v_stress < 4) { |
|
|
|
// only allow lengthen indicator if stress >= 4. |
|
|
|
shorten = 1; |
|
|
|
shorten = true; |
|
|
|
} else if (v_stress < STRESS_IS_PRIMARY) { |
|
|
|
// only allow lengthen indicator if stress >= STRESS_IS_PRIMARY. |
|
|
|
shorten = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (shorten) |
|
|
@@ -1528,7 +1521,6 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph) |
|
|
|
|
|
|
|
const char *p; |
|
|
|
unsigned char c; |
|
|
|
int unstress_mark; |
|
|
|
int length; |
|
|
|
|
|
|
|
length = strlen(ph) + strlen(string); |
|
|
@@ -1536,21 +1528,21 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph) |
|
|
|
return; |
|
|
|
|
|
|
|
// any stressable vowel ? |
|
|
|
unstress_mark = 0; |
|
|
|
bool unstress_mark = false; |
|
|
|
p = ph; |
|
|
|
while ((c = *p++) != 0) { |
|
|
|
if (c >= n_phoneme_tab) continue; |
|
|
|
|
|
|
|
if (phoneme_tab[c]->type == phSTRESS) { |
|
|
|
if (phoneme_tab[c]->std_length < 4) |
|
|
|
unstress_mark = 1; |
|
|
|
unstress_mark = true; |
|
|
|
} else { |
|
|
|
if (phoneme_tab[c]->type == phVOWEL) { |
|
|
|
if (((phoneme_tab[c]->phflags & phUNSTRESSED) == 0) && |
|
|
|
(unstress_mark == 0)) { |
|
|
|
(unstress_mark == false)) { |
|
|
|
tr->word_stressed_count++; |
|
|
|
} |
|
|
|
unstress_mark = 0; |
|
|
|
unstress_mark = false; |
|
|
|
tr->word_vowel_count++; |
|
|
|
} |
|
|
|
} |