Browse Source

Issue espeak-ng/espeak-ng#120

Allow to decrease the score in the rule by adding
master
Valdis Vitolins 8 years ago
parent
commit
252c894e59

+ 2
- 1
docs/dictionary.md View File

@@ -206,7 +206,8 @@ syllable counting.
| Symbol | Description |
|-------------|-------------|
| `@` | A vowel follows somewhere in the word. |
| `+` | Force an increase in the score in this rule (may be repeated for more effect). |
| `+` | Force an increase in the score in this rule by 20 points (may be repeated for more effect). |
| `<` | Force an decrease in the score in this rule by 20 points (may be repeated for more effect). |
| `S<number>` | This number of matching characters are a standard suffix, remove them and retranslate the word. |
| `P<number>` | This number of matching characters are a standard prefix, remove them and retranslate the word. |
| `Lnn` | `nn` is a 2-digit decimal number in the range 01 to 20 Matches with any of the letter sequences which have been defined for letter group `nn` |

+ 4
- 1
src/libespeak-ng/compiledict.c View File

@@ -854,6 +854,9 @@ static void copy_rule_string(char *string, int *state_out)
case '+':
c = RULE_INC_SCORE;
break;
case '<': // Can't use - as opposite for + because it is used literally as part of word
c = RULE_DEC_SCORE;
break;
case '@':
c = RULE_SYLLABLE;
break;
@@ -1035,7 +1038,7 @@ static char *compile_rule(char *input)
state = 3;
p = buf;
if (input[ix+1] == ' ') {
fprintf(f_log, "%5d: Syntax error. Space after (\n", linenum);
fprintf(f_log, "%5d: Syntax error. Space after (, or negative score for previous rule\n", linenum);
error_count++;
}
break;

+ 3
- 0
src/libespeak-ng/dictionary.c View File

@@ -1853,6 +1853,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
case RULE_INC_SCORE:
add_points = 20; // force an increase in points
break;
case RULE_DEC_SCORE:
add_points = -20; // force an decrease in points
break; // TODO schould check why '<' is shown as '!' in rules trace
case RULE_DEL_FWD:
// find the next 'e' in the word and replace by 'E'
for (p = *word + group_length; p < post_ptr; p++) {

+ 1
- 0
src/libespeak-ng/translate.h View File

@@ -182,6 +182,7 @@ extern "C"
#define RULE_NOVOWELS 29 // X no vowels up to word boundary
#define RULE_SPELLING 31 // W while spelling letter-by-letter
#define RULE_LAST_RULE 31
#define RULE_DEC_SCORE 33 // <

#define DOLLAR_UNPR 0x01
#define DOLLAR_NOPREFIX 0x02

Loading…
Cancel
Save