Make the rplanguage contrib give better error on grammar/phoneme mismatch
This commit is contained in:
parent
e6f1cfbf64
commit
d3b59b2312
1 changed files with 8 additions and 2 deletions
|
|
@ -64,7 +64,7 @@ Usage:
|
||||||
"oy ua uh uw y p b t d f v t dh s z sh zh ch jh k " \
|
"oy ua uh uw y p b t d f v t dh s z sh zh ch jh k " \
|
||||||
"ng g m n l r w",
|
"ng g m n l r w",
|
||||||
vowels = "eaoiuy"
|
vowels = "eaoiuy"
|
||||||
grammar = "v vv vvc vcc vvcc cvvc vccv vvccv vcvccv vcvcvcc vvccvvcc " \
|
prammar = "v vv vvc vcc vvcc cvvc vccv vvccv vcvccv vcvcvcc vvccvvcc " \
|
||||||
"vcvvccvvc cvcvvcvvcc vcvcvvccvcvv",
|
"vcvvccvvc cvcvvcvvcc vcvcvvccvcvv",
|
||||||
word_length_variance = 1
|
word_length_variance = 1
|
||||||
noun_postfix = "'la"
|
noun_postfix = "'la"
|
||||||
|
|
@ -280,7 +280,13 @@ class LanguageHandler(DefaultScript):
|
||||||
# use the corresponding length
|
# use the corresponding length
|
||||||
structure = choice(grammar[wlen])
|
structure = choice(grammar[wlen])
|
||||||
for match in _RE_GRAMMAR.finditer(structure):
|
for match in _RE_GRAMMAR.finditer(structure):
|
||||||
new_word += choice(grammar2phonemes[match.group()])
|
try:
|
||||||
|
new_word += choice(grammar2phonemes[match.group()])
|
||||||
|
except IndexError:
|
||||||
|
raise IndexError(
|
||||||
|
"Could not find a matching phoneme for the grammar "
|
||||||
|
f"'{match.group()}'. Make there is at least one phoneme matching this "
|
||||||
|
"combination of consonants and vowels.")
|
||||||
translation[word.lower()] = new_word.lower()
|
translation[word.lower()] = new_word.lower()
|
||||||
|
|
||||||
if manual_translations:
|
if manual_translations:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue