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 +4 -4
- data/lib/katsuyoujin/analyzer.rb +1 -9
- data/lib/katsuyoujin/base.rb +4 -3
- data/lib/katsuyoujin/version.rb +1 -1
- data/lib/katsuyoujin.rb +5 -22
- data/rules/godan/{iru_eru.yml → irregular.yml} +8 -0
- metadata +2 -3
- data/rules/godan/kuru_suru.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11bf087d163f85a06dc34142b52f36804fccc8e9
|
4
|
+
data.tar.gz: 40170f7f9ea5504cff44aca563278f4647de0974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e58cf72f25754d6f92d31d6229df04083ed886c065f1494208a1b23f923d7009de18932858aad94fe02808c71d0a005ae511148d2478926b7a97d0c478ad7d7
|
7
|
+
data.tar.gz: 603e24714debdb62458b3bf92577784a1f51343dfa444d15273691f145b0dd4ef8c6dc9c2bff0394db1efdba32ba2ebcc870888aa4913a35b268f790694c4da0
|
data/lib/katsuyoujin/analyzer.rb
CHANGED
@@ -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
|
-
|
49
|
+
Katsuyoujin.ruleset('godan/irregular').include?(base_form_hiragana)
|
58
50
|
end
|
59
51
|
|
60
52
|
def ichidan?
|
data/lib/katsuyoujin/base.rb
CHANGED
@@ -18,15 +18,16 @@ module Katsuyoujin
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def ichidan_base(base_letter, hiragana: true)
|
21
|
-
verb_root(hiragana) +
|
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) +
|
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
|
-
|
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)
|
data/lib/katsuyoujin/version.rb
CHANGED
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(
|
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
|
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/
|
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
|