[1.44.18]

Change in format of *_dict files.  'Word-boundary' at the start of a rule from *_rules is not implied by a new rule type RULE_PRE_ATSTART.
espeakedit: Improvements to Tools->Process Lexicon->Italian which makes the file dictsource/it_listx.
lang=hu, fixes for ordinal numbers.
Speed-up, add files sonic.cpp, sonic.h



git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@255 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2010-12-03 17:42:02 +00:00
parent 1649824b33
commit b89d8bde63
40 changed files with 4362 additions and 2089 deletions
+54 -27
View File
@@ -1090,6 +1090,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
int done;
int stressflags;
int dflags = 0;
int first_primary;
signed char vowel_stress[N_WORD_PHONEMES/2];
char syllable_weight[N_WORD_PHONEMES/2];
@@ -1433,6 +1434,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
done = 0;
first_primary = 0;
for(v=1; v<vowel_count; v++)
{
if(vowel_stress[v] < 0)
@@ -1469,6 +1471,18 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
stress = 3; /* use secondary stress for remaining syllables */
}
}
if(vowel_stress[v] >= 4)
{
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;
}
}
}
if((unstressed_word) && (tonic < 0))
@@ -1737,7 +1751,6 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
int failed;
int unpron_ignore;
int consumed; /* number of letters consumed from input */
int count; /* count through rules in the group */
int syllable_count;
int vowel;
int letter_group;
@@ -1747,6 +1760,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
int n_bytes;
int add_points;
int command;
int check_atstart;
MatchRecord match;
static MatchRecord best;
@@ -1769,7 +1783,6 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
total_consumed = 0;
count = 0;
common_phonemes = NULL;
match_type = 0;
@@ -1787,7 +1800,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
letter = 0;
distance_right= -6; /* used to reduce points for matches further away the current letter */
distance_left= -2;
count++;
check_atstart = 0;
match.points = 1;
match.end_type = 0;
@@ -1827,17 +1840,24 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
rule--; // so we are still pointing at the 0
failed=2; // matched OK
break;
case RULE_PRE_ATSTART: // pre rule with implied 'start of word'
check_atstart = 1;
unpron_ignore = 0;
match_type = RULE_PRE;
break;
case RULE_PRE:
match_type = RULE_PRE;
if(word_flags & FLAG_UNPRON_TEST)
{
// checking the start of the word for unpronouncable character sequences, only
// consider rules which explicitly match the start of a word
if(rule[0] != ' ')
failed = 1;
unpron_ignore = 0;
// Note: Those rules now use RULE_PRE_ATSTART
failed = 1;
}
break;
case RULE_POST:
match_type = RULE_POST;
break;
@@ -2306,31 +2326,34 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
match.points += add_points;
}
if((failed == 2) && (unpron_ignore == 0))
{
/* matched OK, is this better than the last best match ? */
if(match.points >= best.points)
// do we also need to check for 'start of word' ?
if((check_atstart==0) || (pre_ptr[-1] == ' '))
{
memcpy(&best,&match,sizeof(match));
total_consumed = consumed;
if(check_atstart)
match.points += 4;
/* matched OK, is this better than the last best match ? */
if(match.points >= best.points)
{
memcpy(&best,&match,sizeof(match));
total_consumed = consumed;
}
if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
{
// show each rule that matches, and it's points score
int pts;
char decoded_phonemes[80];
pts = match.points;
if(group_length > 1)
pts += 35; // to account for an extra letter matching
DecodePhonemes(match.phonemes,decoded_phonemes);
fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group_chars, group_length, rule_start, word_flags), decoded_phonemes);
}
}
if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
{
// show each rule that matches, and it's points score
int pts;
char decoded_phonemes[80];
// note: 'count' contains the rule number, if we want to include it
pts = match.points;
if(group_length > 1)
pts += 35; // to account for an extra letter matching
DecodePhonemes(match.phonemes,decoded_phonemes);
fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group_chars, group_length, rule_start, word_flags), decoded_phonemes);
}
}
/* skip phoneme string to reach start of next template */
@@ -3313,6 +3336,10 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
fprintf(f_trans,"Replace: %s %s\n",word,*wordptr);
}
}
else
{
flags[0] &= ~FLAG_SKIPWORDS;
}
ph_out[0] = 0;
return(0);