From 52d77652d00cd4df41875b5e518925c5839fc862 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 16 Aug 2025 09:22:23 -0400 Subject: [PATCH] Past tense --- lib/verb.rb | 20 ++++++++++++++++++++ test/test_verb.rb | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/lib/verb.rb b/lib/verb.rb index b121cab..9d82d6d 100644 --- a/lib/verb.rb +++ b/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 diff --git a/test/test_verb.rb b/test/test_verb.rb index 1509a13..be63fe1 100644 --- a/test/test_verb.rb +++ b/test/test_verb.rb @@ -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