G2P: Added fallback rules to prevent illegal results

This commit is contained in:
Daniel Wolf 2016-12-20 21:21:26 +01:00
parent faea06933b
commit fa0aff0012
2 changed files with 18 additions and 0 deletions

View File

@ -206,3 +206,10 @@
{ wregex(L"l(l)"), L"$1" },
{ wregex(L"f(f)"), L"$1" },
{ wregex(L"z(z)"), L"$1" },
// There are a number of cases not covered by these rules.
// Let's add some reasonable fallback rules.
{ wregex(L"a"), L"â" },
{ wregex(L"e"), L"@" },
{ wregex(L"i"), L"ë" },
{ wregex(L"o"), L"ö" },
{ wregex(L"q"), L"k" },

View File

@ -69,6 +69,17 @@ end
# Read rules
lines = File.read('../../lib/soundchange/english.sc', :encoding => 'iso-8859-1').split(/\r?\n/)
# Add supplementary rules
lines.push(
'* There are a number of cases not covered by these rules.',
'* Let\'s add some reasonable fallback rules.',
'a/â/_',
'e/@/_',
'i/ë/_',
'o/ö/_',
'q/k/_'
)
# Parse character class definitions
characterClassLineCount = 0
lines.each_with_index do |line, index|