[1.42.42]

Don't recognize space as a thousands separator if it's tab, newline, or multiple spaces.
Don't recognuze space as a thousands separator if not followed by exactly 3 digits.

Unrecognized HTML tags should not add a space (eg. <font> <b> inside a word).

lang=hu: fixes for when numbers are ordinal.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@236 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2010-02-13 11:14:41 +00:00
parent 20f52f0301
commit 2698461aa4
69 changed files with 2050 additions and 839 deletions
+9 -3
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2009 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -102,6 +102,10 @@ static keywtab_t k_conditions[] = {
{NULL, 0, 0}
};
// place of articulation
#define i_isVel 0x28
static keywtab_t k_properties[] = {
{"isPause", 0, phPAUSE},
{"isVowel", 0, phVOWEL},
@@ -112,6 +116,8 @@ static keywtab_t k_properties[] = {
{"isPalatal", 0, i_isPalatal},
{"isRhotic", 0, i_isRhotic},
{"isVel", 0, i_isVel},
{"isDiminished", 0, i_isDiminished},
{"isUnstressed", 0, i_isUnstressed},
{"isNotStressed",0, i_isNotStressed},
@@ -269,7 +275,7 @@ static keywtab_t keywords[] = {
{"vcd", tPHONEME_FLAG, phVOICED},
{"vls", tPHONEME_FLAG, phFORTIS},
// place of articulation
// place of articulation, set bits 16-19 of phflags
{"blb", tPLACE, 1},
{"lbd", tPLACE, 2},
{"dnt", tPLACE, 3},
@@ -347,7 +353,7 @@ static void DecompilePhoneme(FILE *f_out, PHONEME_TAB *ph, int compile_phoneme)
int any;
const char *name;
static char *INV = "Invalid";
static const char *INV = "Invalid";
static const char *instn_category_string[16] = {
"", "", "IF", "IF OR",
+2 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -91,6 +91,7 @@ MNEM_TAB mnem_flags[] = {
{"$alt", 20}, // use alternative pronunciation
{"$alt2", 21},
{"$combine", 22}, // Combine with the next word
{"$alt3", 23},
{"$dot", 24}, // ignore '.' after this word (abbreviation)
{"$hasdot", 25}, // use this pronunciation if there is a dot after the word
+29 -21
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -3499,38 +3499,46 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
if(end_type & SUFX_E)
{
// add 'e' to end of stem
if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
if(tr->translator_name == L('e','n'))
{
// vowel(incl.'y') + hard.consonant
for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
// add 'e' to end of stem
if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
{
len = strlen(p);
if(memcmp(p,&word_end[1-len],len)==0)
// vowel(incl.'y') + hard.consonant
for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
{
break;
len = strlen(p);
if(memcmp(p,&word_end[1-len],len)==0)
{
break;
}
}
if(p == NULL)
end_flags |= FLAG_SUFX_E_ADDED; // no exception found
}
else
{
for(i=0; (p = add_e_additions[i]) != NULL; i++)
{
len = strlen(p);
if(memcmp(p,&word_end[1-len],len)==0)
{
end_flags |= FLAG_SUFX_E_ADDED;
break;
}
}
}
if(p == NULL)
end_flags |= FLAG_SUFX_E_ADDED; // no exception found
}
else
if(tr->langopts.suffix_add_e != 0)
{
for(i=0; (p = add_e_additions[i]) != NULL; i++)
{
len = strlen(p);
if(memcmp(p,&word_end[1-len],len)==0)
{
end_flags |= FLAG_SUFX_E_ADDED;
break;
}
}
end_flags |= FLAG_SUFX_E_ADDED;
}
if(end_flags & FLAG_SUFX_E_ADDED)
{
word_end[1] = 'e';
utf8_out(tr->langopts.suffix_add_e, &word_end[1]);
#ifdef LOG_TRANSLATE
if(option_phonemes == 2)
{
+109 -25
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -68,6 +68,7 @@
static int n_digit_lookup;
static char *digit_lookup;
static int speak_missing_thousands;
static int number_control;
typedef struct {
@@ -762,16 +763,18 @@ static int CheckDotOrdinal(Translator *tr, char *word, WORD_TAB *wtab, int roman
int ordinal = 0;
int c2;
int nextflags;
if((tr->langopts.numbers & NUM_ORDINAL_DOT) && ((word[0] == '.') || (wtab[0].flags & FLAG_HAS_DOT)) && !(wtab[1].flags & FLAG_NOSPACE))
{
if(roman || !(wtab[1].flags & FLAG_FIRST_UPPER))
{
utf8_in(&c2, &word[2]);
if((word[1] != 0) && IsAlpha(c2))
if((word[1] != 0) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || IsAlpha(c2)))
{
// ordinal number is indicated by dot after the number
// but not if the next word starts with an upper-case letter
// (c2 == 0) is for cases such as, "2.,"
ordinal = 2;
if(word[0] == '.')
word[0] = ' ';
@@ -779,8 +782,19 @@ static int CheckDotOrdinal(Translator *tr, char *word, WORD_TAB *wtab, int roman
if((roman==0) && (tr->translator_name == L('h','u')))
{
// lang=hu don't treat dot as ordinal indicator if the next word is a month name ($alt). It may have a suffix.
if(TranslateWord(tr, &word[2], 0, NULL) & FLAG_ALT_TRANS)
nextflags = 0;
if(IsAlpha(c2))
{
nextflags = TranslateWord(tr, &word[2], 0, NULL);
}
if((tr->prev_dict_flags & FLAG_ALT_TRANS) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || iswdigit(c2)))
ordinal = 0; // TEST 09.02.10
if(nextflags & FLAG_ALT_TRANS)
ordinal = 0;
if((tr->prev_dict_flags & (FLAG_ALT_TRANS | FLAG_ALT3_TRANS)) && (nextflags & FLAG_ALT3_TRANS))
ordinal = 0x22;
}
}
}
@@ -941,6 +955,12 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
sprintf(string,"_%dM%do",value,thousandplex);
found_value = Lookup(tr, string, ph_thousands);
}
if(!found_value & (number_control & 1))
{
// look for the 'e' variant
sprintf(string,"_%dM%de",value,thousandplex);
found_value = Lookup(tr, string, ph_thousands);
}
if(!found_value)
{
// is there a different pronunciation if there are no hundreds,tens,or units ? (LANG=ta)
@@ -970,6 +990,12 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
sprintf(string,"_%s%do",M_Variant(value), thousandplex);
found = Lookup(tr, string, ph_thousands);
}
if(!found && (number_control & 1))
{
// look for the 'e' variant
sprintf(string,"_%s%de",M_Variant(value), thousandplex);
found = Lookup(tr, string, ph_thousands);
}
if(!found)
{
// is there a different pronunciation if there are no hundreds,tens,or units ?
@@ -1013,10 +1039,11 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
{//========================================================================
// Lookup a 2 digit number
// control bit 0: ordinal number
// control bit 1: tens and units (use special form of '1', LANG=de "eins")
// control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins")
// control bit 2: tens and units only, no higher digits
// control bit 3: use feminine form of '2' (for thousands
// control bit 4: speak zero tens
// control bit 5: variant of ordinal number (lang=hu)
int found;
int ix;
@@ -1025,6 +1052,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
int used_and=0;
int found_ordinal = 0;
int next_phtype;
int ord_type = 'o';
char string[12]; // for looking up entries in *_list
char ph_ordinal[20];
char ph_tens[50];
@@ -1040,6 +1068,11 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
ph_digits[0] = 0;
ph_and[0] = 0;
if(control & 0x20)
{
ord_type = 'q';
}
if((control & 2) && (n_digit_lookup == 2))
{
// pronunciation of the final 2 digits has already been found
@@ -1062,12 +1095,12 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
if(control & 4)
{
sprintf(string,"_%dox",value); // LANG=hu, special word for 1. 2. when there are no higher digits
sprintf(string,"_%d%cx",value,ord_type); // LANG=hu, special word for 1. 2. when there are no higher digits
found = Lookup(tr, string, ph_digits);
}
if(found == 0)
{
sprintf(string,"_%do",value);
sprintf(string,"_%d%c",value,ord_type);
found = Lookup(tr, string, ph_digits);
}
found_ordinal = found;
@@ -1075,13 +1108,28 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
if(found == 0)
{
if((value == 1) && (control & 2))
if(control & 2)
{
if(Lookup(tr, "_1a", ph_out) != 0) // LANG=de, "eins"
return(0);
// the final tens and units of a number
if(number_control & 1)
{
// look for 'e' variant
sprintf(string,"_%de",value);
found = Lookup(tr, string, ph_digits);
}
}
else
{
// followed by hundreds or thousands etc
sprintf(string,"_%da",value);
found = Lookup(tr, string, ph_digits);
}
if(!found)
{
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
}
sprintf(string,"_%d",value);
found = Lookup(tr, string, ph_digits);
}
}
@@ -1103,7 +1151,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
if((control & 1) && ((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
{
sprintf(string,"_%dXo", tens);
sprintf(string,"_%dX%c", tens, ord_type);
if(Lookup(tr, string, ph_tens) != 0)
{
found_ordinal = 1;
@@ -1146,13 +1194,29 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
if((control & 1) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
{
// ordinal
sprintf(string,"_%do",units);
sprintf(string,"_%d%c",units,ord_type);
if((found = Lookup(tr, string, ph_digits)) != 0)
{
found_ordinal = 1;
}
}
if(found == 0)
{
if((number_control & 1) && (control & 2))
{
// look for 'e' variant
sprintf(string,"_%de",units);
found = Lookup(tr, string, ph_digits);
}
else
if(((control & 2) == 0) || ((tr->langopts.numbers & NUM_SWAP_TENS) != 0))
{
// followed by hundreds or thousands (or tens)
sprintf(string,"_%da",units);
found = Lookup(tr, string, ph_digits);
}
}
if(found == 0)
{
sprintf(string,"_%d",units);
Lookup(tr, string, ph_digits);
@@ -1221,6 +1285,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
// Translate a 3 digit number
// control bit 0, previous thousands
// bit 1, ordinal number
// bit 5 variant form of ordinal number
int found;
int hundreds;
int tensunits;
@@ -1237,7 +1302,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
char ph_hundred_and[12];
char ph_thousand_and[12];
ordinal = control & 2;
ordinal = control & 0x22;
hundreds = value / 100;
tensunits = value % 100;
buf1[0] = 0;
@@ -1281,9 +1346,9 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
}
if(tr->langopts.numbers2 & 0x200)
sprintf(ph_thousands,"%s%s%c",ph_10T,ph_digits,phonPAUSE_NOLINK); // say "thousands" before its number, not after
sprintf(ph_thousands,"%s%s",ph_10T,ph_digits); // say "thousands" before its number, not after
else
sprintf(ph_thousands,"%s%s%c",ph_digits,ph_10T,phonPAUSE_NOLINK);
sprintf(ph_thousands,"%s%s",ph_digits,ph_10T);
hundreds %= 10;
if(hundreds == 0)
@@ -1362,6 +1427,8 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
x = 3; // ordinal number
if((value < 100) && !(control & 1))
x |= 4; // tens and units only, no higher digits
if(ordinal & 0x20)
x |= 0x20; // variant form of ordinal number
}
else
{
@@ -1391,6 +1458,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
int n_digits;
int value;
int ix;
int digix;
unsigned char c;
int suppress_null = 0;
int decimal_point = 0;
@@ -1404,6 +1472,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
int max_decimal_count;
int decimal_mode;
int hyphen;
int suffix_ix;
char *p;
char string[20]; // for looking up entries in **_list
char buf1[100];
@@ -1420,6 +1489,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
n_digit_lookup = 0;
buf_digit_lookup[0] = 0;
digit_lookup = buf_digit_lookup;
number_control = 0;
for(ix=0; isdigit(word[ix]); ix++) ;
n_digits = ix;
@@ -1444,7 +1514,6 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
speak_missing_thousands = 0;
}
ph_ordinal2[0] = 0;
ph_zeros[0] = 0;
@@ -1478,9 +1547,9 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
}
*p = 0;
if(suffix[0] != 0)
if((suffix[0] != 0) && (!isdigit(suffix[0]))) // not _#9 (tab)
{
sprintf(string,"_0%s",suffix);
sprintf(string,"_#%s",suffix);
if(Lookup(tr, string, ph_ordinal2))
{
// this is an ordinal suffix
@@ -1526,20 +1595,26 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
if(word[n_digits] == tr->langopts.thousands_sep)
thousands_inc = 2;
suffix_ix = n_digits+2;
if(thousands_inc > 0)
{
// if the following "words" are three-digit groups, count them and add
// a "thousand"/"million" suffix to this one
digix = n_digits + thousands_inc;
ix = n_digits + thousands_inc;
while(isdigit(word[ix]) && isdigit(word[ix+1]) && isdigit(word[ix+2]))
while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) &&
isdigit(word[digix]) && isdigit(word[digix+1]) && isdigit(word[digix+2]) && !isdigit(word[digix+3]) && !isdigit(word[digix-1]))
{
if((word[ix] != '0') || (word[ix+1] != '0') || (word[ix+2] != '0'))
if((word[digix] != '0') || (word[digix+1] != '0') || (word[digix+2] != '0'))
thousands_exact = 0;
thousandplex++;
if(word[ix+3] == tr->langopts.thousands_sep)
ix += (3 + thousands_inc);
digix += 3;
if((word[digix] == tr->langopts.thousands_sep) || ((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[digix] == ' ')))
{
suffix_ix = digix+2;
digix += thousands_inc;
}
else
break;
}
@@ -1550,6 +1625,15 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
suppress_null = 1;
}
if(tr->translator_name == L('h','u'))
{
// variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e'
if((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact==1) && ((word[suffix_ix] == 'a') || (word[suffix_ix] == 'e')))
{
number_control |= 1; // use _1e variant of number
}
}
if((word[n_digits] == tr->langopts.decimal_sep) && isdigit(word[n_digits+1]))
{
// this "word" ends with a decimal point
@@ -1713,7 +1797,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
if((tr->langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
utf8_in(&next_char,p);
if(!iswalpha(next_char) && !(wtab[0].flags & FLAG_HYPHEN_AFTER))
if(!iswalpha(next_char) && !((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact != 0)))
strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
}
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
+26 -10
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -1543,12 +1543,12 @@ static int ReplaceKeyName(char *outbuf, int index, int &outix)
int letter;
char *p;
p = &outbuf[index+1];
p = &outbuf[index];
if((letter = LookupMnem(keynames, p)) != 0)
{
ix = utf8_out(letter, p);
outix = index + ix + 1;
outix = index + ix;
return(letter);
}
return(0);
@@ -1636,16 +1636,26 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int &outix, int n_outb
if(tag_name[0] == '/')
{
tag_type = LookupMnem(ssmltags,&tag_name[1]) + SSML_CLOSE; // closing tag
// closing tag
if((tag_type = LookupMnem(ssmltags,&tag_name[1])) != 0)
{
outbuf[outix++] = ' ';
}
tag_type += SSML_CLOSE;
}
else
{
tag_type = LookupMnem(ssmltags,tag_name);
if((tag_type = LookupMnem(ssmltags,tag_name)) != 0)
{
// separate SSML tags from the previous word (but not unknown HMTL tags such as <b> <font> which can occur inside a word)
outbuf[outix++] = ' ';
}
if(self_closing && ignore_if_self_closing[tag_type])
return(0);
}
voice_change_flag = 0;
terminator = CLAUSE_NONE;
ssml_sp = &ssml_stack[n_ssml_stack-1];
@@ -2178,9 +2188,7 @@ f_input = f_in; // for GetC etc
}
xml_buf[n_xml_buf] = 0;
c2 = ' ';
buf[ix++] = ' ';
self_closing = 0;
if(xml_buf[n_xml_buf-1] == '/')
{
@@ -2211,6 +2219,7 @@ f_input = f_in; // for GetC etc
}
return(terminator);
}
c2 = GetC();
continue;
}
}
@@ -2510,6 +2519,13 @@ if(option_ssml) parag=1;
if(nl_count==0)
{
if((c1 == ',') && (cprev == '.') && (tr->translator_name == L('h','u')) && iswdigit(cprev2) && (iswdigit(c_next) || (iswlower(c_next))))
{
// lang=hu, fix for ordinal numbers, eg: "december 2., szerda", ignore ',' after ordinal number
c1 = CHAR_COMMA_BREAK;
is_end_clause = 0;
}
if(c1 == '.')
{
if((tr->langopts.numbers & NUM_ORDINAL_DOT) &&
@@ -2522,7 +2538,7 @@ if(option_ssml) parag=1;
}
else
{
if (iswlower(c_next))
if (iswlower(c_next) || (c_next=='-')) // hyphen is needed for lang-hu (eg. 2.-kal)
is_end_clause = 0; // only if followed by lower-case, (or if there is a XML tag)
}
}
@@ -2565,7 +2581,7 @@ if(option_ssml) parag=1;
buf[ix] = ' ';
buf[ix+1] = 0;
if(!IsAlpha(c_next))
if(iswdigit(cprev) && !IsAlpha(c_next)) // ????
{
punct_data &= ~CLAUSE_DOT;
}
+2 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -174,7 +174,7 @@ static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_
}
int sync_espeak_terminated_msg( uint unique_identifier, void* user_data)
int sync_espeak_terminated_msg( uint32_t unique_identifier, void* user_data)
{//=====================================================================
ENTER("sync_espeak_terminated_msg");
+2 -1
View File
@@ -1,7 +1,7 @@
#ifndef SPEAK_LIB_H
#define SPEAK_LIB_H
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -26,6 +26,7 @@
/*************************************************************/
#include <stdio.h>
#include <stddef.h>
#define ESPEAK_API_REVISION 5
/*
+4 -3
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.42.21 19.Dec.09";
const char *version_string = "1.42.42 12.Feb.10";
const int version_phdata = 0x014220;
int option_device_number = -1;
@@ -942,13 +942,14 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
case 9:
data = ((instn & 0xf) << 16) + prog[1];
prog++;
switch(instn2)
{
case 1:
// call a procedure or another phoneme
if(n_return < N_RETURN)
{
return_addr[n_return++] = prog+1;
return_addr[n_return++] = prog;
prog = &phoneme_index[data] - 1;
}
break;
+2 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -1458,7 +1458,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
}
}
if((next->type==phVOWEL) || ((next->type==phLIQUID)) && (next->newword==0)) // ?? test 14.Aug.2007
if((next->type==phVOWEL) || ((next->type==phLIQUID) && (next->newword==0))) // ?? test 14.Aug.2007
{
StartSyllable();
}
+4 -2
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -235,6 +235,7 @@ void SetIndicLetters(Translator *tr)
SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; //virama
}
void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
@@ -361,6 +362,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
tr->langopts.suffix_add_e = 'e';
}
break;
@@ -793,7 +795,7 @@ SetLengthMods(tr,3); // all equal
case L('n','o'): // Norwegian
{
static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,210};
static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,230};
SetupTranslator(tr,stress_lengths_no,NULL);
tr->langopts.stress_rule = STRESSPOSN_1L;
+44 -12
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -1763,6 +1763,12 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
first_phoneme = 0;
}
}
if(word_flags & FLAG_COMMA_AFTER)
{
SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE_CLAUSE);
}
// don't set new-word if there is a hyphen before it
if((word_flags & FLAG_HYPHEN) == 0)
{
@@ -2018,6 +2024,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
int prev_out=' ';
int prev_out2;
int prev_in2=0;
int prev_in_save=0;
int next_in;
int next_in_nbytes;
int char_inserted=0;
@@ -2166,14 +2173,15 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
prev_out = 'a';
}
if(prev_in2 != 0)
if(prev_in_save != 0)
{
prev_in = prev_in2;
prev_in2 = 0;
prev_in = prev_in_save;
prev_in_save = 0;
}
else
if(source_index > 0)
{
prev_in2 = prev_in;
utf8_in2(&prev_in,&source[source_index-1],1); // prev_in = source[source_index-1];
}
@@ -2199,13 +2207,13 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
if(prev_in != ' ')
{
c = ' ';
prev_in2 = c;
prev_in_save = c;
source_index--;
}
else
{
embedded_count += EmbeddedCommand(source_index);
prev_in2 = prev_in;
prev_in_save = prev_in;
// replace the embedded command by spaces
memset(&source[srcix],' ',source_index-srcix);
source_index = srcix;
@@ -2285,6 +2293,12 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
word_flags |= FLAG_FOCUS;
}
if(c == CHAR_COMMA_BREAK)
{
c = ' ';
word_flags |= FLAG_COMMA_AFTER;
}
c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
if(c == 8)
continue; // ignore this character
@@ -2311,7 +2325,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if(iswdigit(prev_out))
{
if(!iswdigit(c) && (c != '.') && (c != ','))
if(!iswdigit(c) && (c != '.') && (c != ',') && (c != ' '))
{
c = ' '; // terminate digit string with a space
space_inserted = 1;
@@ -2350,7 +2364,11 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
// start of word, insert space if not one there already
c = ' ';
space_inserted = 1;
next_word_flags |= FLAG_NOSPACE;
if(!IsBracket(prev_out)) // ?? perhaps only set FLAG_NOSPACE for . - / (hyphenated words, URLs, etc)
{
next_word_flags |= FLAG_NOSPACE;
}
}
else
{
@@ -2388,7 +2406,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
{
c = ' '; // lower case followed by upper case, treat as new word
space_inserted = 1;
prev_in2 = c;
prev_in_save = c;
}
else
if((c != ' ') && iswupper(prev_in) && iswlower(next_in))
@@ -2400,7 +2418,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
// changing from upper to lower case, start new word at the last uppercase, if 3 or more letters
c = ' ';
space_inserted = 1;
prev_in2 = c;
prev_in_save = c;
next_word_flags |= FLAG_NOSPACE;
}
}
@@ -2563,9 +2581,15 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
{
if(prev_out == ' ')
{
word_flags |= FLAG_MULTIPLE_SPACES;
continue; // multiple spaces
}
if((cc == 0x09) || (cc == 0x0a))
{
next_word_flags |= FLAG_MULTIPLE_SPACES; // tab or newline, not a simple space
}
if(space_inserted)
{
words[word_count].length = source_index - words[word_count].sourceix;
@@ -2653,6 +2677,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if(word_count > 0)
{
words[word_count-1].flags |= FLAG_LAST_WORD;
// FLAG_NOSPACE check to avoid recognizing .mr -mr
if((terminator & CLAUSE_DOT) && !(words[word_count-1].flags & FLAG_NOSPACE))
words[word_count-1].flags |= FLAG_HAS_DOT;
}
@@ -2665,7 +2690,9 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
int c_temp;
char *pn;
char *pw;
char number_buf[80];
int nw;
char number_buf[60];
WORD_TAB num_wtab[15]; // copy of 'words', when splitting numbers into parts
// start speaking at a specified word position in the text?
count_words++;
@@ -2718,6 +2745,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
number_buf[0] = ' ';
pn = &number_buf[1];
nx = n_digits;
nw = 0;
while(pn < &number_buf[sizeof(number_buf)-3])
{
@@ -2727,6 +2755,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
*pn++ = c;
if((--nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
{
memcpy(&num_wtab[nw++], &words[ix], sizeof(WORD_TAB)); // copy the 'words' entry for each word of numbers
if(tr->langopts.thousands_sep != ' ')
{
*pn++ = tr->langopts.thousands_sep;
@@ -2746,15 +2776,17 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
pw--;
memcpy(&num_wtab[nw], &words[ix], sizeof(WORD_TAB)*2); // the original number word, and the word after it
// include the next few characters, in case there are an ordinal indicator or other suffix
memcpy(pn, pw, 16);
pn[16] = 0;
nw = 0;
for(pw = &number_buf[1]; pw < pn;)
{
// keep wflags for each part, for FLAG_HYPHEN_AFTER
dict_flags = TranslateWord2(tr, pw, &words[ix], words[ix].pre_pause,0 );
dict_flags = TranslateWord2(tr, pw, &num_wtab[nw++], words[ix].pre_pause,0 );
while(*pw++ != ' ');
words[ix].pre_pause = 0;
}
+6 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -55,6 +55,7 @@
#define FLAG_ALT_TRANS 0x100000 // language specific
#define FLAG_ALT2_TRANS 0x200000 // language specific
#define FLAG_COMBINE 0x400000 // combine with the next word
#define FLAG_ALT3_TRANS 0x800000 // language specific
#define FLAG_ALLOW_DOT 0x01000000 // ignore '.' after word (abbreviation)
#define FLAG_NEEDS_DOT 0x02000000 // only if the word is followed by a dot
@@ -103,6 +104,8 @@
#define FLAG_HYPHEN_AFTER 0x4000
#define FLAG_ORDINAL 0x8000 // passed to TranslateNumber() to indicate an ordinal number
#define FLAG_HAS_DOT 0x10000 // dot after this word
#define FLAG_COMMA_AFTER 0x20000 // comma after this word
#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
#define FLAG_NO_PREFIX 0x20000000
@@ -203,6 +206,7 @@
#define SAYAS_DIGITS1 0xc1
#define CHAR_EMPHASIS 0x0530 // this is an unused character code
#define CHAR_COMMA_BREAK 0x0557 // unused character code
// Rule:
// [4] [match] [1 pre] [2 post] [3 phonemes] 0
@@ -437,6 +441,7 @@ typedef struct {
const unsigned int *replace_chars; // characters to be substitutes
const char *ascii_language; // switch to this language for Latin characters
int max_lengthmod;
int suffix_add_e; // replace a suffix (which has the SUFX_E flag) with this character
} LANGUAGE_OPTIONS;
+1 -1
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *