Past tense
This commit is contained in:
parent
60ce9f2690
commit
52d77652d0
20
lib/verb.rb
20
lib/verb.rb
@ -10,6 +10,10 @@ U_VOWEL_CHANGES = {
|
||||
"ぬ" => { "a" => "な", "i" => "に", "u" => "ぬ", "e" => "ね", "o" => "の" },
|
||||
}
|
||||
|
||||
TE_TA_DE_DA = {
|
||||
"て" => "た", "で" => "だ"
|
||||
}
|
||||
|
||||
class KanaKanji
|
||||
attr_reader :kana, :kanji
|
||||
def initialize(kana, kanji=nil)
|
||||
@ -69,9 +73,25 @@ class Verb
|
||||
stem + "ません"
|
||||
end
|
||||
|
||||
def long_form_past_positive
|
||||
stem + "ました"
|
||||
end
|
||||
|
||||
def long_form_past_negative
|
||||
long_form_present_negative + "でした"
|
||||
end
|
||||
|
||||
def short_form_present_positive
|
||||
dictionary
|
||||
end
|
||||
|
||||
def short_form_past_positive
|
||||
te.all_but_last_character + TE_TA_DE_DA[te.last_character]
|
||||
end
|
||||
|
||||
def short_form_past_negative
|
||||
short_form_present_negative.all_but_last_character + "かった"
|
||||
end
|
||||
end
|
||||
|
||||
class IchidanVerb < Verb
|
||||
|
@ -83,4 +83,48 @@ class TestVerb < Minitest::Test
|
||||
assert_equal "勉強しない", @benkyousuru.short_form_present_negative.kanji
|
||||
assert_equal "べんきょうしない", @benkyousuru.short_form_present_negative.kana
|
||||
end
|
||||
|
||||
def test_long_form_past_positive
|
||||
assert_equal "見ました", @miru.long_form_past_positive.kanji
|
||||
assert_equal "みました", @miru.long_form_past_positive.kana
|
||||
assert_equal "飲みました", @nomu.long_form_past_positive.kanji
|
||||
assert_equal "のみました", @nomu.long_form_past_positive.kana
|
||||
assert_equal "しました", @suru.long_form_past_positive.kanji
|
||||
assert_equal "しました", @suru.long_form_past_positive.kana
|
||||
assert_equal "勉強しました", @benkyousuru.long_form_past_positive.kanji
|
||||
assert_equal "べんきょうしました", @benkyousuru.long_form_past_positive.kana
|
||||
end
|
||||
|
||||
def test_long_form_past_negative
|
||||
assert_equal "見ませんでした", @miru.long_form_past_negative.kanji
|
||||
assert_equal "みませんでした", @miru.long_form_past_negative.kana
|
||||
assert_equal "飲みませんでした", @nomu.long_form_past_negative.kanji
|
||||
assert_equal "のみませんでした", @nomu.long_form_past_negative.kana
|
||||
assert_equal "しませんでした", @suru.long_form_past_negative.kanji
|
||||
assert_equal "しませんでした", @suru.long_form_past_negative.kana
|
||||
assert_equal "勉強しませんでした", @benkyousuru.long_form_past_negative.kanji
|
||||
assert_equal "べんきょうしませんでした", @benkyousuru.long_form_past_negative.kana
|
||||
end
|
||||
|
||||
def test_short_form_past_positive
|
||||
assert_equal "見た", @miru.short_form_past_positive.kanji
|
||||
assert_equal "みた", @miru.short_form_past_positive.kana
|
||||
assert_equal "飲んだ", @nomu.short_form_past_positive.kanji
|
||||
assert_equal "のんだ", @nomu.short_form_past_positive.kana
|
||||
assert_equal "した", @suru.short_form_past_positive.kanji
|
||||
assert_equal "した", @suru.short_form_past_positive.kana
|
||||
assert_equal "勉強した", @benkyousuru.short_form_past_positive.kanji
|
||||
assert_equal "べんきょうした", @benkyousuru.short_form_past_positive.kana
|
||||
end
|
||||
|
||||
def test_short_form_past_negative
|
||||
assert_equal "見なかった", @miru.short_form_past_negative.kanji
|
||||
assert_equal "みなかった", @miru.short_form_past_negative.kana
|
||||
assert_equal "飲まなかった", @nomu.short_form_past_negative.kanji
|
||||
assert_equal "のまなかった", @nomu.short_form_past_negative.kana
|
||||
assert_equal "しなかった", @suru.short_form_past_negative.kanji
|
||||
assert_equal "しなかった", @suru.short_form_past_negative.kana
|
||||
assert_equal "勉強しなかった", @benkyousuru.short_form_past_negative.kanji
|
||||
assert_equal "べんきょうしなかった", @benkyousuru.short_form_past_negative.kana
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user