mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-24 04:23:44 +00:00
tokenizer.c: Support ellipsis tokens.
This commit is contained in:
@@ -98,9 +98,10 @@ typedef enum {
|
||||
ESPEAKNG_CTYPE_COMMA,
|
||||
ESPEAKNG_CTYPE_COLON,
|
||||
ESPEAKNG_CTYPE_SEMICOLON,
|
||||
ESPEAKNG_CTYPE_ELLIPSIS,
|
||||
} espeakng_CTYPE;
|
||||
|
||||
#define ESPEAKNG_CTYPE_PROPERTY_MASK 0xFC0000000000C001ull
|
||||
#define ESPEAKNG_CTYPE_PROPERTY_MASK 0xFE0000000000C001ull
|
||||
|
||||
// Reference: http://www.unicode.org/reports/tr14/tr14-32.html -- Unicode Line Breaking Algorithm
|
||||
static espeakng_CTYPE codepoint_type(uint32_t c)
|
||||
@@ -151,6 +152,8 @@ static espeakng_CTYPE codepoint_type(uint32_t c)
|
||||
return ESPEAKNG_CTYPE_COLON;
|
||||
case ESPEAKNG_PROPERTY_SEMI_COLON:
|
||||
return ESPEAKNG_CTYPE_SEMICOLON;
|
||||
case ESPEAKNG_PROPERTY_ELLIPSIS:
|
||||
return ESPEAKNG_CTYPE_ELLIPSIS;
|
||||
}
|
||||
|
||||
// 4. Classify the remaining codepoints.
|
||||
@@ -284,6 +287,18 @@ tokenizer_state_default(espeak_ng_TOKENIZER *tokenizer)
|
||||
return tokenizer_read_word_token(tokenizer, current, ESPEAKNG_TOKEN_WORD_UPPERCASE);
|
||||
case ESPEAKNG_CTYPE_FULL_STOP:
|
||||
current += utf8_out(c, current);
|
||||
if (c == '.' && text_decoder_peekc(tokenizer->decoder) == '.') {
|
||||
c = text_decoder_getc(tokenizer->decoder);
|
||||
if (text_decoder_peekc(tokenizer->decoder) == '.') {
|
||||
c = text_decoder_getc(tokenizer->decoder);
|
||||
current += utf8_out('.', current);
|
||||
current += utf8_out('.', current);
|
||||
*current = '\0';
|
||||
return ESPEAKNG_TOKEN_ELLIPSIS;
|
||||
} else {
|
||||
tokenizer->keepc = c;
|
||||
}
|
||||
}
|
||||
*current = '\0';
|
||||
return ESPEAKNG_TOKEN_FULL_STOP;
|
||||
case ESPEAKNG_CTYPE_QUESTION_MARK:
|
||||
@@ -306,6 +321,10 @@ tokenizer_state_default(espeak_ng_TOKENIZER *tokenizer)
|
||||
current += utf8_out(c, current);
|
||||
*current = '\0';
|
||||
return ESPEAKNG_TOKEN_SEMICOLON;
|
||||
case ESPEAKNG_CTYPE_ELLIPSIS:
|
||||
current += utf8_out(c, current);
|
||||
*current = '\0';
|
||||
return ESPEAKNG_TOKEN_ELLIPSIS;
|
||||
default:
|
||||
current += utf8_out(c, current);
|
||||
*current = '\0';
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef enum
|
||||
ESPEAKNG_TOKEN_COMMA,
|
||||
ESPEAKNG_TOKEN_COLON,
|
||||
ESPEAKNG_TOKEN_SEMICOLON,
|
||||
ESPEAKNG_TOKEN_ELLIPSIS,
|
||||
} espeak_ng_TOKEN_TYPE;
|
||||
|
||||
espeak_ng_TOKEN_TYPE
|
||||
|
||||
Reference in New Issue
Block a user