Sha256: 32ef111902ff53f33c2cda1b38b9a1d78f6dc9f7b77c871cc1b97a990e55715f
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require 'yaml' require 'katsuyoujin/version' require 'katsuyoujin/verb' require 'katsuyoujin/base' require 'katsuyoujin/analyzer' module Katsuyoujin def self.root File.dirname __dir__ end def self.rules File.join root, 'rules' end ICHIDAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'ichidan/base.yml').freeze GODAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'godan/base.yml').freeze CONJUGATIONS = { 'ichidan' => YAML.load_file(File.join(rules, 'ichidan/conjugations.yml')).freeze, 'godan' => YAML.load_file(File.join(rules, 'godan/conjugations.yml')).freeze } def self.conjugate(word, *args, category: nil, hiragana: true) verb = Verb.new word vcat = category || verb.category rules = args.inject(CONJUGATIONS[vcat]) { |conjugations, rule| conjugations[rule] || {} } return unless rules['base'] base = Base.new(verb, rules['base']).conjugate category: category, hiragana: hiragana base + rules['attachment'] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katsuyoujin-0.0.1.2 | lib/katsuyoujin.rb |