Refactoring.

This commit is contained in:
doncr 2016-12-27 21:08:59 +00:00
parent 9f8093c0e0
commit d0c1b0eeb7

View File

@ -1,11 +1,13 @@
// drill.js // drill.js
var conjugations = { var words = {
"行く" : { "行く" : {
"group" : "iku", "group" : "iku",
"conjugations" : {
"plain" : "行[い]く", "plain" : "行[い]く",
"negative" : "行[い]かない", "negative" : "行[い]かない",
"polite" : "行[い]きます", "polite" : "行[い]きます",
@ -31,11 +33,14 @@ var conjugations = {
"polite progressive" : "行[い]っています", "polite progressive" : "行[い]っています",
"polite progressive negative" : "行[い]っていません", "polite progressive negative" : "行[い]っていません",
}, },
},
"飲む" : { "飲む" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "飲[の]む", "plain" : "飲[の]む",
"negative" : "飲[の]まない", "negative" : "飲[の]まない",
"polite" : "飲[の]みます", "polite" : "飲[の]みます",
@ -61,11 +66,14 @@ var conjugations = {
"polite progressive" : "飲[の]んでいます", "polite progressive" : "飲[の]んでいます",
"polite progressive negative" : "飲[の]んでいません", "polite progressive negative" : "飲[の]んでいません",
}, },
},
"作る" : { "作る" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "作[つく]る", "plain" : "作[つく]る",
"negative" : "作[つく]らない", "negative" : "作[つく]らない",
"polite" : "作[つく]ります", "polite" : "作[つく]ります",
@ -91,11 +99,14 @@ var conjugations = {
"polite progressive" : "作[つく]っています", "polite progressive" : "作[つく]っています",
"polite progressive negative" : "作[つく]っていません", "polite progressive negative" : "作[つく]っていません",
}, },
},
"買い戻す" : { "買い戻す" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "買[か]い戻[もど]す", "plain" : "買[か]い戻[もど]す",
"negative" : "買[か]い戻[もど]さない", "negative" : "買[か]い戻[もど]さない",
"polite" : "買[か]い戻[もど]します", "polite" : "買[か]い戻[もど]します",
@ -121,11 +132,14 @@ var conjugations = {
"polite progressive" : "買[か]い戻[もど]しています", "polite progressive" : "買[か]い戻[もど]しています",
"polite progressive negative" : "買[か]い戻[もど]していません", "polite progressive negative" : "買[か]い戻[もど]していません",
}, },
},
"見る" : { "見る" : {
"group" : "ichidan", "group" : "ichidan",
"conjugations" : {
"plain" : "見[み]る", "plain" : "見[み]る",
"negative" : "見[み]ない", "negative" : "見[み]ない",
"polite" : "見[み]ます", "polite" : "見[み]ます",
@ -151,11 +165,14 @@ var conjugations = {
"polite progressive" : "見[み]ています", "polite progressive" : "見[み]ています",
"polite progressive negative" : "見[み]ていません", "polite progressive negative" : "見[み]ていません",
}, },
},
"食べる" : { "食べる" : {
"group" : "ichidan", "group" : "ichidan",
"conjugations" : {
"plain" : "食[た]べる", "plain" : "食[た]べる",
"negative" : "食[た]べない", "negative" : "食[た]べない",
"polite" : "食[た]べます", "polite" : "食[た]べます",
@ -181,11 +198,14 @@ var conjugations = {
"polite progressive" : "食[た]べています", "polite progressive" : "食[た]べています",
"polite progressive negative" : "食[た]べていません", "polite progressive negative" : "食[た]べていません",
}, },
},
"起きる" : { "起きる" : {
"group" : "ichidan", "group" : "ichidan",
"conjugations" : {
"plain" : "起[お]きる", "plain" : "起[お]きる",
"negative" : "起[お]きない", "negative" : "起[お]きない",
"polite" : "起[お]きます", "polite" : "起[お]きます",
@ -211,11 +231,14 @@ var conjugations = {
"polite progressive" : "起[お]きています", "polite progressive" : "起[お]きています",
"polite progressive negative" : "起[お]きていません", "polite progressive negative" : "起[お]きていません",
}, },
},
"買い換える" : { "買い換える" : {
"group" : "ichidan", "group" : "ichidan",
"conjugations" : {
"plain" : "買[か]い換[か]える", "plain" : "買[か]い換[か]える",
"negative" : "買[か]い換[か]えない", "negative" : "買[か]い換[か]えない",
"polite" : "買[か]い換[か]えます", "polite" : "買[か]い換[か]えます",
@ -241,11 +264,14 @@ var conjugations = {
"polite progressive" : "買[か]い換[か]えています", "polite progressive" : "買[か]い換[か]えています",
"polite progressive negative" : "買[か]い換[か]えていません", "polite progressive negative" : "買[か]い換[か]えていません",
}, },
},
"来る" : { "来る" : {
"group" : "kuru", "group" : "kuru",
"conjugations" : {
"plain" : "来[く]る", "plain" : "来[く]る",
"negative" : "来[こ]ない", "negative" : "来[こ]ない",
"polite" : "来[き]ます", "polite" : "来[き]ます",
@ -271,11 +297,14 @@ var conjugations = {
"polite progressive" : "来[き]ています", "polite progressive" : "来[き]ています",
"polite progressive negative" : "来[き]ていません", "polite progressive negative" : "来[き]ていません",
}, },
},
"する" : { "する" : {
"group" : "suru", "group" : "suru",
"conjugations" : {
"plain" : "する", "plain" : "する",
"negative" : "しない", "negative" : "しない",
"polite" : "します", "polite" : "します",
@ -291,11 +320,14 @@ var conjugations = {
"polite progressive" : "しています", "polite progressive" : "しています",
"polite progressive negative" : "していません", "polite progressive negative" : "していません",
}, },
},
"勉強する" : { "勉強する" : {
"group" : "suru", "group" : "suru",
"conjugations" : {
"plain" : "勉[べん]強[きょう]する", "plain" : "勉[べん]強[きょう]する",
"negative" : "勉[べん]強[きょう]しない", "negative" : "勉[べん]強[きょう]しない",
"polite" : "勉[べん]強[きょう]します", "polite" : "勉[べん]強[きょう]します",
@ -311,11 +343,14 @@ var conjugations = {
"polite progressive" : "勉[べん]強[きょう]しています", "polite progressive" : "勉[べん]強[きょう]しています",
"polite progressive negative" : "勉[べん]強[きょう]していません", "polite progressive negative" : "勉[べん]強[きょう]していません",
}, },
},
"電話する" : { "電話する" : {
"group" : "suru", "group" : "suru",
"conjugations" : {
"plain" : "電[でん]話[わ]する", "plain" : "電[でん]話[わ]する",
"negative" : "電[でん]話[わ]しない", "negative" : "電[でん]話[わ]しない",
"polite" : "電[でん]話[わ]します", "polite" : "電[でん]話[わ]します",
@ -331,11 +366,14 @@ var conjugations = {
"polite progressive" : "電[でん]話[わ]しています", "polite progressive" : "電[でん]話[わ]しています",
"polite progressive negative" : "電[でん]話[わ]していません", "polite progressive negative" : "電[でん]話[わ]していません",
}, },
},
"読む" : { "読む" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "読[よ]む", "plain" : "読[よ]む",
"negative" : "読[よ]まない", "negative" : "読[よ]まない",
"polite" : "読[よ]みます", "polite" : "読[よ]みます",
@ -361,11 +399,14 @@ var conjugations = {
"polite progressive" : "読[よ]んでいます", "polite progressive" : "読[よ]んでいます",
"polite progressive negative" : "読[よ]んでいません", "polite progressive negative" : "読[よ]んでいません",
}, },
},
"思う" : { "思う" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "思[おも]う", "plain" : "思[おも]う",
"negative" : "思[おも]わない", "negative" : "思[おも]わない",
"polite" : "思[おも]います", "polite" : "思[おも]います",
@ -391,11 +432,14 @@ var conjugations = {
"polite progressive" : "思[おも]っています", "polite progressive" : "思[おも]っています",
"polite progressive negative" : "思[おも]っていません", "polite progressive negative" : "思[おも]っていません",
}, },
},
"買い与える" : { "買い与える" : {
"group" : "ichidan", "group" : "ichidan",
"conjugations" : {
"plain" : "買[か]い与[あた]える", "plain" : "買[か]い与[あた]える",
"negative" : "買[か]い与[あた]えない", "negative" : "買[か]い与[あた]えない",
"polite" : "買[か]い与[あた]えます", "polite" : "買[か]い与[あた]えます",
@ -421,11 +465,14 @@ var conjugations = {
"polite progressive" : "買[か]い与[あた]えています", "polite progressive" : "買[か]い与[あた]えています",
"polite progressive negative" : "買[か]い与[あた]えていません", "polite progressive negative" : "買[か]い与[あた]えていません",
}, },
},
"座る" : { "座る" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "座[すわ]る", "plain" : "座[すわ]る",
"negative" : "座[すわ]らない", "negative" : "座[すわ]らない",
"polite" : "座[すわ]ります", "polite" : "座[すわ]ります",
@ -451,11 +498,14 @@ var conjugations = {
"polite progressive" : "座[すわ]っています", "polite progressive" : "座[すわ]っています",
"polite progressive negative" : "座[すわ]っていません", "polite progressive negative" : "座[すわ]っていません",
}, },
},
"休む" : { "休む" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "休[やす]む", "plain" : "休[やす]む",
"negative" : "休[やす]まない", "negative" : "休[やす]まない",
"polite" : "休[やす]みます", "polite" : "休[やす]みます",
@ -481,11 +531,14 @@ var conjugations = {
"polite progressive" : "休[やす]んでいます", "polite progressive" : "休[やす]んでいます",
"polite progressive negative" : "休[やす]んでいません", "polite progressive negative" : "休[やす]んでいません",
}, },
},
"足す" : { "足す" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "足[た]す", "plain" : "足[た]す",
"negative" : "足[た]さない", "negative" : "足[た]さない",
"polite" : "足[た]します", "polite" : "足[た]します",
@ -511,11 +564,14 @@ var conjugations = {
"polite progressive" : "足[た]しています", "polite progressive" : "足[た]しています",
"polite progressive negative" : "足[た]していません", "polite progressive negative" : "足[た]していません",
}, },
},
"歌う" : { "歌う" : {
"group" : "godan", "group" : "godan",
"conjugations" : {
"plain" : "歌[うた]う", "plain" : "歌[うた]う",
"negative" : "歌[うた]わない", "negative" : "歌[うた]わない",
"polite" : "歌[うた]います", "polite" : "歌[うた]います",
@ -541,11 +597,14 @@ var conjugations = {
"polite progressive" : "歌[うた]っています", "polite progressive" : "歌[うた]っています",
"polite progressive negative" : "歌[うた]っていません", "polite progressive negative" : "歌[うた]っていません",
}, },
},
"高い" : { "高い" : {
"group" : "i-adjective", "group" : "i-adjective",
"conjugations" : {
"plain" : "高[たか]い", "plain" : "高[たか]い",
"negative" : "高[たか]くない", "negative" : "高[たか]くない",
"polite" : "高[たか]いです", "polite" : "高[たか]いです",
@ -555,11 +614,14 @@ var conjugations = {
"polite past" : "高[たか]かったです", "polite past" : "高[たか]かったです",
"polite past negative" : "高[たか]くなかったです", "polite past negative" : "高[たか]くなかったです",
}, },
},
"面白い" : { "面白い" : {
"group" : "i-adjective", "group" : "i-adjective",
"conjugations" : {
"plain" : "面白[おもしろ]い", "plain" : "面白[おもしろ]い",
"negative" : "面白[おもしろ]くない", "negative" : "面白[おもしろ]くない",
"polite" : "面白[おもしろ]いです", "polite" : "面白[おもしろ]いです",
@ -569,11 +631,14 @@ var conjugations = {
"polite past" : "面白[おもしろ]かったです", "polite past" : "面白[おもしろ]かったです",
"polite past negative" : "面白[おもしろ]くなかったです", "polite past negative" : "面白[おもしろ]くなかったです",
}, },
},
"暗い" : { "暗い" : {
"group" : "i-adjective", "group" : "i-adjective",
"conjugations" : {
"plain" : "暗[くら]い", "plain" : "暗[くら]い",
"negative" : "暗[くら]くない", "negative" : "暗[くら]くない",
"polite" : "暗[くら]いです", "polite" : "暗[くら]いです",
@ -583,11 +648,14 @@ var conjugations = {
"polite past" : "暗[くら]かったです", "polite past" : "暗[くら]かったです",
"polite past negative" : "暗[くら]くなかったです", "polite past negative" : "暗[くら]くなかったです",
}, },
},
"いい" : { "いい" : {
"group" : "i-adjective", "group" : "i-adjective",
"conjugations" : {
"plain" : "いい", "plain" : "いい",
"negative" : "良[よ]くない", "negative" : "良[よ]くない",
"polite" : "いいです", "polite" : "いいです",
@ -597,11 +665,14 @@ var conjugations = {
"polite past" : "良[よ]かったです", "polite past" : "良[よ]かったです",
"polite past negative" : "良[よ]くなかったです", "polite past negative" : "良[よ]くなかったです",
}, },
},
"有名な" : { "有名な" : {
"group" : "na-adjective", "group" : "na-adjective",
"conjugations" : {
"plain" : "有名[ゆうめい]だ", "plain" : "有名[ゆうめい]だ",
"negative" : "有名[ゆうめい]ではない", "negative" : "有名[ゆうめい]ではない",
"polite" : "有名[ゆうめい]です", "polite" : "有名[ゆうめい]です",
@ -611,11 +682,14 @@ var conjugations = {
"polite past" : "有名[ゆうめい]でした", "polite past" : "有名[ゆうめい]でした",
"polite past negative" : "有名[ゆうめい]ではありませんでした", "polite past negative" : "有名[ゆうめい]ではありませんでした",
}, },
},
"好きな" : { "好きな" : {
"group" : "na-adjective", "group" : "na-adjective",
"conjugations" : {
"plain" : "好[き]だ", "plain" : "好[き]だ",
"negative" : "好[き]ではない", "negative" : "好[き]ではない",
"polite" : "好[き]です", "polite" : "好[き]です",
@ -625,11 +699,14 @@ var conjugations = {
"polite past" : "好[き]でした", "polite past" : "好[き]でした",
"polite past negative" : "好[き]ではありませんでした", "polite past negative" : "好[き]ではありませんでした",
}, },
},
"元気な" : { "元気な" : {
"group" : "na-adjective", "group" : "na-adjective",
"conjugations" : {
"plain" : "元[げん]気[き]だ", "plain" : "元[げん]気[き]だ",
"negative" : "元[げん]気[き]ではない", "negative" : "元[げん]気[き]ではない",
"polite" : "元[げん]気[き]です", "polite" : "元[げん]気[き]です",
@ -639,11 +716,14 @@ var conjugations = {
"polite past" : "元[げん]気[き]でした", "polite past" : "元[げん]気[き]でした",
"polite past negative" : "元[げん]気[き]ではありませんでした", "polite past negative" : "元[げん]気[き]ではありませんでした",
}, },
},
"意地悪な" : { "意地悪な" : {
"group" : "na-adjective", "group" : "na-adjective",
"conjugations" : {
"plain" : "意[い]地[じ]悪[わる]だ", "plain" : "意[い]地[じ]悪[わる]だ",
"negative" : "意[い]地[じ]悪[わる]ではない", "negative" : "意[い]地[じ]悪[わる]ではない",
"polite" : "意[い]地[じ]悪[わる]です", "polite" : "意[い]地[じ]悪[わる]です",
@ -653,7 +733,7 @@ var conjugations = {
"polite past" : "意[い]地[じ]悪[わる]でした", "polite past" : "意[い]地[じ]悪[わる]でした",
"polite past negative" : "意[い]地[じ]悪[わる]ではありませんでした", "polite past negative" : "意[い]地[じ]悪[わる]ではありませんでした",
}, },
},
}; };
var transformations = { var transformations = {
@ -901,10 +981,10 @@ function getVerbForms(entry) {
"furigana": { } "furigana": { }
}; };
Object.keys(conjugations[entry]).forEach(function (key) { Object.keys(words[entry].conjugations).forEach(function (key) {
result["kanji"][key] = kanjiForm(conjugations[entry][key]); result["kanji"][key] = kanjiForm(words[entry].conjugations[key]);
result["hiragana"][key] = kanaForm(conjugations[entry][key]); result["hiragana"][key] = kanaForm(words[entry].conjugations[key]);
result["furigana"][key] = conjugations[entry][key]; result["furigana"][key] = words[entry].conjugations[key];
}); });
return result; return result;
@ -1029,7 +1109,7 @@ function generateQuestion() {
return; return;
} }
entry = Object.keys(conjugations).randomElement(); entry = Object.keys(words).randomElement();
to_form = Object.keys(transformations).randomElement(); to_form = Object.keys(transformations).randomElement();
from_form = Object.keys(transformations[to_form]).randomElement(); from_form = Object.keys(transformations[to_form]).randomElement();
@ -1046,7 +1126,7 @@ function generateQuestion() {
} }
}); });
if ($('#' + conjugations[entry].group).is(':checked') == false) { if ($('#' + words[entry].group).is(':checked') == false) {
valid = false; valid = false;
} }