Commit 406944ad authored by Thomas Dennis's avatar Thomas Dennis

Handle つ/ち/し properly for ~u verb conjugations.

parent ed1de39d
......@@ -25,9 +25,19 @@ var VERB_U = {
conjugate: function(word, tense, affirmative, formal)
{
// As a special case, words ending with "[vowel]u" should use WA not A.
var negative_stem = word.slice(0, -1);
if (negative_stem.slice(-1).match(/[AEIOUaeiou]/)) { negative_stem += "w"; }
word = word.toLowerCase();
// Convert su->shi / tsu->chi for hanaSHImasu/maCHImasu/etc.
var formal_prefix = "";
if (word.slice(-3) == "tsu") { formal_prefix = word.slice(0, -3) + "chi"; }
else if (word.slice(-2) == "su" ) { formal_prefix = word.slice(0, -2) + "shi"; }
else { formal_prefix = word.slice(0, -1) + "i"; }
// Words ending with "[vowel]u" should use WA not A, and TSU should become TA.
var negative_stem = "";
if (word.slice(-3) == "tsu" ) { negative_stem = word.slice(0, -3) + "ta"; }
else if (word.slice(-2, -1).match(/[aeiou]/)) { negative_stem = word.slice(0, -1) + "wa"; }
else { negative_stem = word.slice(0, -1) + "a"; }
switch (tense)
{
......@@ -35,21 +45,21 @@ var VERB_U = {
case "present":
if (formal)
{
if (affirmative) { return word.slice(0, -1) + "imasu"; }
else { return word.slice(0, -1) + "imasen"; }
if (affirmative) { return formal_prefix + "masu"; }
else { return formal_prefix + "masen"; }
}
else
{
if (affirmative) { return word; }
else { return negative_stem + "anai"; }
if (affirmative) { return word; }
else { return negative_stem + "nai"; }
}
break;
case "past":
if (formal)
{
if (affirmative) { return word.slice(0, -1) + "imashita"; }
else { return word.slice(0, -1) + "imasen deshita"; }
if (affirmative) { return formal_prefix + "mashita"; }
else { return formal_prefix + "masen deshita"; }
}
else if (affirmative)
{
......@@ -71,19 +81,22 @@ var VERB_U = {
return word.slice(0, -1) + "tta";
}
else { return negative_stem + "anakatta"; }
else { return negative_stem + "nakatta"; }
break;
case "potential":
if (word.slice(-3) == "tsu") { word = word.slice(0, -3) + "te"; }
else { word = word.slice(0, -1) + "e"; }
if (formal)
{
if (affirmative) { return word.slice(0, -1) + "emasu"; }
else { return word.slice(0, -1) + "emasen"; }
if (affirmative) { return word + "masu"; }
else { return word + "masen"; }
}
else
{
if (affirmative) { return word.slice(0, -1) + "eru"; }
else { return word.slice(0, -1) + "enai"; }
if (affirmative) { return word + "ru"; }
else { return word + "nai"; }
}
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