Upload Kuli Beta
All checks were successful
Deploy Online Pages / Pages-Deployment (push) Successful in 22s

This commit is contained in:
halsamen 2025-08-15 13:18:42 +09:00
parent d7cb005a68
commit 3dcb256229
7 changed files with 252 additions and 94 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>苦力</title>
<title>苦力 Beta</title>
</head>
<body>
<div id="hamburger"><span></span><span></span><span></span></div>
@ -43,9 +43,10 @@
<div id="replay">重新开始</div>
</body>
<!--<audio src="../../src/startQuiz.mp3" id="startSound"></audio>-->
<audio src="src/correct.wav" id="corrSound"></audio>
<audio src="src/correct.mp3" id="corrSound"></audio>
<audio src="src/correct2.mp3" id="corrSound2"></audio>
<audio src="src/wrong.wav" id="wrongSound"></audio>
<script src="src/words_list.js"></script>
<script src="mkWrongChoice.js"></script>
<script src="script.js"></script>
</html>

190
Kuli/mkWrongChoice.js Normal file
View File

@ -0,0 +1,190 @@
const consPhoneme = [
["b", "p", "f"],
["d", "t"],
["g", "k"],
["h", "f"],
["j", "q", "zh", "ch", "z", "c"],
["x", "sh", "s"],
["l", "r"],
["B", "P", "F"],
["D", "T"],
["G", "K"],
["H", "F"],
["J", "Q", "Zh", "Ch", "Z", "C"],
["X", "Sh", "S"],
["L", "R"],
["H", "F"]
];
const vowPhoneme = [
["ā", "á", "ǎ", "à"],
["ī", "í", "ǐ", "ì"],
["ū", "ú", "ǔ", "ù"],
["ē", "é", "ě", "è"],
["ō", "ó", "ǒ", "ò"],
["ng"]
];
let consPhonemeType;
let foundConsPhoneme = [];
let foundVowPhoneme = [];
let consWrongList = [];
let wrongList = [];
let consWrong;
let vowWrong;
let temp;
let temptemp;
let zhCheck = -1;
let chCheck = -1;
let shCheck = -1;
let ngCheck = -1;
let ZhCheck = -1;
let ChCheck = -1;
let ShCheck = -1;
let NgCheck = -1;
function mkWrongChoice(choice){
foundConsPhoneme = [];
foundVowPhoneme = [];
consWrongList = [];
wrongList = [];
//zh, ch, sh, ng の例外処理が必要
zhCheck = choice.indexOf("zh");
chCheck = choice.indexOf("ch");
shCheck = choice.indexOf("sh");
ngCheck = choice.indexOf("ng");
ZhCheck = choice.indexOf("Zh");
ChCheck = choice.indexOf("Ch");
ShCheck = choice.indexOf("Sh");
NgCheck = choice.indexOf("Ng");
//子音探索
for(let i = 0; i < consPhoneme.length; ++i){
for(let j = 0; j < consPhoneme[i].length; ++j){
if(choice.indexOf(consPhoneme[i][j]) != -1){
//hの例外処理
if(consPhoneme[i][j] == "h"){
if(zhCheck + chCheck + shCheck + ZhCheck + ChCheck + ShCheck > -6){
if(zhCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(chCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(shCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(ZhCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(ChCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(ShCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
}else{
foundConsPhoneme.push([i, j]);
}
//zの例外処理
}else if(consPhoneme[i][j] == "z" && zhCheck != -1){
if(zhCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//cの例外処理
}else if(consPhoneme[i][j] == "c" && chCheck != -1){
if(chCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//sの例外処理
}else if(consPhoneme[i][j] == "s" && shCheck != -1){
if(shCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//Zの例外処理
}else if(consPhoneme[i][j] == "Z" && ZhCheck != -1){
if(ZhCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//Cの例外処理
}else if(consPhoneme[i][j] == "C" && ChCheck != -1){
if(ChCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//Sの例外処理
}else if(consPhoneme[i][j] == "S" && ShCheck != -1){
if(ShCheck == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
//gの例外処理
}else if(consPhoneme[i][j] == "g"){
if(ngCheck + NgCheck > -2){
if(ngCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else if(NgCheck + 1 == choice.indexOf(consPhoneme[i][j])){
continue;
}else{
foundConsPhoneme.push([i, j]);
}
}else{
foundConsPhoneme.push([i, j]);
}
//例外でない状態
}else{
foundConsPhoneme.push([i, j]);
}
//素通り
}else{
continue;
}
}
}
//同グループの自分以外の子音に置換される
for(let i = 0; i < foundConsPhoneme.length; ++i){
for(let j = 0; j < consPhoneme[foundConsPhoneme[i][0]].length; j++){
if(j == foundConsPhoneme[i][1]) continue;
consWrong = choice.replace(consPhoneme[foundConsPhoneme[i][0]][foundConsPhoneme[i][1]], consPhoneme[foundConsPhoneme[i][0]][j])
consWrongList.push(consWrong)
}
}
consWrongList.push(choice)
//母音探索
for(let i = 0; i < vowPhoneme.length; ++i){
for(let j = 0; j < vowPhoneme[i].length; ++j){
if(choice.indexOf(vowPhoneme[i][j]) != -1){
foundVowPhoneme.push([i, j]);
}else{
continue;
}
}
}
//consWrongListの全語の母音が、同グループの自分以外の母音に置換される
for(let k = 0; k < consWrongList.length; ++k){
for(let i = 0; i < foundVowPhoneme.length; ++i){
if(vowPhoneme[foundVowPhoneme[i][0]][foundVowPhoneme[i][1]] == "ng"){
vowWrong = consWrongList[k].replace("ng", "n")
wrongList.push(vowWrong)
}else{
for(let j = 0; j < vowPhoneme[foundVowPhoneme[i][0]].length; j++){
if(j == foundVowPhoneme[i][1]) continue;
vowWrong = consWrongList[k].replace(vowPhoneme[foundVowPhoneme[i][0]][foundVowPhoneme[i][1]], vowPhoneme[foundVowPhoneme[i][0]][j])
wrongList.push(vowWrong)
}
}
}
}
console.log({wrongList});
return wrongList;
}
mkWrongChoice("Zhōngguó");
mkWrongChoice("kuàngquánshuǐ");

View File

@ -24,7 +24,7 @@ let replay = document.getElementById("replay");
let corrSound = document.getElementById("corrSound");
let corrSound2 = document.getElementById("corrSound2");
let wrongSound = document.getElementById("wrongSound");
corrSound.volume = 0.5;
corrSound.volume = 0.7;
wrongSound.volume = 0.5;
let curWordIdx;
@ -34,13 +34,13 @@ let isClicked = [false, false, false, false];
let wordIdx;
let tmpWordIdx;
//関数内の問題語番号の運用
let wordTxt;
//問題語のテキスト
let corrDict;
//問題語の個人情報リスト
let corrIdx;
let wrongIdx = [];
let quizedWordIdx = [];
let tmpWrongIdx;
let wrongChoiceList = [];
let cnt = 0;
let corrCnt = 0;
let wrongCnt = 0;
@ -98,23 +98,10 @@ function quiz() {
//誤答の一覧の表示
mistakenWordIdx = wrongs[i][0];
//間違い方リストから正答番号を取り出した
mistakenWordPronunc = target[mistakenWordIdx]["pronunc"];
mistakenWordPronuncLen = mistakenWordPronunc.length;
console.log(mistakenWordPronunc);
mistakenWordPronuncTxt = "" + mistakenWordPronunc[0] + "";
if (mistakenWordPronuncLen != 0) {
for (let i = 1; i < mistakenWordPronuncLen; ++i) {
//多義語の処理らしい
if (i == mistakenWordPronuncLen - 1) {
mistakenWordPronuncTxt += "</span> or <span style=\"color: red;\">'" + mistakenWordPronunc[i] + "'";
} else {
mistakenWordPronuncTxt += "</span>, <span style=\"color: red;\">'" + mistakenWordPronunc[i] + "'";
}
}
}
wrongsTxt += "<span style=\"color: red;\">" + target[mistakenWordIdx]["word"] + "</span>"
+ " 是 <span style=\"color: red;\">"
+ mistakenWordPronuncTxt + "</span>,不是 " + wrongs[i][1] + "’。<br>"
mistakenWordPronuncTxt = "" + mistakenWordPronunc + "";
wrongsTxt += "<span style=\"color: black;\">" + target[mistakenWordIdx]["word"] + "</span>"
+ "是 <span style=\"color: black;\">"
+ target[mistakenWordIdx]["pronunc"] + "</span>不是<span style=\"color: black;\">" + wrongs[i][1] + "’。</span><br>"
}
imperfect.innerHTML = wrongsTxt.slice(0, -4);
return [null, null];
@ -123,43 +110,44 @@ function quiz() {
//継続処理
setQuiz();
tmpWordIdx = Math.floor(Math.random() * targetLen);
while (tmpWordIdx == wordIdx) {
//連続同一問題を排除する
while (quizedWordIdx.includes(tmpWordIdx) || tmpWordIdx == wordIdx) {
//今ゲームの出題リストに含まれる出題を排除する
tmpWordIdx = Math.floor(Math.random() * targetLen);
}
wordIdx = tmpWordIdx;
quizedWordIdx.push(wordIdx);
corrIdx = Math.floor(Math.random() * 4);
console.log(corrIdx);
//問題語と正答番号をリフレッシュした
corrDict = target[wordIdx]
word.innerText = corrDict["word"];
pronunc.innerText = corrDict["meaning"];
ans[corrIdx].innerText = corrDict["pronunc"];
//誤答選択肢を作る
wrongChoiceList = [];
wrongChoiceList = mkWrongChoice(corrDict["pronunc"][0])
for (let i = 0; i < 4; ++i) {
//誤答選択肢を作る
if (i == corrIdx) continue;
tmpWrongIdx = Math.floor(Math.random() * targetLen);
while (wrongIdx.includes(tmpWrongIdx) || tmpWrongIdx == wordIdx) {
//以前の誤答集に含まれる、または正答と同一であるような誤答を省く
tmpWrongIdx = Math.floor(Math.random() * targetLen);
tmpWrongIdx = Math.floor(Math.random() * wrongChoiceList.length);
while (wrongIdx.includes(tmpWrongIdx)) {
//今回の誤答選択肢に含まれる誤答を省く
tmpWrongIdx = Math.floor(Math.random() * wrongChoiceList.length);
}
wrongIdx.push(tmpWrongIdx);
//誤答集に今回使った誤答を追加した
ans[i].innerText = randElem(target[tmpWrongIdx]["pronunc"]);
ans[i].innerText = wrongChoiceList[tmpWrongIdx];
//ランダム列、ピンイン行の要素を誤答ゾーンに代入した
}
wrongIdx = [];
//誤答集がリセットされた
corrDict = target[wordIdx]
wordTxt = corrDict["word"];
//実装されなかったらしいジェンダーの表示機能
if (corrDict["gender_is_distinctive"]) wordTxt += " (" + corrDict["gender"] + ")";
word.innerText = wordTxt;
pronunc.innerText = "" + corrDict["meaning"] + "";
ans[corrIdx].innerText = randElem(corrDict["pronunc"]);
//多義語ならば意味の一つだけを表示する仕様だったらしい
cnt++;
return [wordIdx, corrIdx]
}
}
function start() {
//初期値設定
quizedWordIdx = [];
[curWordIdx, curCorrIdx] = quiz();
// startSound.currentTime = 0;
// startSound.play();
@ -266,17 +254,3 @@ ans[3].addEventListener("click", () => {
}
})
replay.addEventListener("click", start)
clsChg.addEventListener("click", () => {
if (wordClass == "noun") {
wordClass = "verb";
clsChg.innerText = "V";
} else {
wordClass = "noun";
clsChg.innerText = "N";
}
target = words(wordClass);
targetLen = target.length;
console.log(targetLen);
cnt = 0;
start();
})

BIN
Kuli/src/correct.mp3 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,9 @@ function words() {
{ "word": "多", "meaning": ["多い"], "pronunc": ["duō"] },
{ "word": "关照", "meaning": ["~の世話をする"], "pronunc": ["guān zhào"] },
{ "word": "您", "meaning": ["あなたさま"], "pronunc": ["nín"] },
{ "word": "他/她/它", "meaning": ["彼/彼女/それ"], "pronunc": ["tā"] },
{ "word": "他", "meaning": ["彼"], "pronunc": ["tā"] },
{ "word": "她", "meaning": ["彼女"], "pronunc": ["tā"] },
{ "word": "它", "meaning": ["それ"], "pronunc": ["tā"] },
{ "word": "谁", "meaning": ["だれ"], "pronunc": ["shéi/shúi"] },
{ "word": "咱们", "meaning": ["わたしたち"], "pronunc": ["zánmen"] },
{ "word": "伊藤", "meaning": ["伊藤(固有名詞)"], "pronunc": ["Yīténg"] },
@ -24,7 +26,7 @@ function words() {
{ "word": "学", "meaning": ["~を学ぶ"], "pronunc": ["xué"] },
{ "word": "去", "meaning": ["~に行く"], "pronunc": ["qù"] },
{ "word": "中国", "meaning": ["中国"], "pronunc": ["Zhōngguó"] },
{ "word": "李先生", "meaning": ["李さん"], "pronunc": ["Lǐ xiānsheng"] },
{ "word": "李先生", "meaning": ["李さん(固有名詞)"], "pronunc": ["Lǐ xiānsheng"] },
{ "word": "美国", "meaning": ["アメリカ"], "pronunc": ["Měiguó"] },
{ "word": "图书馆", "meaning": ["図書館"], "pronunc": ["túshūguǎn"] },
{ "word": "学校", "meaning": ["学校"], "pronunc": ["xuéxiào"] },
@ -68,7 +70,7 @@ function words() {
{ "word": "日本人", "meaning": ["日本人"], "pronunc": ["Rìběnrén"] },
{ "word": "大学生", "meaning": ["大学生"], "pronunc": ["dàxuéshenḡ"] },
{ "word": "职员", "meaning": ["職員"], "pronunc": ["zhíyuán"] },
{ "word": "小刘", "meaning": ["刘ちゃん(固有名詞)"], "pronunc": ["Xiǎo Liǔ"] },
{ "word": "小刘", "meaning": ["刘ちゃん(固有名詞)"], "pronunc": ["Xiǎo Liú"] },
{ "word": "都", "meaning": ["みんな"], "pronunc": ["dōu"] },
{ "word": "爷爷", "meaning": ["(父方の)祖父"], "pronunc": ["yéye"] },
{ "word": "奶奶", "meaning": ["(父方の)祖母"], "pronunc": ["nǎinai"] },
@ -84,18 +86,20 @@ function words() {
{ "word": "儿子", "meaning": ["息子"], "pronunc": ["érzi"] },
{ "word": "女儿", "meaning": ["娘"], "pronunc": ["nǚér"] },
{ "word": "兄弟姐妹", "meaning": ["兄弟姉妹"], "pronunc": ["xiōngdìjiěmèi"] },
{ "word": "刘燕", "meaning": ["刘燕(固有名詞)"], "pronunc": ["Liǔ Yàn"] },
{ "word": "刘燕", "meaning": ["刘燕(固有名詞)"], "pronunc": ["Liú Yàn"] },
{ "word": "吗", "meaning": ["~か?"], "pronunc": ["ma"] },
{ "word": "田中明香", "meaning": ["田中明香(固有名詞)"], "pronunc": ["Tiánzhōng Míngxiāng"] },
{ "word": "不", "meaning": ["~ない"], "pronunc": ["bù"] },
{ "word": "这儿/这里", "meaning": ["ここ"], "pronunc": ["zhèr/zhèli"] },
{ "word": "这儿", "meaning": ["ここ"], "pronunc": ["zhèr"] },
{ "word": "这里", "meaning": ["ここ"], "pronunc": ["zhèli"] },
{ "word": "景色", "meaning": ["景色"], "pronunc": ["jǐngsè"] },
{ "word": "美", "meaning": ["美しい"], "pronunc": ["měi"] },
{ "word": "那 (指示代詞)", "meaning": ["あれ"], "pronunc": ["nà"] },
{ "word": "有名", "meaning": ["有名"], "pronunc": ["yǒumíng"] },
{ "word": "公园", "meaning": ["公園"], "pronunc": ["gōngyuán"] },
{ "word": "在", "meaning": ["(~が~に)ある"], "pronunc": ["zài"] },
{ "word": "哪儿/哪里", "meaning": ["どこ"], "pronunc": ["nǎr/nǎli"] },
{ "word": "哪儿", "meaning": ["どこ"], "pronunc": ["nǎr"] },
{ "word": "哪里", "meaning": ["どこ"], "pronunc": ["nǎli"] },
{ "word": "对面", "meaning": ["向かい側"], "pronunc": ["duìmiàn"] },
{ "word": "离", "meaning": ["~から"], "pronunc": ["lí"] },
{ "word": "远", "meaning": ["遠い"], "pronunc": ["yuǎn"] },
@ -129,7 +133,8 @@ function words() {
{ "word": "这些", "meaning": ["これら"], "pronunc": ["zhè xiē/zhèi xiē"] },
{ "word": "那些", "meaning": ["あれら"], "pronunc": ["nà xiē/nèi xiē"] },
{ "word": "哪些", "meaning": ["*どれら"], "pronunc": ["nǎ xiē/něi xiē"] },
{ "word": "那儿/那里", "meaning": ["あそこ"], "pronunc": ["nàr/nàli"] },
{ "word": "那儿", "meaning": ["あそこ"], "pronunc": ["nàr"] },
{ "word": "那里", "meaning": ["あそこ"], "pronunc": ["nàli"] },
{ "word": "买", "meaning": ["~を買う"], "pronunc": ["mǎi"] },
{ "word": "教室", "meaning": ["教室"], "pronunc": ["jiàoshì"] },
{ "word": "银行", "meaning": ["銀行"], "pronunc": ["yínháng"] },
@ -395,7 +400,7 @@ function words() {
{ "word": "工学", "meaning": ["工学"], "pronunc": ["gōngxué"] },
{ "word": "农学", "meaning": ["農学"], "pronunc": ["nóngxué"] },
{ "word": "后海", "meaning": ["后海(固有名詞)"], "pronunc": ["Hòuhǎi"] },
{ "word": "嗯", "meaning": ["うん", "えっと"], "pronunc": ["ǹg"] },
// { "word": "嗯", "meaning": ["うん", "えっと"], "pronunc": ["ǹg"] },
{ "word": "夜景", "meaning": ["夜景"], "pronunc": ["yèjǐng"] },
{ "word": "古建筑", "meaning": ["昔の建築"], "pronunc": ["gǔ jiànzhù"] },
{ "word": "鼓楼", "meaning": ["鼓楼"], "pronunc": ["Gǔlóu"] },
@ -535,6 +540,7 @@ function words() {
{ "word": "唱", "meaning": ["~を歌う"], "pronunc": ["chàng"] },
{ "word": "歌", "meaning": ["歌"], "pronunc": ["gē"] },
{ "word": "闷热", "meaning": ["蒸し暑い"], "pronunc": ["mēnrè"] },
{ "word": "参加", "meaning": ["~に参加する"], "pronunc": ["cānjiā"] }
{ "word": "参加", "meaning": ["~に参加する"], "pronunc": ["cānjiā"] },
{ "word": "苦力", "meaning": ["アジア系の下層肉体労働者"], "pronunc": ["kǔlì"] }
]
}

View File

@ -2,30 +2,7 @@ body {
text-align: center;
vertical-align: middle;
font-weight: bold;
}
#clsChg {
position: absolute;
display: block;
width: 16vh;
height: 8vh;
text-align: center;
border-radius: 2rem;
background-color: darkgreen;
color: white;
font-size: 6vh;
cursor: pointer;
user-select: none;
transition: all 0.3s;
box-shadow: 0 3px 5px rgba(0, 0, 0, .3);
}
#clsChg:hover {
background-color: green;
}
#hamburger {
background-color: green;
background-color: red;
}
#scoreA {
@ -55,13 +32,15 @@ body {
#pronunc {
font-size: 4vh;
color: gray;
color: gold;
}
#ans_0 {
width: 50%;
height: 40%;
background-color: #d14d28;
color: black;
background-color: red;
border: 5px solid gold;
}
#ans_0:hover {
@ -71,7 +50,9 @@ body {
#ans_1 {
width: 50%;
background-color: #59c8ef;
color: black;
background-color: red;
border: 5px solid gold;
}
#ans_1:hover {
@ -81,7 +62,9 @@ body {
#ans_2 {
height: 40%;
background-color: #2b9464;
color: black;
background-color: red;
border: 5px solid gold;
}
#ans_2:hover {
@ -90,7 +73,9 @@ body {
}
#ans_3 {
background-color: #f5df65;
color: black;
background-color: red;
border: 5px solid gold;
}
#ans_3:hover {
@ -105,7 +90,9 @@ body {
padding: 0.5em 1em;
margin: 0 auto;
text-align: left;
background-color: white;
border: 5px solid gold;
background-color: red;
color:gold;
box-shadow: 0 3px 6px rgba(0, 0, 0, .4);
}
@ -134,8 +121,8 @@ body {
padding: auto;
margin: 10px auto;
border-radius: 1rem;
background-color: red;
color: white !important;
background-color: gold;
color: red !important;
font-size: 4vw;
cursor: pointer;
transition: all 0.3s;