diff --git a/docs/dictionary.md b/docs/dictionary.md index b0d2feb9..8dec7f76 100644 --- a/docs/dictionary.md +++ b/docs/dictionary.md @@ -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` | This number of matching characters are a standard suffix, remove them and retranslate the word. | | `P` | 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` | diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 21b04ecf..737086b5 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -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; diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 1f76d6a1..4d6eeb6d 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -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++) { diff --git a/src/libespeak-ng/translate.h b/src/libespeak-ng/translate.h index bf782867..0fd49813 100644 --- a/src/libespeak-ng/translate.h +++ b/src/libespeak-ng/translate.h @@ -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