arabic_conjugator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +22 -0
- data/README.md +8 -0
- data/Rakefile +1 -0
- data/arabic_conjugator.gemspec +20 -0
- data/lib/arabic_conjugator.rb +43 -0
- data/lib/arabic_conjugator/base.rb +70 -0
- data/lib/arabic_conjugator/factories/base_factory.rb +74 -0
- data/lib/arabic_conjugator/factories/tense_factory.rb +20 -0
- data/lib/arabic_conjugator/factories/type_factory.rb +59 -0
- data/lib/arabic_conjugator/form.rb +10 -0
- data/lib/arabic_conjugator/form_II_hollow_defective.rb +6 -0
- data/lib/arabic_conjugator/form_I_defective.rb +5 -0
- data/lib/arabic_conjugator/form_I_defective_past.rb +12 -0
- data/lib/arabic_conjugator/form_I_defective_present.rb +9 -0
- data/lib/arabic_conjugator/form_I_hamzated_past.rb +16 -0
- data/lib/arabic_conjugator/form_I_hamzated_present.rb +16 -0
- data/lib/arabic_conjugator/form_I_hollow_past.rb +5 -0
- data/lib/arabic_conjugator/form_I_hollow_present.rb +6 -0
- data/lib/arabic_conjugator/form_VIII_hamzated.rb +5 -0
- data/lib/arabic_conjugator/form_VIII_hollow.rb +5 -0
- data/lib/arabic_conjugator/past_bases/form_III_past_base.rb +42 -0
- data/lib/arabic_conjugator/past_bases/form_II_past_base.rb +36 -0
- data/lib/arabic_conjugator/past_bases/form_IV_past_base.rb +46 -0
- data/lib/arabic_conjugator/past_bases/form_I_past_base.rb +57 -0
- data/lib/arabic_conjugator/past_bases/form_VIII_past_base.rb +78 -0
- data/lib/arabic_conjugator/past_bases/form_VII_past_base.rb +26 -0
- data/lib/arabic_conjugator/past_bases/form_VI_past_base.rb +32 -0
- data/lib/arabic_conjugator/past_bases/form_V_past_base.rb +35 -0
- data/lib/arabic_conjugator/past_bases/form_X_past_base.rb +40 -0
- data/lib/arabic_conjugator/past_tense.rb +12 -0
- data/lib/arabic_conjugator/present_bases/form_III_present_base.rb +30 -0
- data/lib/arabic_conjugator/present_bases/form_II_present_base.rb +34 -0
- data/lib/arabic_conjugator/present_bases/form_IV_present_base.rb +48 -0
- data/lib/arabic_conjugator/present_bases/form_I_present_base.rb +54 -0
- data/lib/arabic_conjugator/present_bases/form_VIII_present_base.rb +67 -0
- data/lib/arabic_conjugator/present_bases/form_VII_present_base.rb +31 -0
- data/lib/arabic_conjugator/present_bases/form_VI_present_base.rb +47 -0
- data/lib/arabic_conjugator/present_bases/form_V_present_base.rb +30 -0
- data/lib/arabic_conjugator/present_bases/form_X_present_base.rb +30 -0
- data/lib/arabic_conjugator/present_tense.rb +12 -0
- data/lib/arabic_conjugator/version.rb +3 -0
- data/spec/past_tense/formIII_past_spec.rb +75 -0
- data/spec/past_tense/formII_past_spec.rb +108 -0
- data/spec/past_tense/formIV_past_spec.rb +122 -0
- data/spec/past_tense/formI_past_spec.rb +160 -0
- data/spec/past_tense/formVIII_past_spec.rb +135 -0
- data/spec/past_tense/formVII_past_spec.rb +60 -0
- data/spec/past_tense/formVI_past_spec.rb +70 -0
- data/spec/past_tense/formV_past_spec.rb +77 -0
- data/spec/past_tense/formX_past_spec.rb +78 -0
- data/spec/present_tense/formIII_present_spec.rb +80 -0
- data/spec/present_tense/formII_present_spec.rb +102 -0
- data/spec/present_tense/formIV_present_spec.rb +107 -0
- data/spec/present_tense/formI_present_spec.rb +143 -0
- data/spec/present_tense/formVIII_present_spec.rb +126 -0
- data/spec/present_tense/formVII_present_spec.rb +50 -0
- data/spec/present_tense/formVI_present_spec.rb +75 -0
- data/spec/present_tense/formV_present_spec.rb +87 -0
- data/spec/present_tense/formX_present_spec.rb +68 -0
- data/spec/spec_helper.rb +5 -0
- metadata +166 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormIIIPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = @root1 + "ا" + @root2 + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def defective_base
|
11
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
12
|
+
@base[0...-1]
|
13
|
+
else
|
14
|
+
@base[0...-1] + "ي"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def adjust_first_radical
|
19
|
+
@root1 = "ؤ"
|
20
|
+
end
|
21
|
+
|
22
|
+
def adjust_second_radical
|
23
|
+
@root2 = "ئ"
|
24
|
+
end
|
25
|
+
|
26
|
+
def adjust_third_radical
|
27
|
+
@root3 = "ئ"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormIIPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = @root1 + @root2 + "ّ" + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def defective_base
|
11
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
12
|
+
@base[0...-1]
|
13
|
+
else
|
14
|
+
@base
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def doubled_base
|
19
|
+
@base
|
20
|
+
end
|
21
|
+
|
22
|
+
def adjust_first_radical
|
23
|
+
@root1 = "ؤ"
|
24
|
+
end
|
25
|
+
|
26
|
+
def adjust_second_radical
|
27
|
+
@root2 = "ئ"
|
28
|
+
end
|
29
|
+
|
30
|
+
def adjust_third_radical
|
31
|
+
@root3 = "ئ"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormIVPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = @root1 + @root2 + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def defective_base
|
11
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
12
|
+
@base[0...-1]
|
13
|
+
else
|
14
|
+
@base
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def assimilated_base
|
19
|
+
"و" + @base[1..-1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def hollow_base
|
23
|
+
if @root3 == "ئ" && [:I, :you_m, :he, :she, :we].include?(@pronoun)
|
24
|
+
@root1 + "يء"
|
25
|
+
elsif @root3 == "ئ" && [:you_pl, :they].include?(@pronoun)
|
26
|
+
@root1 + "يؤ"
|
27
|
+
else
|
28
|
+
@root1 + "ي" + @root3
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def doubled_base
|
33
|
+
@base[0...-1] + "ّ"
|
34
|
+
end
|
35
|
+
|
36
|
+
def adjust_first_radical
|
37
|
+
@root1 = "ؤ"
|
38
|
+
end
|
39
|
+
|
40
|
+
def adjust_second_radical
|
41
|
+
@root2 = "ئ"
|
42
|
+
end
|
43
|
+
|
44
|
+
def adjust_third_radical
|
45
|
+
@root3 = "ئ"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative '../form_I_hamzated_present'
|
3
|
+
require_relative '../form_I_hollow_present'
|
4
|
+
require_relative '../form_I_defective_present'
|
5
|
+
require_relative '../base'
|
6
|
+
|
7
|
+
class FormIPresentBase < Base
|
8
|
+
|
9
|
+
def initialize(verb)
|
10
|
+
super
|
11
|
+
@base = @root1 + @root2 + @root3
|
12
|
+
end
|
13
|
+
|
14
|
+
def assimilated_base
|
15
|
+
@root2 + @root3
|
16
|
+
end
|
17
|
+
|
18
|
+
def hollow_base
|
19
|
+
@base = @root1 + FORM_I_HOLLOW_PRESENT[@base] + @root3 if FORM_I_HOLLOW_PRESENT[@base]
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def doubled_base
|
24
|
+
@base[0...-1] + "ّ"
|
25
|
+
end
|
26
|
+
|
27
|
+
def defective_base
|
28
|
+
base = @base[0...-1]
|
29
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
30
|
+
base
|
31
|
+
else
|
32
|
+
base + (FORM_I_DEFECTIVE_PRESENT[@base] ||= @root3)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def assimilated_defective_base
|
37
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
38
|
+
@root2
|
39
|
+
else
|
40
|
+
@root2 + @root3
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def adjust_second_radical
|
45
|
+
base = @root1 + @root2 + @root3
|
46
|
+
@root2 = FORM_I_HAMZATED_PRESENT[base]
|
47
|
+
end
|
48
|
+
|
49
|
+
def adjust_third_radical
|
50
|
+
base = @root1 + @root2 + @root3
|
51
|
+
@root3 = FORM_I_HAMZATED_PRESENT[base]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormVIIIPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = @root1 + "ت" + @root2 + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def regular_base
|
11
|
+
@base
|
12
|
+
end
|
13
|
+
|
14
|
+
def hollow_base
|
15
|
+
@root2 = (FORM_VIII_HOLLOW[@root1+@root2+@root3] ||= "ا")
|
16
|
+
@base = @root1 + "ت" + @root2 + @root3
|
17
|
+
@base = morphed_taa_base if ["ز", "ذ", "ص", "ض"].include?(@root1)
|
18
|
+
@base
|
19
|
+
end
|
20
|
+
|
21
|
+
def assimilated_defective_base
|
22
|
+
@base = "تّ" + @root2 + @root3
|
23
|
+
if [:you_f, :you_pl, :they].include?(@pronoun)
|
24
|
+
@base[0...-1]
|
25
|
+
else
|
26
|
+
@base[0...-1] + "ي"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def defective_base
|
31
|
+
if [:you_f, :you_pl, :they].include?(@pronoun)
|
32
|
+
@base[0...-1]
|
33
|
+
else
|
34
|
+
@base[0...-1] + "ي"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def assimilated_base
|
39
|
+
"تّ" + @root2 + @root3
|
40
|
+
end
|
41
|
+
|
42
|
+
def doubled_base
|
43
|
+
@base = morphed_taa_base if ["ز", "ذ", "ص", "ض"].include?(@root1)
|
44
|
+
@base[0...-1] + "ّ"
|
45
|
+
end
|
46
|
+
|
47
|
+
def assimilated_taa_base
|
48
|
+
@root1 + "ّ" + @root2 + @root3
|
49
|
+
end
|
50
|
+
|
51
|
+
def morphed_taa_base
|
52
|
+
if ["ز", "ذ"].include?(@root1)
|
53
|
+
@root1 + "د" + @root2 + @root3
|
54
|
+
else
|
55
|
+
@root1 + "ط" + @root2 + @root3
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def adjust_second_radical
|
60
|
+
@root2 = "ئ"
|
61
|
+
end
|
62
|
+
|
63
|
+
def adjust_third_radical
|
64
|
+
@root3 = "ئ"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormVIIPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = "ن" + @root1 + @root2 + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def hollow_base
|
11
|
+
@root2 = "ا"
|
12
|
+
"ن" + @root1 + @root2 + @root3
|
13
|
+
end
|
14
|
+
|
15
|
+
def doubled_base
|
16
|
+
@base[0...-1] + "ّ"
|
17
|
+
end
|
18
|
+
|
19
|
+
def defective_base
|
20
|
+
if [:you_f, :you_pl, :they].include?(@pronoun)
|
21
|
+
@base[0...-1]
|
22
|
+
else
|
23
|
+
@base[0...-1] + "ي"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def adjust_third_radical
|
28
|
+
@root3 = "ئ"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
# encoding: utf-8
|
5
|
+
|
6
|
+
class FormVIPresentBase < Base
|
7
|
+
|
8
|
+
def initialize(verb)
|
9
|
+
super
|
10
|
+
@base = calculate_base
|
11
|
+
end
|
12
|
+
|
13
|
+
def defective_base
|
14
|
+
if [:you_f, :you_pl, :they].include?(@pronoun)
|
15
|
+
@base[0...-1]
|
16
|
+
else
|
17
|
+
@base[0...-1] + "ى"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def adjust_first_radical
|
22
|
+
@root1 = "آ"
|
23
|
+
end
|
24
|
+
|
25
|
+
def adjust_second_radical
|
26
|
+
@root2 = "ء"
|
27
|
+
end
|
28
|
+
|
29
|
+
def adjust_third_radical
|
30
|
+
if [:they, :you_pl].include?(@pronoun)
|
31
|
+
@root3 = "ؤ"
|
32
|
+
elsif @pronoun == :you_f
|
33
|
+
@root3 == "ئ"
|
34
|
+
else
|
35
|
+
@root3 == "أ"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def calculate_base
|
40
|
+
if @root1 == "آ"
|
41
|
+
"ت" + @root1 + @root2 + @root3
|
42
|
+
else
|
43
|
+
"ت" + @root1 + "ا" + @root2 + @root3
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormVPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = "ت" + @root1 + @root2 + "ّ" + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def doubled_base
|
11
|
+
@base
|
12
|
+
end
|
13
|
+
|
14
|
+
def defective_base
|
15
|
+
if [:you_f, :you_pl, :they].include?(@pronoun)
|
16
|
+
@base[0...-1]
|
17
|
+
else
|
18
|
+
@base[0...-1] + "ى"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def adjust_second_radical
|
23
|
+
@root2 = "أ"
|
24
|
+
end
|
25
|
+
|
26
|
+
def adjust_third_radical
|
27
|
+
@root3 = "أ"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FormXPresentBase < Base
|
4
|
+
|
5
|
+
def initialize(verb)
|
6
|
+
super
|
7
|
+
@base = "ست" + @root1 + @root2 + @root3
|
8
|
+
end
|
9
|
+
|
10
|
+
def doubled_base
|
11
|
+
@base[0...-1] + "ّ"
|
12
|
+
end
|
13
|
+
|
14
|
+
def defective_base
|
15
|
+
if [:you_pl, :they, :you_f].include?(@pronoun)
|
16
|
+
@base[0...-1]
|
17
|
+
else
|
18
|
+
@base
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def adjust_second_radical
|
23
|
+
@root2 = "أ"
|
24
|
+
end
|
25
|
+
|
26
|
+
def adjust_third_radical
|
27
|
+
@root3 = "ئ"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Form III Past" do
|
6
|
+
|
7
|
+
context "regular past" do
|
8
|
+
it 'conjugates formIII' do
|
9
|
+
verb = Verb.new({root1: "ش", root2: "ه", root3: "د", form: "3", tense: "past", pronoun: :you_pl})
|
10
|
+
expect(verb.conjugate).to eq("شاهدتم")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'conjugates form III regular past with first radical hamza' do
|
14
|
+
verb = Verb.new({root1: "ء", root2: "ك", root3: "ل", form: "3", tense: "past", pronoun: :you_pl})
|
15
|
+
expect(verb.conjugate).to eq("آكلتم")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'conjugates form III regular past with second radical hamza' do
|
19
|
+
verb = Verb.new({root1: "س", root2: "ء", root3: "ل", form: "3", tense: "past", pronoun: :you_pl})
|
20
|
+
expect(verb.conjugate).to eq("ساءلتم")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'conjugates form III regular past with third radical hamza' do
|
24
|
+
verb = Verb.new({root1: "ف", root2: "ج", root3: "ء", form: "3", tense: "past", pronoun: :she})
|
25
|
+
expect(verb.conjugate).to eq("فاجأت")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "defective past" do
|
30
|
+
it 'conjugates formIII defective past with final root waaw' do
|
31
|
+
verb = Verb.new({root1: "ن", root2: "د", root3: "ي", form: "3", tense: "past", pronoun: :he})
|
32
|
+
expect(verb.conjugate).to eq("نادى")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'conjugates formIII defective past with final root yaa, :she' do
|
36
|
+
verb = Verb.new({root1: "ح", root2: "م", root3: "ي", form: "3", tense: "past", pronoun: :he})
|
37
|
+
expect(verb.conjugate).to eq("حامى")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'conjugates formIII hollow-defective past' do
|
41
|
+
verb = Verb.new({root1: "س", root2: "و", root3: "ي", form: "3", tense: "past", pronoun: :he})
|
42
|
+
expect(verb.conjugate).to eq("ساوى")
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'conjugates formIII hamzated-defective past' do
|
46
|
+
verb = Verb.new({root1: "ء", root2: "ت", root3: "ي", form: "3", tense: "past", pronoun: :you_f})
|
47
|
+
expect(verb.conjugate).to eq("آتيت")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "assimilated past" do
|
52
|
+
it 'conjugates formIII assimilated past' do
|
53
|
+
verb = Verb.new({root1: "و", root2: "ف", root3: "ق", form: "3", tense: "past", pronoun: :we})
|
54
|
+
expect(verb.conjugate).to eq("وافقنا")
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'conjugates formIII assimilated past, first radical yaa' do
|
58
|
+
verb = Verb.new({root1: "ي", root2: "س", root3: "ر", form: "3", tense: "past", pronoun: :we})
|
59
|
+
expect(verb.conjugate).to eq("ياسرنا")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "hollow past" do
|
64
|
+
it 'conjugates formIII hollow past, first radical waaw' do
|
65
|
+
verb = Verb.new({root1: "ح", root2: "و", root3: "ل", form: "3", tense: "past", pronoun: :we})
|
66
|
+
expect(verb.conjugate).to eq("حاولنا")
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'conjugates formIII hollow past, medial yaa' do
|
70
|
+
verb = Verb.new({root1: "ب", root2: "ي", root3: "ع", form: "3", tense: "past", pronoun: :you_pl})
|
71
|
+
expect(verb.conjugate).to eq("بايعتم")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|