katsuyoujin 0.0.2 → 0.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d2d86774f80cd186b0600fac3406b429630482e
4
- data.tar.gz: 234cfd1fa512c20603731af88c225a2836d2f735
3
+ metadata.gz: 11bf087d163f85a06dc34142b52f36804fccc8e9
4
+ data.tar.gz: 40170f7f9ea5504cff44aca563278f4647de0974
5
5
  SHA512:
6
- metadata.gz: 04955ced89c6f018e526c54c5c3ab4eeaaf053406eb158960e30d98ce490a3b04cb32eb7fd7bd7ceeaecd19efef24d6e77b22324b8352dd109a4e677b7040137
7
- data.tar.gz: 3f7b4ebd7506c3abde0330345663418fa003f68b8bca7e7f0699a86cc206d90084cb2efbf98b03091b961fb5918289dcd0fbaafe7cb8f2ab729281622842f4da
6
+ metadata.gz: 8e58cf72f25754d6f92d31d6229df04083ed886c065f1494208a1b23f923d7009de18932858aad94fe02808c71d0a005ae511148d2478926b7a97d0c478ad7d7
7
+ data.tar.gz: 603e24714debdb62458b3bf92577784a1f51343dfa444d15273691f145b0dd4ef8c6dc9c2bff0394db1efdba32ba2ebcc870888aa4913a35b268f790694c4da0
@@ -45,16 +45,8 @@ module Katsuyoujin
45
45
  'くる' == base_form_hiragana
46
46
  end
47
47
 
48
- def godan_iru_eru?
49
- GODAN_IRU_ERU.include?(base_form_hiragana)
50
- end
51
-
52
- def godan_kuru_suru?
53
- GODAN_KURU_SURU.include?(base_form)
54
- end
55
-
56
48
  def irregular_godan?
57
- godan_iru_eru? || godan_kuru_suru?
49
+ Katsuyoujin.ruleset('godan/irregular').include?(base_form_hiragana)
58
50
  end
59
51
 
60
52
  def ichidan?
@@ -18,15 +18,16 @@ module Katsuyoujin
18
18
  private
19
19
 
20
20
  def ichidan_base(base_letter, hiragana: true)
21
- verb_root(hiragana) + ICHIDAN_BASE_TABLE[base_letter]
21
+ verb_root(hiragana) + Katsuyoujin.ruleset('ichidan/base')[base_letter]
22
22
  end
23
23
 
24
24
  def godan_base(base_letter, hiragana: true)
25
- verb_root(hiragana) + GODAN_BASE_TABLE[base_letter][verb.ending]
25
+ verb_root(hiragana) + Katsuyoujin.ruleset('godan/base')[base_letter][verb.ending]
26
26
  end
27
27
 
28
28
  def irregular_base(base_letter, hiragana: true)
29
- IRREGULAR_BASE_TABLE[base_letter][verb.hiragana_ending][hiragana ? 'hiragana' : 'kanji']
29
+ form = hiragana ? 'hiragana' : 'kanji'
30
+ Katsuyoujin.ruleset('irregular/base')[base_letter][verb.hiragana_ending][form]
30
31
  end
31
32
 
32
33
  def verb_root(hiragana = true)
@@ -1,3 +1,3 @@
1
1
  module Katsuyoujin
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.2.1'
3
3
  end
data/lib/katsuyoujin.rb CHANGED
@@ -6,37 +6,20 @@ require 'katsuyoujin/base'
6
6
  require 'katsuyoujin/analyzer'
7
7
 
8
8
  module Katsuyoujin
9
- def self.root
10
- File.dirname __dir__
11
- end
12
-
13
- def self.rules
14
- File.join root, 'rules'
15
- end
16
-
17
- GODAN_IRU_ERU = YAML.load_file(File.join(Katsuyoujin.rules, 'godan/iru_eru.yml')).freeze
18
- GODAN_KURU_SURU = YAML.load_file(File.join(Katsuyoujin.rules, 'godan/kuru_suru.yml')).freeze
19
-
20
- ICHIDAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'ichidan/base.yml').freeze
21
- GODAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'godan/base.yml').freeze
22
- IRREGULAR_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'irregular/base.yml').freeze
23
-
24
- CONJUGATIONS = {
25
- 'ichidan' => YAML.load_file(File.join(rules, 'ichidan/conjugations.yml')).freeze,
26
- 'godan' => YAML.load_file(File.join(rules, 'godan/conjugations.yml')).freeze,
27
- 'irregular' => YAML.load_file(File.join(rules, 'irregular/conjugations.yml')).freeze
28
- }
29
-
30
9
  def self.conjugate(word, *args, category: nil, hiragana: true)
31
10
  verb = Verb.new word
32
11
 
33
12
  vcat = category || verb.category
34
13
  vcat = 'irregular' if ['kuru', 'suru'].include?(vcat)
35
14
 
36
- rules = args.inject(CONJUGATIONS[vcat]) { |a, e| a[e] || {} }
15
+ rules = args.inject(ruleset("#{vcat}/conjugations")) { |a, e| a[e] || {} }
37
16
  return unless rules['base']
38
17
 
39
18
  base = Base.new(verb, rules['base']).conjugate category: category, hiragana: hiragana
40
19
  base + rules['attachment']
41
20
  end
21
+
22
+ def self.ruleset(rule)
23
+ YAML.load_file(File.join(File.dirname(__dir__), 'rules', "#{rule}.yml"))
24
+ end
42
25
  end
@@ -1,3 +1,11 @@
1
+ - "刷る"
2
+ - "摺る"
3
+ - "擦る"
4
+ - "摩る"
5
+ - "磨る"
6
+ - "擂る"
7
+ - "掏る"
8
+ - "繰る"
1
9
  - "あせる"
2
10
  - "あざける"
3
11
  - "だべる"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katsuyoujin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LuckyThirteen
@@ -146,8 +146,7 @@ files:
146
146
  - lib/katsuyoujin/version.rb
147
147
  - rules/godan/base.yml
148
148
  - rules/godan/conjugations.yml
149
- - rules/godan/iru_eru.yml
150
- - rules/godan/kuru_suru.yml
149
+ - rules/godan/irregular.yml
151
150
  - rules/ichidan/base.yml
152
151
  - rules/ichidan/conjugations.yml
153
152
  - rules/irregular/base.yml
@@ -1,8 +0,0 @@
1
- - "刷る"
2
- - "摺る"
3
- - "擦る"
4
- - "摩る"
5
- - "磨る"
6
- - "擂る"
7
- - "掏る"
8
- - "繰る"