decompose lexemes into segmental feature bundles

This commit is contained in:
Sorrel Bri 2019-12-03 17:18:53 -08:00
parent 946f1cb930
commit 544f06d4d4

View file

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import './PhonoChangeApplier.scss';
import ls from 'local-storage';
import ProtoLang from './components/ProtoLang';
import Features from './components/Features';
@ -8,9 +9,16 @@ import Options from './components/Options';
import Output from './components/Output';
const PhonoChangeApplier = () => {
const [ lexicon, setLexicon ] = useState(['one']);
const [ lexicon, setLexicon ] = useState(['mun', 'tʰu', 'tɯm', 'utʰ']);
const [ phonemes, setPhonemes ] = useState(
{ phoneme: [ 'feature' ] }
{
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' ],
: [ 'occlusive', 'plosive', 'obstruent', 'alveolar', 'aspirated' ]
}
);
const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[- feature]/_#']}]);
const [ options, setOptions ] = useState({output: 'default', save: false})
@ -32,7 +40,29 @@ const PhonoChangeApplier = () => {
if (Object.entries(ruleError).length) return setErrors(ruleError)
setErrors({});
// setResults
// decompose Lexical Items
// moving window on phonemes of each lexical item
let lexicalFeatureBundles = []
lexicon.forEach(lexeme => {
let lexemeBundle = [];
let startingIndex = 0;
let lastIndex = lexeme.length - 1;
[...lexeme].forEach((_, index) => {
if (phonemes[lexeme.slice(startingIndex, index + 1)] && index !== lastIndex) return;
if (phonemes[lexeme.slice(startingIndex, index + 1)]) return lexemeBundle.push(phonemes[lexeme.slice(startingIndex)])
if (index !== 0 && index !== lastIndex) lexemeBundle.push(phonemes[lexeme.slice(startingIndex, index)])
if (index === lastIndex) {
lexemeBundle.push(phonemes[lexeme.slice(startingIndex, index)])
lexemeBundle.push(phonemes[lexeme.slice(index)])
}
startingIndex = index;
})
lexicalFeatureBundles.push({[lexeme]: lexemeBundle});
})
console.log(lexicalFeatureBundles)
// apply sound changes
// handle output
}
return (