From 8552a95bb7289090f83ac3044655f147d474fb23 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 16 Aug 2025 07:21:11 -0400 Subject: [PATCH] Te form --- src/verb.rb | 87 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/src/verb.rb b/src/verb.rb index 1696d90..971aba5 100644 --- a/src/verb.rb +++ b/src/verb.rb @@ -1,5 +1,13 @@ -GUYS = { +U_VOWEL_CHANGES = { + "る" => { "a" => "ら", "i" => "り", "u" => "る", "e" => "れ", "o" => "ろ" }, + "う" => { "a" => "あ", "i" => "い", "u" => "う", "e" => "え", "o" => "お" }, + "つ" => { "a" => "た", "i" => "ち", "u" => "つ", "e" => "て", "o" => "と" }, + "す" => { "a" => "さ", "i" => "し", "u" => "す", "e" => "せ", "o" => "そ" }, + "く" => { "a" => "か", "i" => "き", "u" => "く", "e" => "け", "o" => "こ" }, + "ぐ" => { "a" => "が", "i" => "ぎ", "u" => "ぐ", "e" => "げ", "o" => "ご" }, + "ぶ" => { "a" => "ば", "i" => "び", "u" => "ぶ", "e" => "べ", "o" => "ぼ" }, "む" => { "a" => "ま", "i" => "み", "u" => "む", "e" => "め", "o" => "も" }, + "ぬ" => { "a" => "な", "i" => "に", "u" => "ぬ", "e" => "ね", "o" => "の" }, } class KanaKanji @@ -17,8 +25,9 @@ class KanaKanji self.class.new kana + other, kanji + other end - def last_character - GUYS[kana[-1]] + def last_character(new_form=nil) + return kana[-1] unless new_form + U_VOWEL_CHANGES[kana[-1]][new_form] end def all_but_last_character @@ -36,8 +45,8 @@ class Verb @definition_english = definition_english end - def last_character - dict.last_character + def last_character(new_form=nil) + dict.last_character(new_form) end def all_but_last_character @@ -57,40 +66,66 @@ class IchidanVerb < Verb def long_form_present_positive all_but_last_character + "ます" end + + def te + all_but_last_character + "て" + end end class GodanVerb < Verb def long_form_present_positive - all_but_last_character + last_character["i"] + "ます" + all_but_last_character + last_character("i") + "ます" + end + + def te + p last_character + case last_character + when "う" + all_but_last_character + "って" + when "る" + all_but_last_character + "って" + when "つ" + all_but_last_character + "って" + when "す" + all_but_last_character + "して" + when "く" + all_but_last_character + "いて" + when "ぐ" + all_but_last_character + "いで" + when "ぶ" + all_but_last_character + "んで" + when "む" + all_but_last_character + "んで" + when "ぬ" + all_but_last_character + "んで" + end end end class SuruVerb < Verb + def prefix + dict[..-3] + end + def long_form_present_positive - dict[..-3] + "します" + prefix + "します" + end + + def te + prefix + "して" end end 見る = IchidanVerb.new("見る", "みる", "to look") -p 見る.dictionary.kanji -p 見る.dictionary.kana -p 見る.long_form_present_positive.kanji -p 見る.long_form_present_positive.kana - 飲む = GodanVerb.new("飲む", "のむ", "to drink") -p 飲む.dictionary.kanji -p 飲む.dictionary.kana -p 飲む.long_form_present_positive.kanji -p 飲む.long_form_present_positive.kana - する = SuruVerb.new("する", "する", "to do") -p する.dictionary.kanji -p する.dictionary.kana -p する.long_form_present_positive.kanji -p する.long_form_present_positive.kana - 勉強する = SuruVerb.new("勉強する", "べんきょうする", "to study") -p 勉強する.dictionary.kanji -p 勉強する.dictionary.kana -p 勉強する.long_form_present_positive.kanji -p 勉強する.long_form_present_positive.kana +verbs = [見る,飲む,する,勉強する] +verbs.each do |verb| + p verb.dictionary.kanji + p verb.dictionary.kana + p verb.long_form_present_positive.kanji + p verb.long_form_present_positive.kana + p verb.te.kanji + p verb.te.kana +end