class Kanjika::Conjugator::Masu

def apply_conjugation_rule(verb_type)

def apply_conjugation_rule(verb_type)
  rule = CONJUGATION_RULES[verb_type]
  case verb_type
  when :ichidan
    rule.call(stem)
  when :godan
    rule.call(stem, verb[-1])
  when :irregular
    rule.call(verb)
  end
end

def conjugate

def conjugate
  Ve.in(:ja).words(verb).flat_map do |word|
    word.tokens.map { |token| conjugate_token(word, token) }.join
  end.join
end

def conjugate_others(token)

def conjugate_others(token)
  return verb + "します" if verb.kanji?
  if ending_in_e_or_i?
    CONJUGATION_RULES[:ichidan].call(stem)
  elsif godan_ending?
    CONJUGATION_RULES[:godan].call(stem, verb[-1])
  end
end

def conjugate_token(word, token)

def conjugate_token(word, token)
  if word.part_of_speech.name == "verb"
    conjugate_verb(token)
  else
    conjugate_others(token)
  end
end

def conjugate_verb(token)

def conjugate_verb(token)
  verb_type = determine_verb_type(token)
  apply_conjugation_rule(verb_type)
end

def determine_verb_type(token)

def determine_verb_type(token)
  return :ichidan if ichidan?(token)
  return :godan if godan?(token)
  :irregular if irregular?(token)
end

def ending_in_e_or_i?

def ending_in_e_or_i?
  E_ENDINGS.include?(verb[-2]) || I_ENDINGS.include?(verb[-2])
end

def godan?(token)

def godan?(token)
  token[:inflection_type].match?(GODAN)
end

def godan_ending?

def godan_ending?
  GODAN_ENDINGS.key?(verb[-1])
end

def ichidan?(token)

def ichidan?(token)
  token[:inflection_type].match?(ICHIDAN)
end

def irregular?(token)

def irregular?(token)
  token[:inflection_type].match?(SURU) || token[:inflection_type].match?(KURU)
end

def stem

def stem
  verb.chop
end