Commit 1ac41617 authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

modifs pour phonographe mandarin

parent fee5a654
......@@ -745,15 +745,200 @@ function playEffect(effect) {
////////////////////////
// ÉCRITURE EN MANDARIN
var currentPinyin = "";
var currentSyll = []; // [ "phon_p_h", "phon_a", "ton1"]
function zhPhon(rectId) {
console.log(rectId);
var phon = rectId.replace('rect_', 'phon_').replace('-t', '').replace('-f', '')
if (gradientToRight.includes(phon)) { phon = phon+'-h' } // gradients à l'horizontal pour affriquées
console.log("zhPhon",rectId, phon)
if (listinitiales.includes(rectId)) currentSyll = [];
currentSyll.push(phon)
var currentAPI = ""
for (var ph=0; ph<currentSyll.length; ph++) {
var phon = currentSyll[ph];
console.log("PHON=",phon);
if (phon in phon2api) currentAPI += phon2api[phon];
else if (["0","1","2","3","4","5"].includes(phon[8])) currentAPI += phon[8]
else console.log("MANQUE",phon,"DANS PHON2API !")
}
console.log(currentSyll, currentAPI);
var [charlist, freqlist] = getChars(currentAPI);
if (charlist.length>0) {
var hanDiv = document.createElement("div");
hanDiv.id = "hanDiv";
hanDiv.style.width = "100%";
hanDiv.style.height = "100%";
hanDiv.classList = "d-flex justify-content-evenly align-content-around flex-wrap";
document.getElementById('graphiesZone').innerHTML = "";
document.getElementById('graphiesZone').appendChild(hanDiv);
document.getElementById('graphiesZone').appendChild(hanDiv);
for(let char=0; char<charlist.length; char++) {
console.log(charlist[char],freqlist[char]);
var newHan = document.createElement('div');
newHan.innerHTML = charlist[char];
newHan.classList = ["han"];
hanDiv.appendChild(newHan);
}
}
}
function recupTone(tonId){
zhPhon(tonId)
}
function getChars(pinyin) {
var chars = syll2chars[pinyin];
for(var char in chars) {
console.log(char, chars[char]);
function getChars(api) {
var charlist = [];
var freqlist = [];
var x = ""; // api sans ton
var y = ""; // ton seul
if (["0","1","2","3","4","5"].includes(api[api.length-1])) {
x = api.slice(0,api.length-1);
y = api[api.length-1];
}
if (x in syllonAPI2pinyin && syllonAPI2pinyin[x]+y in syll2chars) {
var pinyin = syllonAPI2pinyin[x]+y;
var chars = syll2chars[pinyin];
for(var char in chars) {
charlist.push(char);
freqlist.push(chars[char]);
}
}
return [charlist, freqlist]
}
function writeHan(currentSyll){
}
let syll = {
"initiale": { "rect":"", "phon":""},
"glide": { "rect":"", "phon":""},
"tonale": { "rect":"", "phon":""},
"finale": { "rect":"", "phon":""},
"tone": 0,
"structure": 0 // millier:initiale, centaine:glide, dizaine:tonale, unité:finale. Ex. 10 = tonale seule; 11 = tonale+finale; 1010 = initiale+tonale
}
function makeNewSyll(syll) {
let newSyll = document.createElement('div')
newSyll.classList = "syll"
let newInitiale = document.createElement('div')
let newGlide = document.createElement('div')
let newTonale = document.createElement('div')
let newFinale = document.createElement('div')
structString = syll.structure.toString()
if (structString == "0") {
prop = "_1"
} else if (syll.tonale.phon == "") {
prop = "_" + (structString.match(/1/g).length+1)
} else {
prop = "_" + structString.match(/1/g).length
}
if (structString.length >= 4 && structString[structString.length-4] == 1) newInitiale.classList = prop + ' ' + syll.initiale.phon + ' noTextClip'
if (structString.length >= 3 && structString[structString.length-3] == 1) newGlide.classList = prop + ' ' + syll.glide.phon + ' noTextClip'
if (structString.length >= 2 && structString[structString.length-2] == 1) newTonale.classList = prop + ' ' + syll.tonale.phon + ' noTextClip'
if (structString.length >= 1 && structString[structString.length-1] == 1) newFinale.classList = prop + ' finale ' + syll.finale.phon + ' noTextClip'
newSyll.append(newInitiale, newGlide, newTonale, newFinale)
let newDivTons = document.createElement('div')
newDivTons.classList.add('divTons')
if (syll.tone == 1){ addTone(newDivTons, 't1'); addTone(newDivTons, 't4')}
if (syll.tone == 2){ addTone(newDivTons, 't2'); addTone(newDivTons, 't4')}
if (syll.tone == 3){ addTone(newDivTons, 't2'); addTone(newDivTons, 't8'); addTone(newDivTons, 't4')}
if (syll.tone == 4){ addTone(newDivTons, 't1'); addTone(newDivTons, 't6')}
function addTone(el, toneEl) {
let newTone = document.createElement('div')
newTone.classList.add('ton')
newTone.style.display = 'block'
newTone.classList.add(toneEl)
el.appendChild(newTone)
}
}
\ No newline at end of file
newSyll.appendChild(newDivTons)
return newSyll
}
let listinitiales = [
'rect_p',
'rect_p_h',
'rect_m',
'rect_f',
'rect_t',
'rect_t_h',
'rect_n',
'rect_l',
'rect_s',
'rect_ts',
'rect_t_hs',
'rect_s_retr',
'rect_ts_retr',
'rect_t_hs_retr',
'rect_z_retr',
'rect_s_slash',
'rect_ts_slash',
'rect_t_hs_slash',
'rect_k',
'rect_x',
'rect_k_h'
]
let gradientToRight = [
'phon_ts',
'phon_t_hs',
'phon_ts_retr',
'phon_t_hs_retr',
'phon_ts_slash',
'phon_t_hs_slash'
]
let listglides = [
'rect_j',
'rect_h_maj',
'rect_w'
]
let listvoyelles = [
'rect_i',
'rect_y',
'rect_1',
'rect_u',
'rect_7',
'rect_o',
'rect_a',
'rect_e',
'rect_e_maj',
'rect_wo',
'rect_m_maj7',
'rect_7rho',
'rect_arho'
]
let listtonales = [
'rect_i-t',
'rect_y-t',
'rect_u-t',
'rect_e-t',
'rect_7-t',
'rect_o-t',
'rect_e_maj-t',
'rect_a-t'
]
let listfinales = [
'rect_rho',
'rect_j-f',
'rect_w-f',
'rect_rho-f',
'rect_n-f',
'rect_n_maj-f'
]
\ No newline at end of file
......@@ -174,16 +174,6 @@ var syll2chars = {
"毿": 2,
"": 1
},
"c": {
"C": 12,
"c": 3
},
"p": {
"P": 20
},
"q": {
"Q": 12
},
"wu3": {
"5": 4,
"": 1,
......@@ -276,10 +266,6 @@ var syll2chars = {
"": 4,
"": 1
},
"a": {
"A": 22,
"a": 4
},
"zhi4": {
"": 368,
"": 219,
......@@ -344,12 +330,6 @@ var syll2chars = {
"": 4,
"": 1
},
"b": {
"B": 16
},
"g": {
"G": 10
},
"ka1": {
"": 45,
"": 78,
......@@ -640,14 +620,6 @@ var syll2chars = {
"": 1,
"": 1
},
"d": {
"D": 2,
"d": 2
},
"n": {
"N": 9,
"n": 3
},
"jian4": {
"": 51,
"": 2,
......@@ -708,10 +680,6 @@ var syll2chars = {
"": 2,
"": 2
},
"e": {
"E": 1,
"e": 1
},
"zai3": {
"": 32,
"": 40,
......@@ -776,9 +744,6 @@ var syll2chars = {
"": 1,
"": 3
},
"h": {
"H": 2
},
"qiao2": {
"": 226,
"": 87,
......@@ -796,9 +761,6 @@ var syll2chars = {
"": 1,
"": 1
},
"i": {
"I": 3
},
"ju4": {
"": 206,
"㨿": 2,
......@@ -837,12 +799,6 @@ var syll2chars = {
"": 1,
"": 4
},
"j": {
"J": 2
},
"k": {
"K": 25
},
"fu2": {
"": 295,
"": 306,
......@@ -1050,10 +1006,6 @@ var syll2chars = {
"": 1,
"": 1
},
"l": {
"L": 3,
"l": 3
},
"zhao4": {
"": 202,
"": 1,
......@@ -1074,13 +1026,6 @@ var syll2chars = {
"": 3,
"": 1
},
"m": {
"M": 5,
"m": 1
},
"v": {
"V": 5
},
"duan4": {
"": 87,
"": 338,
......@@ -1134,10 +1079,6 @@ var syll2chars = {
"": 1,
"": 2
},
"o": {
"O": 9,
"o": 8
},
"beng1": {
"": 23,
"": 1,
......@@ -1147,10 +1088,6 @@ var syll2chars = {
"": 1,
"": 2
},
"s": {
"S": 4,
"s": 3
},
"tui3": {
"": 102,
"": 1
......@@ -1177,10 +1114,6 @@ var syll2chars = {
"": 2,
"": 2
},
"u": {
"U": 13,
"u": 1
},
"min2": {
"": 658,
"": 1,
......@@ -1202,10 +1135,6 @@ var syll2chars = {
"": 1,
"": 1
},
"r": {
"R": 2,
"r": 2
},
"kou4": {
"": 78,
"": 2,
......@@ -1271,12 +1200,6 @@ var syll2chars = {
"": 1,
"": 1
},
"t": {
"T": 13
},
"f": {
"F": 1
},
"ka3": {
"": 475,
"": 2,
......@@ -1284,9 +1207,6 @@ var syll2chars = {
"": 1,
"": 1
},
"y": {
"y": 3
},
"lao3": {
"": 573,
"": 1,
......@@ -1741,9 +1661,6 @@ var syll2chars = {
"": 2,
"": 1
},
"x": {
"X": 4
},
"jiang4": {
"": 90,
"": 114,
......@@ -1772,9 +1689,6 @@ var syll2chars = {
"": 1,
"": 1
},
"w": {
"w": 3
},
"jie3": {
"": 35,
"": 399,
......
let syllonAPI2pinyin = {
"a": "a",
"aj": "ai",
"an": "an",
"": "ang",
"aw": "ao",
"pa": "ba",
"paj": "bai",
"pan": "ban",
"paŋ": "bang",
"paw": "bao",
"pɛj": "bei",
"pej": "bei",
"pɤn": "ben",
"poŋ": "beng",
"pɤŋ": "beng",
"pi": "bi",
"pjɛn": "bian",
"pjaw": "biao",
"pje": "bie",
"pjɛ": "bie",
"pjin": "bin",
"pin": "bin",
"pjiŋ": "bing",
"piŋ": "bing",
"pwo": "bo",
"pu": "bu",
"tsʰa": "ca",
"tsʰaj": "cai",
"tsʰan": "can",
"tsʰaŋ": "cang",
"tsʰaw": "cao",
"tsʰɯɤ": "ce",
"tsʰɤ": "ce",
"tsʰɤn": "cen",
"tsʰɤŋ": "ceng",
"tʂʰa": "cha",
"tʂʰaj": "chai",
"tʂʰan": "chan",
"tʂʰaŋ": "chang",
"tʂʰaw": "chao",
"tʂʰɯɤ": "che",
"tʂʰɤ": "che",
"tʂʰɤn": "chen",
"tʂʰɤŋ": "cheng",
"tʂʰɨ": "chi",
"tʂʰuŋ": "chong",
"tʂʰwuŋ": "chong",
"tʂʰwoŋ": "chong",
"tʂʰoŋ": "chong",
"tʂʰwɤŋ": "chong",
"tʂʰow": "chou",
"tʂʰu": "chu",
"tʂʰwaj": "chuai",
"tʂʰwan": "chuan",
"tʂʰwaŋ": "chuang",
"tʂʰwɛj": "chui",
"tʂʰwej": "chui",
"tʂʰwe": "chui",
"tʂʰwɛ": "chui",
"tʂʰwun": "chun",
"tʂʰwɤn": "chun",
"tʂʰwo": "chuo",
"tsʰi": "ci",
"tsʰuŋ": "cong",
"tsʰwuŋ": "cong",
"tsʰwoŋ": "cong",
"tsʰoŋ": "cong",
"tsʰwɤŋ": "cong",
"tsʰu": "cu",
"tsʰwan": "cuan",
"tsʰwɛj": "cui",
"tsʰwej": "cui",
"tsʰwe": "cui",
"tsʰwɛ": "cui",
"tsʰwun": "cun",
"tsʰwɤn": "cun",
"tsʰwo": "cuo",
"ta": "da",
"taj": "dai",
"tan": "dan",
"taŋ": "dang",
"taw": "dao",
"tɯɤ": "de",
"": "de",
"tɛj": "dei",
"tej": "dei",
"tɤŋ": "deng",
"ti": "di",
"tjɛn": "dian",
"tjaw": "diao",
"tje": "die",
"tjɛ": "die",
"tjiŋ": "ding",
"tiŋ": "ding",
"tjow": "diu",
"tjo": "diu",
"tuŋ": "dong",
"twuŋ": "dong",
"twoŋ": "dong",
"toŋ": "dong",
"twɤŋ": "dong",
"tow": "dou",
"tu": "du",
"twan": "duan",
"twɛj": "dui",
"twej": "dui",
"twe": "dui",
"twɛ": "dui",
"twun": "dun",
"twɤn": "dun",
"two": "duo",
"ɯɤ": "e",
"ɤ": "e",
"ɛj": "ei",
"ej": "ei",
"ɤn": "en",
"ɤŋ": "eng",
"ɤ˞": "er",
"": "er",
"fa": "fa",
"fan": "fan",
"faŋ": "fang",
"fɛj": "fei",
"fej": "fei",
"fɤn": "fen",
"foŋ": "feng",
"fɤŋ": "feng",
"fwo": "fo",
"fow": "fou",
"fu": "fu",
"ka": "ga",
"kaj": "gai",
"kan": "gan",
"kaŋ": "gang",
"kaw": "gao",
"kɯɤ": "ge",
"": "ge",
"kɛj": "gei",
"kej": "gei",
"kɤn": "gen",
"kɤŋ": "geng",
"kuŋ": "gong",
"kwuŋ": "gong",
"kwoŋ": "gong",
"koŋ": "gong",
"kwɤŋ": "gong",
"kow": "gou",
"ku": "gu",
"kwa": "gua",
"kwaj": "guai",
"kwan": "guan",
"kwaŋ": "guang",
"kwɛj": "gui",
"kwej": "gui",
"kwe": "gui",
"kwɛ": "gui",
"kwun": "gun",
"kwɤn": "gun",
"kwo": "guo",
"xa": "ha",
"xaj": "hai",
"xan": "han",
"xaŋ": "hang",
"xaw": "hao",
"xɯɤ": "he",
"": "he",
"xɛj": "hei",
"xej": "hei",
"xɤn": "hen",
"xɤŋ": "heng",
"xuŋ": "hong",
"xwuŋ": "hong",
"xwoŋ": "hong",
"xoŋ": "hong",
"xwɤŋ": "hong",
"xow": "hou",
"xu": "hu",
"xwa": "hua",
"xwaj": "huai",
"xwan": "huan",
"xwaŋ": "huang",
"xwɛj": "hui",
"xwej": "hui",
"xwe": "hui",
"xwɛ": "hui",
"xwun": "hun",
"xwɤn": "hun",
"xwo": "huo",