patch transformLexeme to remove empty phoneme object in case of deletion

This commit is contained in:
Sorrel Bri 2020-02-19 18:36:42 -08:00
parent 07be982b51
commit 42f0b179c8
2 changed files with 4 additions and 2 deletions

View file

@ -14,8 +14,8 @@ export const initState = (changesArgument: number): stateType => {
'[+ occlusive - nasal]>[+ occlusive + nasal]/n_.',
'a>ɯ/._#',
'[+ sonorant - low rounded high back]>0/._.',
// 'nn>nun/._.',
// '[+ nasal][+ obstruent]>[+ nasal obstruent aspirated ]/#_.',
// 'nn>nun/._.',
// '[+ sonorant rounded]>[+ sonorant - rounded]/._#'
]
}

View file

@ -183,6 +183,8 @@ export const transformLexeme = (lexemeBundle, rule, features) => {
if (!isEnvironmentBoundByRule([phoneme], position)) return [...newLexeme, phoneme];
if (!isEnvironmentBoundByRule(lexemeBundle.slice(index, index + post.length), post)) return [...newLexeme, phoneme];
const newPhoneme = swapPhoneme(phoneme, rule.newFeatures[0], features);
// if deletion occurs
if (!newPhoneme.grapheme) return [ ...newLexeme] ;
return [...newLexeme, newPhoneme];
}, [])
return newLexeme;
@ -212,7 +214,7 @@ export const run = (state: stateType, action: resultsAction): stateType => {
const lexiconBundle = formBundleFromLexicon(lexicon)(phones);
const passResults = transformLexicon(lexiconBundle)(ruleBundle)(features);
const stringifiedPassResults = passResults.map(stringifyResults);
console.log(passResults)
const pass = {
pass: epoch.name,
lexicon: stringifiedPassResults