[1.31.17]

*_rules: New option, (Pb to specify a character such as apostrophe which splits a word into two parts (used for lang-tr).
 

git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@150 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-02-24 13:53:14 +00:00
parent 19db296d78
commit bf8ee6362e
26 changed files with 565 additions and 351 deletions
+3
View File
@@ -810,6 +810,9 @@ void copy_rule_string(char *string, int &state)
case 't':
sxflags |= SUFX_T;
break;
case 'b':
sxflags |= SUFX_B;
break;
default:
if(isdigit(c))
value = (value*10) + (c - '0');
+3 -1
View File
@@ -2272,6 +2272,8 @@ int Translator::TranslateRules(char *p_start, char *phonemes, int ph_size, char
{
c = p_start[ix];
word_copy[ix++] = c;
if(c == 0)
break;
}
word_copy[ix] = 0;
@@ -3096,7 +3098,7 @@ int Translator::RemoveEnding(char *word, int end_type, char *word_copy)
word_copy[i] = 0;
// look for multibyte characters to increase the number of bytes to remove
for(len_ending = i = (end_type & 0xf); i>0 ;i--) // num.of characters of the suffix
for(len_ending = i = (end_type & 0x3f); i>0 ;i--) // num.of characters of the suffix
{
word_end--;
while((*word_end & 0xc0) == 0x80)
+1 -1
View File
@@ -466,7 +466,7 @@ int Translator::LookupNum3(int value, char *ph_out, int suppress_null, int thous
Lookup("_0C",ph_100);
if((hundreds >= 10) && ((langopts.numbers & 0x0800) || (hundreds != 19)))
if((hundreds >= 10) && (((langopts.numbers & 0x0800) == 0) || (hundreds != 19)))
{
ph_digits[0] = 0;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.31.14 21.Feb.08";
const char *version_string = "1.31.17 24.Feb.08";
const int version_phdata = 0x013105;
int option_device_number = -1;
+1 -1
View File
@@ -42,7 +42,7 @@ Translator_English::Translator_English() : Translator()
memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths));
langopts.stress_rule = 0;
langopts.numbers = 0x41 + NUM_ROMAN;
langopts.numbers = 0x841 + NUM_ROMAN;
langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
}
+25 -24
View File
@@ -147,7 +147,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.param[LOPT_PREFIXES] = 1;
memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
tr->langopts.numbers = 0x11c19 + NUM_ROMAN;
tr->langopts.numbers = 0x11419 + NUM_ROMAN;
SetLetterVowel(tr,'y');
}
break;
@@ -189,7 +189,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
tr->langopts.numbers = 0xb09;
tr->langopts.numbers = 0x309;
tr->langopts.numbers2 = 0x2; // variant form of numbers before thousands
if(name2 == L_grc)
@@ -218,7 +218,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.unstressed_wd1 = 1;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.numbers = 0x1c09 + NUM_ROMAN;
tr->langopts.numbers = 0x1409 + NUM_ROMAN;
}
break;
@@ -258,7 +258,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.long_stop = 140;
tr->langopts.numbers = 0x1009;
tr->langopts.numbers = 0x1809;
SetLetterVowel(tr,'y');
tr->langopts.max_initial_consonants = 2;
tr->langopts.spelling_stress = 1;
@@ -295,7 +295,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
tr->langopts.numbers = 0x811;
tr->langopts.numbers = 0x011;
tr->langopts.numbers2 = 0x100;
tr->letter_bits_offset = OFFSET_DEVANAGARI;
@@ -331,7 +331,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
tr->langopts.numbers = 0x1c0d + 0x4000 + NUM_ROMAN_UC;
tr->langopts.numbers = 0x140d + 0x4000 + NUM_ROMAN_UC;
tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
tr->langopts.replace_chars = replace_cyrillic_latin;
@@ -358,7 +358,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.param[LOPT_COMBINE_WORDS] = 99; // combine some prepositions with the following word
tr->langopts.numbers = 0x1809 + NUM_ROMAN;
tr->langopts.numbers = 0x1009 + NUM_ROMAN;
SetLetterVowel(tr,'y');
tr->langopts.spelling_stress = 1;
SetLengthMods(tr,3); // all equal
@@ -372,7 +372,7 @@ SetLengthMods(tr,3); // all equal
tr = new Translator();
SetupTranslator(tr,stress_lengths_id,stress_amps_id);
tr->langopts.stress_rule = 2;
tr->langopts.numbers = 0x1809 + NUM_ROMAN;
tr->langopts.numbers = 0x1009 + NUM_ROMAN;
tr->langopts.stress_flags = 0x6 | 0x10;
}
break;
@@ -395,7 +395,7 @@ SetLengthMods(tr,3); // all equal
SetLetterBits(tr,3,"jvr"); // Letter group H
tr->letter_groups[1] = is_lettergroup_B;
SetLetterVowel(tr,'y');
tr->langopts.numbers = 0xe9;
tr->langopts.numbers = 0x8e9;
tr->langopts.numbers2 = 0x2;
}
break;
@@ -417,7 +417,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
tr->langopts.numbers = 0x2709 + 0x800 + NUM_ROMAN;
tr->langopts.numbers = 0x2709 + NUM_ROMAN;
}
break;
@@ -451,7 +451,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
tr->langopts.numbers = 0x100c69;
tr->langopts.numbers = 0x100469;
tr->langopts.max_initial_consonants = 2;
}
break;
@@ -483,7 +483,7 @@ SetLengthMods(tr,3); // all equal
tr->letter_groups[0] = vowels_cyrillic;
tr->langopts.stress_rule = 4; // antipenultimate
tr->langopts.numbers = 0x0c29 + 0x4000;
tr->langopts.numbers = 0x0429 + 0x4000;
tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
}
break;
@@ -500,7 +500,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(tr,'y');
tr->langopts.numbers = 0x11419;
tr->langopts.numbers = 0x11c19;
memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
}
break;
@@ -514,7 +514,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 0;
SetLetterVowel(tr,'y');
tr->langopts.numbers = 0x11049;
tr->langopts.numbers = 0x11849;
}
break;
@@ -531,7 +531,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
tr->langopts.numbers=0x1809 + 0x4000;
tr->langopts.numbers=0x1009 + 0x4000;
tr->langopts.numbers2=0x40;
tr->langopts.param[LOPT_COMBINE_WORDS] = 2 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable words (marked with $alt)
SetLetterVowel(tr,'y');
@@ -549,7 +549,7 @@ SetLengthMods(tr,3); // all equal
// tr->langopts.vowel_pause = 1;
tr->langopts.stress_rule = 3; // stress on final syllable
tr->langopts.stress_flags = 0x6 | 0x10 | 0x20000;
tr->langopts.numbers = 0xa69 + 0x2000 + NUM_ROMAN;
tr->langopts.numbers = 0x269 + 0x2000 + NUM_ROMAN;
SetLetterVowel(tr,'y');
}
break;
@@ -566,7 +566,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_flags = 0x100 + 0x6;
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.numbers = 0x1829+0x6000 + NUM_ROMAN;
tr->langopts.numbers = 0x1029+0x6000 + NUM_ROMAN;
tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
}
break;
@@ -593,7 +593,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.spelling_stress = 1;
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
tr->langopts.numbers = 0x0c01 + 0x4000 + NUM_ROMAN;
tr->langopts.numbers = 0x0401 + 0x4000 + NUM_ROMAN;
tr->langopts.numbers2 = 0x40;
tr->langopts.thousands_sep = 0; //no thousands separator
tr->langopts.decimal_sep = ',';
@@ -620,7 +620,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 0;
SetLetterVowel(tr,'y');
// SetLetterBits(tr,6,"eiyäö"); // soft vowels NOTE accented letters don't work in SetLetterBits
tr->langopts.numbers = 0x1109;
tr->langopts.numbers = 0x1909;
}
break;
@@ -637,7 +637,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 2;
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.numbers = 0x8e1;
tr->langopts.numbers = 0x4e1;
tr->langopts.numbers2 = 0x100;
}
break;
@@ -684,16 +684,17 @@ SetLengthMods(tr,3); // all equal
case L('t','r'): // Turkish
{
static const unsigned char stress_amps_tr[8] = {16,16, 20,20, 20,24, 24,22 };
static const short stress_lengths_tr[8] = {170,170, 190,170, 0,0, 250,270};
static const unsigned char stress_amps_tr[8] = {18,18, 20,20, 20,24, 24,22 };
static const short stress_lengths_tr[8] = {190,190, 190,190, 0,0, 250,270};
tr = new Translator();
SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
tr->langopts.stress_flags = 0x20; //no automatic secondary stress
tr->langopts.numbers = 0x1d09 + 0x4000;
tr->langopts.numbers = 0x1509 + 0x4000;
tr->langopts.max_initial_consonants = 2;
}
break;
@@ -1044,7 +1045,7 @@ Translator_Afrikaans::Translator_Afrikaans() : Translator()
langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(this,'y'); // add 'y' to vowels
langopts.numbers = 0x0d1 + NUM_ROMAN;
langopts.numbers = 0x8d1 + NUM_ROMAN;
memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths));
}
+36 -6
View File
@@ -613,6 +613,8 @@ int Translator::TranslateWord(char *word1, int next_pause, WORD_TAB *wtab)
int word_length;
int ix;
int posn;
int pfix;
int n_chars;
unsigned int dictionary_flags[2];
unsigned int dictionary_flags2[2];
int end_type=0;
@@ -624,6 +626,7 @@ int Translator::TranslateWord(char *word1, int next_pause, WORD_TAB *wtab)
char prefix_phonemes[N_WORD_PHONEMES];
char end_phonemes[N_WORD_PHONEMES];
char word_copy[N_WORD_BYTES];
char prefix_chars[N_WORD_BYTES];
int found=0;
int end_flags;
char c_temp; // save a character byte while we temporarily replace it with space
@@ -824,7 +827,7 @@ if((wmark > 0) && (wmark < 8))
{
// Found a standard prefix, remove it and retranslate
if(confirm_prefix)
if(confirm_prefix && !(end_type & SUFX_B))
{
int end2;
char phonemes2[N_WORD_PHONEMES];
@@ -856,8 +859,6 @@ if((wmark > 0) && (wmark < 8))
}
}
strcat(prefix_phonemes,end_phonemes);
end_phonemes[0] = 0;
prefix_type = end_type;
if(prefix_type & SUFX_V)
@@ -866,15 +867,44 @@ if((wmark > 0) && (wmark < 8))
}
wordx[-1] = c_temp;
for(ix=(prefix_type & 0xf); ix>0; ix--) // num. of characters to remove
pfix = 1;
prefix_chars[0] = 0;
n_chars = prefix_type & 0x3f;
for(ix=0; ix < n_chars; ix++) // num. of characters to remove
{
wordx++;
while((*wordx & 0xc0) == 0x80) wordx++; // for multibyte characters
prefix_chars[pfix++] = *wordx++;
if((prefix_type & SUFX_B) && (ix == (n_chars-1)))
{
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
}
while((*wordx & 0xc0) == 0x80)
{
prefix_chars[pfix++] = *wordx++; // for multibyte characters
}
}
prefix_chars[pfix] = 0;
c_temp = wordx[-1];
wordx[-1] = ' ';
confirm_prefix = 1;
if(prefix_type & SUFX_B)
{
// retranslate the prefix part
char *wordpf;
wordpf = &prefix_chars[1];
found = LookupDictList(&wordpf, phonemes, dictionary_flags, SUFX_P, wtab); // without prefix
if(found == 0)
{
end_type = TranslateRules(wordpf, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags[0]);
strcat(prefix_phonemes, phonemes);
}
}
strcat(prefix_phonemes,end_phonemes);
end_phonemes[0] = 0;
end_type = 0;
found = LookupDictList(&wordx, phonemes, dictionary_flags2, SUFX_P, wtab); // without prefix
if(dictionary_flags[0]==0)
+2 -1
View File
@@ -106,6 +106,7 @@
#define SUFX_F 0x2000 // verb follows
#define SUFX_Q 0x4000 // don't retranslate
#define SUFX_T 0x10000 // don't affect the stress position in the stem
#define SUFX_B 0x20000 // break, this character breaks the word into stem and suffix (used with SUFX_P)
#define FLAG_ALLOW_TEXTMODE 0x02 // allow dictionary to translate to text rather than phonemes
#define FLAG_SUFX 0x04
@@ -321,7 +322,7 @@ typedef struct {
// bit8=only one primary stress in tens+units
// bit9=only one vowel betwen tens and units
// bit10=omit "one" before "hundred"
// bit11=don't say 19** as nineteen hundred
// bit11=say 19** as nineteen hundred
// bit12=allow space as thousands separator (in addition to langopts.thousands_sep)
// bits13-15 post-decimal-digits 0=single digits, 1=(LANG=it) 2=(LANG=pl) 3=(LANG=ro)
// bit16=dot after number indicates ordinal