freeze to change structure of phoneme and epoch hooks

This commit is contained in:
Sorrel Bri 2019-12-04 12:23:14 -08:00
parent 1724355a6c
commit 5fd4406675

View file

@ -23,7 +23,7 @@ const PhonoChangeApplier = () => {
: [ 'occlusive', 'plosive', 'obstruent', 'alveolar', 'aspirated' ], : [ 'occlusive', 'plosive', 'obstruent', 'alveolar', 'aspirated' ],
} }
); );
const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ rounded]>[+ unrounded]/_#']}]); const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ rounded]>[- rounded + unrounded]/_#']}]);
const [ options, setOptions ] = useState({output: 'default', save: false}) const [ options, setOptions ] = useState({output: 'default', save: false})
const [ results, setResults ] = useState([]) const [ results, setResults ] = useState([])
const [ errors, setErrors ] = useState({}) const [ errors, setErrors ] = useState({})
@ -73,17 +73,20 @@ const PhonoChangeApplier = () => {
} }
startingIndex = index; startingIndex = index;
}) })
lexemeBundle.unshift(['#'])
lexemeBundle.push(['#'])
lexicalFeatureBundles.push(lexemeBundle); lexicalFeatureBundles.push(lexemeBundle);
}) })
console.log(lexicalFeatureBundles)
// decompose rules // decompose rules
let allEpochs = epochs.map(epoch => { let allEpochs = epochs.map(epoch => {
let ruleBundle = epoch.changes.map(rule => { let ruleBundle = epoch.changes.map(rule => {
return { return {
input: rule.split('>')[0], input: rule.split('>')[0].replace(/\[|\]|\+/g, '').trim(),
result: rule.split('>')[1].split('/')[0], result: rule.split('>')[1].split('/')[0],
preInput: rule.split('/')[1].split('_')[0], preInput: rule.split('/')[1].split('_')[0].replace(/\[|\]|\+/g, '').trim(),
postInput: rule.split('/')[1].split('_')[1], postInput: rule.split('/')[1].split('_')[1].replace(/\[|\]|\+/g, '').trim(),
} }
}) })
return {epoch: epoch.name, rules: ruleBundle} return {epoch: epoch.name, rules: ruleBundle}
@ -91,6 +94,19 @@ const PhonoChangeApplier = () => {
console.log(allEpochs) console.log(allEpochs)
// apply sound changes // apply sound changes
allEpochs.reduce((diachronicLexicon, epoch) => {
let startingLexicon = diachronicLexicon.length
? diachronicLexicon[diachronicLexicon.length - 1]
: lexicalFeatureBundles;
let currentRules = epoch.rules;
let resultingLexicon = startingLexicon.forEach(lexeme => {
currentRules.forEach(rule => {
let ruleEnvironment = [[rule.preInput], [rule.input], [rule.postInput]];
console.log(ruleEnvironment)
})
})
diachronicLexicon.push(resultingLexicon)
},[])
// handle output // handle output
} }