Commit 80f7e03b authored by Thomas Dennis's avatar Thomas Dennis

Allow alternative "correct" answers for a single conjugation.

parent 2ff335e3
......@@ -6,6 +6,8 @@ var ADJECTIVE_I = {
word_list:
[
{ "romaji": "furui", "kanji": "古い", "description": "old" },
{ "romaji": "nagai", "kanji": "長い", "description": "long" },
{ "romaji": "takai", "kanji": "高い", "description": "high/expensive" }
],
......@@ -15,27 +17,38 @@ var ADJECTIVE_I = {
{
if (!affirmative)
{
// TODO: Also allow "~ku nai desu" and "~ku nakatta desu" here.
if (tense == "past") { return word.slice(0, -1) + "ku arimasen deshita"; }
else { return word.slice(0, -1) + "ku arimasen"; }
if (tense == "past")
{
return [
word.slice(0, -1) + "ku nakatta desu",
word.slice(0, -1) + "ku arimasen deshita"
];
}
else
{
return [
word.slice(0, -1) + "ku nai desu",
word.slice(0, -1) + "ku arimasen"
];
}
}
else
{
if (tense == "past") { return word.slice(0, -1) + "katta desu"; }
else { return word + " desu"; }
if (tense == "past") { return [word.slice(0, -1) + "katta desu"]; }
else { return [word + " desu"]; }
}
}
else
{
if (!affirmative)
{
if (tense == "past") { return word.slice(0, -1) + "ku nakatta"; }
else { return word.slice(0, -1) + "ku nai"; }
if (tense == "past") { return [word.slice(0, -1) + "ku nakatta"]; }
else { return [word.slice(0, -1) + "ku nai"]; }
}
else
{
if (tense == "past") { return word.slice(0, -1) + "katta"; }
else { return word; }
if (tense == "past") { return [word.slice(0, -1) + "katta"]; }
else { return [word]; }
}
}
}
......
......@@ -33,26 +33,26 @@ var ADJECTIVE_NA = {
{
if (!affirmative)
{
if (tense == "past") { return word + " dewa arimasen deshita"; }
else { return word + " dewa arimasen"; }
if (tense == "past") { return [word + " dewa arimasen deshita"]; }
else { return [word + " dewa arimasen"]; }
}
else
{
if (tense == "past") { return word + " deshita"; }
else { return word + " desu"; }
if (tense == "past") { return [word + " deshita"]; }
else { return [word + " desu"]; }
}
}
else
{
if (!affirmative)
{
if (tense == "past") { return word + " dewa nakatta"; }
else { return word + " dewa nai"; }
if (tense == "past") { return [word + " dewa nakatta"]; }
else { return [word + " dewa nai"]; }
}
else
{
if (tense == "past") { return word + " datta"; }
else { return word + " da"; }
if (tense == "past") { return [word + " datta"]; }
else { return [word + " da"]; }
}
}
}
......
......@@ -143,25 +143,28 @@ function check()
var word = QUESTION[n]["current_word"];
var tense = QUESTION[n].dictionary.tense_list[t];
var expected = QUESTION[n].dictionary.conjugate(word, tense, flags[v][1], flags[v][2]);
var answers = QUESTION[n].dictionary.conjugate(word, tense, flags[v][1], flags[v][2]);
var elem = document.getElementById(QUESTION[n].html_id + "_" + tense + flags[v][0]);
if (elem.value.toLowerCase().replace(/ /g, "") != expected.toLowerCase().replace(/ /g, ""))
{
elem.className = "wrong_answer";
var message = "The <b>" + (flags[v][2] ? "formal, " : "informal, ");
if (!flags[v][1]) { message += "negative-"; }
message += tense + "</b> conjugation should be <b>" + expected + "</b>."
errors.push(message)
var guess = elem.value.toLowerCase().replace(/ /g, "");
elem.className = "wrong_answer";
for (var i = 0; i < answers.length; ++i)
{
if (guess == answers[i].toLowerCase().replace(/ /g, ""))
{
elem.className = "right_answer";
++score;
break;
}
}
else
if (elem.className == "wrong_answer")
{
elem.className = "right_answer";
++score;
var text = "The <b>" + (flags[v][2] ? "formal, " : "informal, ");
if (!flags[v][1]) { text += "negative-"; }
text += tense + "</b> conjugation should be <b>" + answers.join('</b> or <b>') + "</b>.";
errors.push(text);
}
++total;
......
......@@ -26,52 +26,52 @@ var VERB_ERU = {
case "present":
if (formal)
{
if (affirmative) { return word.slice(0, -2) + "masu"; }
else { return word.slice(0, -2) + "masen"; }
if (affirmative) { return [word.slice(0, -2) + "masu"]; }
else { return [word.slice(0, -2) + "masen"]; }
}
else
{
if (affirmative) { return word; }
else { return word.slice(0, -2) + "nai"; }
if (affirmative) { return [word]; }
else { return [word.slice(0, -2) + "nai"]; }
}
break;
case "past":
if (formal)
{
if (affirmative) { return word.slice(0, -2) + "mashita"; }
else { return word.slice(0, -2) + "masen deshita"; }
if (affirmative) { return [word.slice(0, -2) + "mashita"]; }
else { return [word.slice(0, -2) + "masen deshita"]; }
}
else
{
if (affirmative) { return word.slice(0, -2) + "ta"; }
else { return word.slice(0, -2) + "nakatta"; }
if (affirmative) { return [word.slice(0, -2) + "ta"]; }
else { return [word.slice(0, -2) + "nakatta"]; }
}
break;
case "potential":
if (formal)
{
if (affirmative) { return word.slice(0, -2) + "raremasu"; }
else { return word.slice(0, -2) + "raremasen"; }
if (affirmative) { return [word.slice(0, -2) + "raremasu"]; }
else { return [word.slice(0, -2) + "raremasen"]; }
}
else
{
if (affirmative) { return word.slice(0, -2) + "rareru"; }
else { return word.slice(0, -2) + "rarenai"; }
if (affirmative) { return [word.slice(0, -2) + "rareru"]; }
else { return [word.slice(0, -2) + "rarenai"]; }
}
break;
case "provisional":
if (formal)
{
if (affirmative) { return word.slice(0, -2) + "masunaraba"; }
else { return word.slice(0, -2) + "masennaraba"; }
if (affirmative) { return [word.slice(0, -2) + "masunaraba"]; }
else { return [word.slice(0, -2) + "masennaraba"]; }
}
else
{
if (affirmative) { return word.slice(0, -2) + "reba"; }
else { return word.slice(0, -2) + "nakereba"; }
if (affirmative) { return [word.slice(0, -2) + "reba"]; }
else { return [word.slice(0, -2) + "nakereba"]; }
}
break;
......
......@@ -45,43 +45,43 @@ var VERB_U = {
case "present":
if (formal)
{
if (affirmative) { return formal_prefix + "masu"; }
else { return formal_prefix + "masen"; }
if (affirmative) { return [formal_prefix + "masu"]; }
else { return [formal_prefix + "masen"]; }
}
else
{
if (affirmative) { return word; }
else { return negative_stem + "nai"; }
if (affirmative) { return [word]; }
else { return [negative_stem + "nai"]; }
}
break;
case "past":
if (formal)
{
if (affirmative) { return formal_prefix + "mashita"; }
else { return formal_prefix + "masen deshita"; }
if (affirmative) { return [formal_prefix + "mashita"]; }
else { return [formal_prefix + "masen deshita"]; }
}
else if (affirmative)
{
// Handle "tsu" first - "su" is handled below.
if (word.slice(-3) == "tsu") { return word.slice(0, -3) + "tta"; }
if (word.slice(-3) == "tsu") { return [word.slice(0, -3) + "tta"]; }
// Handle all possible two-character endings.
switch (word.slice(-2))
{
case "ku": return word.slice(0, -2) + "ita";
case "gu": return word.slice(0, -2) + "ida";
case "ru": return word.slice(0, -2) + "tta";
case "su": return word.slice(0, -2) + "shita";
case "nu": case "bu": case "mu": return word.slice(0, -2) + "nda";
case "ku": return [word.slice(0, -2) + "ita"];
case "gu": return [word.slice(0, -2) + "ida"];
case "ru": return [word.slice(0, -2) + "tta"];
case "su": return [word.slice(0, -2) + "shita"];
case "nu": case "bu": case "mu": return [word.slice(0, -2) + "nda"];
}
// If all else, fails, assume it ends with "u".
return word.slice(0, -1) + "tta";
return [word.slice(0, -1) + "tta"];
}
else { return negative_stem + "nakatta"; }
else { return [negative_stem + "nakatta"]; }
break;
case "potential":
......@@ -90,13 +90,13 @@ var VERB_U = {
if (formal)
{
if (affirmative) { return word + "masu"; }
else { return word + "masen"; }
if (affirmative) { return [word + "masu"]; }
else { return [word + "masen"]; }
}
else
{
if (affirmative) { return word + "ru"; }
else { return word + "nai"; }
if (affirmative) { return [word + "ru"]; }
else { return [word + "nai"]; }
}
break;
......@@ -106,13 +106,13 @@ var VERB_U = {
if (formal)
{
if (affirmative) { return formal_prefix + "masunaraba"; }
else { return formal_prefix + "masennaraba"; }
if (affirmative) { return [formal_prefix + "masunaraba"]; }
else { return [formal_prefix + "masennaraba"]; }
}
else
{
if (affirmative) { return word + "eba"; }
else { return word + "anakereba"; }
if (affirmative) { return [word + "eba"]; }
else { return [word + "anakereba"]; }
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment