From 1724355a6c8f68610ad48388448ac8350dcde75a Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Tue, 3 Dec 2019 22:11:21 -0800 Subject: [PATCH] decompose rules to produce rule bundle array for epoch object --- src/PhonoChangeApplier.js | 41 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/PhonoChangeApplier.js b/src/PhonoChangeApplier.js index 90f61ea..7389451 100644 --- a/src/PhonoChangeApplier.js +++ b/src/PhonoChangeApplier.js @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import './PhonoChangeApplier.scss'; -import ls from 'local-storage'; + +// import ls from 'local-storage'; import ProtoLang from './components/ProtoLang'; import Features from './components/Features'; @@ -11,20 +12,24 @@ import Output from './components/Output'; const PhonoChangeApplier = () => { const [ lexicon, setLexicon ] = useState(['mun', 'tʰu', 'tɯm', 'utʰ']); const [ phonemes, setPhonemes ] = useState( - { - n: [ 'occlusive', 'sonorant', 'obstruent', 'nasal', 'alveolar' ], - m: [ 'occlusive', 'sonorant', 'obstruent', 'nasal', 'bilabial' ], - u: [ 'continuant', 'sonorant', 'syllabic', 'high', 'back', 'rounded' ], - ɯ: [ 'continuant', 'sonorant', 'syllabic', 'high', 'back', 'unrounded' ], - t: [ 'occlusive', 'plosive', 'obstruent', 'alveolar' ], - tʰ: [ 'occlusive', 'plosive', 'obstruent', 'alveolar', 'aspirated' ] - } + // ! candidate for trie to avoid situations where >2 graph phonemes + // ! are uncaught by lexeme decomposition when [- feature]/_#']}]); + const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ rounded]>[+ unrounded]/_#']}]); const [ options, setOptions ] = useState({output: 'default', save: false}) const [ results, setResults ] = useState([]) const [ errors, setErrors ] = useState({}) - const [ features, setFeatures ] = useState([]) + const [ features, setFeatures ] = useState( + ['occlusive', 'sonorant', 'obstruent', 'nasal', 'alveolar','bilabial', + 'continuant','syllabic','high','back','rounded','unrounded', 'plosive','aspirated']) const runChanges = e => { e.preventDefault(); @@ -71,6 +76,20 @@ const PhonoChangeApplier = () => { lexicalFeatureBundles.push(lexemeBundle); }) + // decompose rules + let allEpochs = epochs.map(epoch => { + let ruleBundle = epoch.changes.map(rule => { + return { + input: rule.split('>')[0], + result: rule.split('>')[1].split('/')[0], + preInput: rule.split('/')[1].split('_')[0], + postInput: rule.split('/')[1].split('_')[1], + } + }) + return {epoch: epoch.name, rules: ruleBundle} + }) + + console.log(allEpochs) // apply sound changes // handle output