decompose lexemes into segmental feature bundles
This commit is contained in:
parent
946f1cb930
commit
544f06d4d4
1 changed files with 35 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import './PhonoChangeApplier.scss';
|
import './PhonoChangeApplier.scss';
|
||||||
|
import ls from 'local-storage';
|
||||||
|
|
||||||
import ProtoLang from './components/ProtoLang';
|
import ProtoLang from './components/ProtoLang';
|
||||||
import Features from './components/Features';
|
import Features from './components/Features';
|
||||||
|
@ -8,9 +9,16 @@ import Options from './components/Options';
|
||||||
import Output from './components/Output';
|
import Output from './components/Output';
|
||||||
|
|
||||||
const PhonoChangeApplier = () => {
|
const PhonoChangeApplier = () => {
|
||||||
const [ lexicon, setLexicon ] = useState(['one']);
|
const [ lexicon, setLexicon ] = useState(['mun', 'tʰu', 'tɯm', 'utʰ']);
|
||||||
const [ phonemes, setPhonemes ] = useState(
|
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' ],
|
||||||
|
tʰ: [ 'occlusive', 'plosive', 'obstruent', 'alveolar', 'aspirated' ]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[- feature]/_#']}]);
|
const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[- feature]/_#']}]);
|
||||||
const [ options, setOptions ] = useState({output: 'default', save: false})
|
const [ options, setOptions ] = useState({output: 'default', save: false})
|
||||||
|
@ -23,8 +31,8 @@ const PhonoChangeApplier = () => {
|
||||||
let ruleError = epochs.reduce((errorObject, epoch) => {
|
let ruleError = epochs.reduce((errorObject, epoch) => {
|
||||||
epoch.changes.map((change, index) => {
|
epoch.changes.map((change, index) => {
|
||||||
if (!change.match(/>.*\/.*_/)) errorObject[epoch.name]
|
if (!change.match(/>.*\/.*_/)) errorObject[epoch.name]
|
||||||
? errorObject[epoch.name].push(index)
|
? errorObject[epoch.name].push(index)
|
||||||
: errorObject[epoch.name] = [index]
|
: errorObject[epoch.name] = [index]
|
||||||
})
|
})
|
||||||
return errorObject;
|
return errorObject;
|
||||||
}, {})
|
}, {})
|
||||||
|
@ -32,7 +40,29 @@ const PhonoChangeApplier = () => {
|
||||||
if (Object.entries(ruleError).length) return setErrors(ruleError)
|
if (Object.entries(ruleError).length) return setErrors(ruleError)
|
||||||
setErrors({});
|
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 (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue