Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
lancejpollard committed May 17, 2023
1 parent 84b4f0a commit 9b3f8f1
Show file tree
Hide file tree
Showing 7 changed files with 562 additions and 459 deletions.
3 changes: 3 additions & 0 deletions form.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const CONSONANTS = [
{ i: 's!', o: 's93', name: 'Ejective s sound' },
{ i: 's~', o: 's7', name: 'Dental s sound' },
{ i: 's', o: 's', name: 'S sound' },
{ i: 'Fw~', o: 'f633', name: 'Labial labialized f sound' },
{ i: 'F', o: 'f6', name: 'Labial f sound' },
{ i: 'fy~', o: 'f3', name: 'Palatalized f sound' },
{ i: 'fG~', o: 'f4', name: 'Velarized f sound' },
Expand Down Expand Up @@ -274,6 +275,7 @@ const CONSONANTS = [
{ i: 'xG~', o: 'x6', name: 'Velarized x sound' },
{ i: 'xy~h~', o: 'x^5', name: 'Aspirated palatalized x sound' },
{ i: 'xy~', o: 'x5', name: 'Palatalized x sound' },
{ i: 'x@y~', o: 'x005', name: 'Tense palatalized x sound' },
{ i: 'xw~', o: 'x55', name: 'Labialized x sound' },
{ i: 'x!', o: 'x05', name: 'Ejective sh sound' },
{ i: 'Xh~', o: 'x4^', name: 'Aspirated Indian sh sound' },
Expand All @@ -284,6 +286,7 @@ const CONSONANTS = [
{ i: 'x', o: 'x', name: 'Sh sound' },
{ i: 'wh!', o: 'w^0', name: 'Voiceless w sound' },
{ i: 'w!', o: 'w05', name: 'Ejective w sound' },
{ i: 'W', o: 'w4', name: 'Velar approximant w sound' },
{ i: 'w', o: 'w', name: 'W sound' },
{ i: 'yw~', o: 'y33', name: 'Labialized y sound' },
{ i: 'yh!', o: 'y%9', name: 'Voiceless y sound' },
Expand Down
35 changes: 27 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@drumwork/tone",
"version": "4.3.0",
"version": "4.3.1",
"main": "form.js",
"dependencies": {
"@lancejpollard/script-tree": "^1.1.0"
Expand All @@ -11,6 +11,7 @@
"pronunciation.js"
],
"devDependencies": {
"@drumwork/call": "^4.0.5",
"puppeteer": "^14.4.0"
}
}
63 changes: 46 additions & 17 deletions pronunciation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const m = {

module.exports = convertIPAToCall

function convertIPAToCall(ipa) {
function convertIPAToCall(ipa, options = { tones: true }) {
const result = {
last: {
consonants: [],
Expand Down Expand Up @@ -190,10 +190,12 @@ function convertIPAToCall(ipa) {
addConsonant('g?')
break
case 'ɟ':
addConsonant('gy~')
addConsonant('g')
addFeature('palatalization')
break
case 'ʄ':
addConsonant('g?y~')
addConsonant('g?')
addFeature('palatalization')
break
case 'ħ':
addConsonant('Hh!')
Expand All @@ -211,10 +213,12 @@ function convertIPAToCall(ipa) {
addConsonant('H')
break
case 'ç':
addConsonant('hy~')
addConsonant('h')
addFeature('palatalization')
break
case 'c':
addConsonant('ky~')
addConsonant('k')
addFeature('palatalization')
break
case 'ʐ':
addConsonant('J')
Expand All @@ -226,7 +230,8 @@ function convertIPAToCall(ipa) {
addConsonant('Z')
break
case 'ʑ':
addConsonant('jy~')
addConsonant('j')
addFeature('palatalization')
break
case 'k':
addConsonant('k')
Expand All @@ -253,7 +258,8 @@ function convertIPAToCall(ipa) {
addConsonant('q')
break
case 'ɲ':
addConsonant('ny~')
addConsonant('n')
addFeature('palatalization')
break
case 'l':
addConsonant('l')
Expand All @@ -262,7 +268,8 @@ function convertIPAToCall(ipa) {
addConsonant('L')
break
case 'ʎ':
addConsonant('ly~')
addConsonant('l')
addFeature('palatalization')
break
case 'ǁ':
addConsonant('l*')
Expand Down Expand Up @@ -335,7 +342,8 @@ function convertIPAToCall(ipa) {
addConsonant('X')
break
case 'ɕ':
addConsonant('xy~')
addConsonant('x')
addFeature('palatalization')
break
case 'j':
addConsonant('y')
Expand Down Expand Up @@ -376,6 +384,12 @@ function convertIPAToCall(ipa) {
case 'ɝ':
addVowel('u~')
break
case 'ŏ':
addVowel('o')
break
case 'ĕ':
addVowel('e')
break
case `${m.d.tilde}`:
addFeature(`nasalization`)
break
Expand All @@ -386,7 +400,7 @@ function convertIPAToCall(ipa) {
addPunctuation('=.')
break
case '-':
addPunctuation('-')
addPunctuation('=-')
break
case '\u031d':
break
Expand All @@ -401,10 +415,6 @@ function convertIPAToCall(ipa) {
break
case '\u0339':
break
case '\u0348':
break
case '\u0348':
break
case '\u035c':
break
case '\u0361':
Expand All @@ -420,6 +430,9 @@ function convertIPAToCall(ipa) {
case '\u02FD': // apical
case '\u033A': // apical
break
case '(':
case ')':
break
case m.u.tilde:
addFeature('nasalization')
break
Expand Down Expand Up @@ -556,6 +569,10 @@ function convertIPAToCall(ipa) {
addVowel('i')
result.last.vowels = []
break
case 'é':
addVowel('e')
captureAllTones('˦')
result.last.vowels = []
break
case 'à':
addVowel('a')
Expand Down Expand Up @@ -648,6 +665,10 @@ function convertIPAToCall(ipa) {
return serialize(result)

function addTones(tones) {
if (!options.tones) {
return
}

const vowels = result.last.vowels
let i = 0

Expand Down Expand Up @@ -767,6 +788,14 @@ function convertIPAToCall(ipa) {
result.last.consonant.stop = true
break
case 'tense':
if (result.last.consonant.value.match('x')) {
const second =
result.last.consonants[result.last.consonants.length - 2]
if (second && second.value.match(/[ptk]/)) {
second.tense = true
break
}
}
result.last.consonant.tense = true
break
case 'long':
Expand Down Expand Up @@ -817,6 +846,9 @@ function serialize(result) {
if (node.nasalization) {
out.push('&')
}
if (node.tense) {
out.push('@')
}
if (node.dental) {
out.push('~')
}
Expand All @@ -838,9 +870,6 @@ function serialize(result) {
if (node.implosion) {
out.push('?')
}
if (node.tense) {
out.push('@')
}
if (node.voice === false) {
out.push('h!')
}
Expand Down
24 changes: 24 additions & 0 deletions syllable.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,42 @@ const SYMBOL = {

m: { type: 'consonant', value: 'm' },
n: { type: 'consonant', value: 'n' },
N: { type: 'consonant', value: 'N' },
q: { type: 'consonant', value: 'q' },
g: { type: 'consonant', value: 'g' },
d: { type: 'consonant', value: 'd' },
b: { type: 'consonant', value: 'b' },
p: { type: 'consonant', value: 'p' },
t: { type: 'consonant', value: 't' },
T: { type: 'consonant', value: 'T' },
k: { type: 'consonant', value: 'k' },
K: { type: 'consonant', value: 'K' },
h: { type: 'consonant', value: 'h' },
H: { type: 'consonant', value: 'H' },
s: { type: 'consonant', value: 's' },
S: { type: 'consonant', value: 'S' },
f: { type: 'consonant', value: 'f' },
F: { type: 'consonant', value: 'F' },
V: { type: 'consonant', value: 'V' },
v: { type: 'consonant', value: 'v' },
z: { type: 'consonant', value: 'z' },
Z: { type: 'consonant', value: 'Z' },
j: { type: 'consonant', value: 'j' },
J: { type: 'consonant', value: 'J' },
x: { type: 'consonant', value: 'x' },
X: { type: 'consonant', value: 'X' },
c: { type: 'consonant', value: 'c' },
'C~': { type: 'consonant', value: 'C~' },
C: { type: 'consonant', value: 'C' },
y: { type: 'consonant', value: 'y' },
W: { type: 'consonant', value: 'W' },
w: { type: 'consonant', value: 'w' },
Q: { type: 'consonant', value: 'Q' },
"'": { type: 'consonant', value: "'" },
l: { type: 'consonant', value: 'l' },
L: { type: 'consonant', value: 'L' },
r: { type: 'consonant', value: 'r' },
R: { type: 'consonant', value: 'R' },
'!': { truncation: true },
_: { elongation: true },
'^': { stress: true },
Expand All @@ -92,6 +105,7 @@ module.exports = parse
function parse(string) {
let x = string
const chunks = []
let i = 0
while (x.length) {
let matched = false
symbol: for (const key in SYMBOL) {
Expand All @@ -106,11 +120,13 @@ function parse(string) {
}
}
x = x.slice(key.length)
i += key.length
matched = true
break symbol
}
}
if (!matched) {
console.error(string.slice(0, i))
throw new Error('Invalid characters found')
}
}
Expand Down Expand Up @@ -150,6 +166,14 @@ function demarcate(chunks) {
marks.push(mark)
break
}
case 'o':
switch (chunk.value) {
case 'a':
case 'A':
mark = { base: i - 1, head: i - 1 }
marks.push(mark)
break
}
}
break
}
Expand Down
Loading

0 comments on commit 9b3f8f1

Please sign in to comment.