arabic_conjugator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
YjAxMDZiNDU0NmE0YjBmN2U0N2NkYTEzM2QwZDYxNTkyMTE5OWMwNw==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
OTgxZThhMjMwYjZkYTljNzgxNWI0MmNkZWQ0YzRmMjFlMWFlMzlhNQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
NzJiN2JiYjFmMWNlOTRlNDBlMzc2NzQzNzdlYWU5OTdjNTFhY2ZhNzcxNzNj
|
|
10
|
+
ZjA5MmEwMDJiZmY0MGJjOTVkZjVlN2FmYjFjZmVlZmEwNDAxNTc4NjFhMTI5
|
|
11
|
+
OTU5ZGNkODA3NmY0Yjk1ODk0NjRkODYwMmE5MGFlY2I5N2I3NDU=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
ZTdiMzBjMTgyNGY0MWEwOTFlYjZkMmE2Njc1NWQxZjJmOTQzZjg3MzE5ZTU5
|
|
14
|
+
ZmE0NTk3MDllN2NjZGQyYjc1YzE0ZjRlZTk4ZDZmMWM2M2VlMDE5MGUyOWY5
|
|
15
|
+
ZDVlNWJmNTA3MDZiNTE0OTBjNjhkODk4N2U4NTBiZDdjOTJiM2M=
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
arabic_conjugator (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
diff-lcs (1.2.5)
|
|
10
|
+
rake (10.1.1)
|
|
11
|
+
rspec (2.14.1)
|
|
12
|
+
rspec-core (~> 2.14.0)
|
|
13
|
+
rspec-expectations (~> 2.14.0)
|
|
14
|
+
rspec-mocks (~> 2.14.0)
|
|
15
|
+
rspec-core (2.14.8)
|
|
16
|
+
rspec-expectations (2.14.5)
|
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
18
|
+
rspec-mocks (2.14.6)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
arabic_conjugator!
|
|
25
|
+
bundler (~> 1.5)
|
|
26
|
+
rake
|
|
27
|
+
rspec
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'arabic_conjugator/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "arabic_conjugator"
|
|
8
|
+
spec.version = ArabicConjugator::VERSION
|
|
9
|
+
spec.authors = ["Anne Willborn"]
|
|
10
|
+
spec.email = ["awillborn@gmail.com"]
|
|
11
|
+
spec.summary = %q{Conjugate MSA verbs}
|
|
12
|
+
spec.homepage = ""
|
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
16
|
+
spec.require_paths = ["lib"]
|
|
17
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
18
|
+
spec.add_development_dependency "rake"
|
|
19
|
+
spec.add_development_dependency "rspec"
|
|
20
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#coding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative 'arabic_conjugator/version'
|
|
4
|
+
require_relative 'arabic_conjugator/factories/type_factory'
|
|
5
|
+
require_relative 'arabic_conjugator/factories/base_factory'
|
|
6
|
+
require_relative 'arabic_conjugator/factories/tense_factory'
|
|
7
|
+
require_relative 'arabic_conjugator/past_tense'
|
|
8
|
+
require_relative 'arabic_conjugator/present_tense'
|
|
9
|
+
|
|
10
|
+
class Verb
|
|
11
|
+
attr_reader :root1, :root2, :root3, :tense, :types, :form, :base, :opts, :pronoun
|
|
12
|
+
|
|
13
|
+
def initialize(opts)
|
|
14
|
+
@opts = opts
|
|
15
|
+
@root1 = opts[:root1]
|
|
16
|
+
@root2 = opts[:root2]
|
|
17
|
+
@root3 = opts[:root3]
|
|
18
|
+
@pronoun = opts[:pronoun]
|
|
19
|
+
@tense = opts[:tense]
|
|
20
|
+
@form = opts[:form]
|
|
21
|
+
@types = find_types
|
|
22
|
+
@base = find_base
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def find_types
|
|
26
|
+
TypeFactory.new(@root1, @root2, @root3, @form).load_types
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def find_base
|
|
30
|
+
BaseFactory.new(self).load_base
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def find_tense
|
|
34
|
+
TenseFactory.new(self).create_tense
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def conjugate
|
|
38
|
+
@tense = find_tense
|
|
39
|
+
@tense.conjugate
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
PAST_AFFIXES = { :I => "ت", :you_m => "ت", :you_f => "ت", :she => "ت" , :he =>'', :we => "نا", :you_pl => "تم", :they => "وا" }
|
|
4
|
+
PRESENT_AFFIXES = { :I => ["أ", ''], :you_m => ["ت", ''], :you_f => ["ت", "ين"], :he => ["ي", ""], :she => ["ت", ""], :we => ["ن", ''], :you_pl => ["ت", "ون"], :they => ["ي", "ون"] }
|
|
5
|
+
|
|
6
|
+
class Base
|
|
7
|
+
|
|
8
|
+
def initialize(verb)
|
|
9
|
+
@types = verb.types[0]
|
|
10
|
+
@root1 = verb.root1
|
|
11
|
+
@root2 = verb.root2
|
|
12
|
+
@root3 = verb.root3
|
|
13
|
+
@pronoun = verb.pronoun
|
|
14
|
+
adjust_first_radical if @root1 == "ء"
|
|
15
|
+
adjust_second_radical if @root2 == "ء"
|
|
16
|
+
adjust_third_radical if @root3 == "ء"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def regular_base
|
|
20
|
+
if @root3 == "أ" && @pronoun == :they
|
|
21
|
+
@base[0...-1] + "ؤ"
|
|
22
|
+
else
|
|
23
|
+
@base
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def defective_base
|
|
28
|
+
@base = @base[0...-1]
|
|
29
|
+
if @pronoun == :he
|
|
30
|
+
@base + "ى"
|
|
31
|
+
elsif [:she, :they].include?(@pronoun)
|
|
32
|
+
@base
|
|
33
|
+
else
|
|
34
|
+
@base + "ي"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def assimilated_base
|
|
39
|
+
@base
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def hollow_base
|
|
43
|
+
if @root3 == "أ" && @pronoun == :they
|
|
44
|
+
@base[0...-1] + "ؤ"
|
|
45
|
+
else
|
|
46
|
+
@base
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def doubled_base
|
|
51
|
+
if [:he, :she, :they].include?(@pronoun)
|
|
52
|
+
@base[0...-1] + "ّ"
|
|
53
|
+
else
|
|
54
|
+
@base
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def assimilated_defective_base
|
|
59
|
+
defective_base
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def hollow_defective_base
|
|
63
|
+
defective_base
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def adjust_first_radical
|
|
67
|
+
@root1 = "أ"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require_relative '../past_bases/form_I_past_base'
|
|
2
|
+
require_relative '../past_bases/form_II_past_base'
|
|
3
|
+
require_relative '../past_bases/form_III_past_base'
|
|
4
|
+
require_relative '../past_bases/form_IV_past_base'
|
|
5
|
+
require_relative '../past_bases/form_V_past_base'
|
|
6
|
+
require_relative '../past_bases/form_VI_past_base'
|
|
7
|
+
require_relative '../past_bases/form_VII_past_base'
|
|
8
|
+
require_relative '../past_bases/form_VIII_past_base'
|
|
9
|
+
require_relative '../past_bases/form_X_past_base'
|
|
10
|
+
require_relative '../present_bases/form_I_present_base'
|
|
11
|
+
require_relative '../present_bases/form_II_present_base'
|
|
12
|
+
require_relative '../present_bases/form_III_present_base'
|
|
13
|
+
require_relative '../present_bases/form_IV_present_base'
|
|
14
|
+
require_relative '../present_bases/form_V_present_base'
|
|
15
|
+
require_relative '../present_bases/form_VI_present_base'
|
|
16
|
+
require_relative '../present_bases/form_VII_present_base'
|
|
17
|
+
require_relative '../present_bases/form_VIII_present_base'
|
|
18
|
+
require_relative '../present_bases/form_X_present_base'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BaseFactory
|
|
22
|
+
FORM_MAPPING = {
|
|
23
|
+
"1past" => FormIPastBase,
|
|
24
|
+
"2past" => FormIIPastBase,
|
|
25
|
+
"3past" => FormIIIPastBase,
|
|
26
|
+
"4past" => FormIVPastBase,
|
|
27
|
+
"5past" => FormVPastBase,
|
|
28
|
+
"6past" => FormVIPastBase,
|
|
29
|
+
"7past" => FormVIIPastBase,
|
|
30
|
+
"8past" => FormVIIIPastBase,
|
|
31
|
+
"10past" => FormXPastBase,
|
|
32
|
+
"1present" => FormIPresentBase,
|
|
33
|
+
"2present" => FormIIPresentBase,
|
|
34
|
+
"3present" => FormIIIPresentBase,
|
|
35
|
+
"4present" => FormIVPresentBase,
|
|
36
|
+
"5present" => FormVPresentBase,
|
|
37
|
+
"6present" => FormVIPresentBase,
|
|
38
|
+
"7present" => FormVIIPresentBase,
|
|
39
|
+
"8present" => FormVIIIPresentBase,
|
|
40
|
+
"10present" => FormXPresentBase
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def initialize(verb)
|
|
44
|
+
@verb = verb
|
|
45
|
+
@form_name = verb.form
|
|
46
|
+
@tense = verb.opts[:tense]
|
|
47
|
+
@types = verb.types[0]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def load_base
|
|
51
|
+
form = FORM_MAPPING[@form_name.concat(@tense)].new(@verb)
|
|
52
|
+
case @types
|
|
53
|
+
when "assimilated defective"
|
|
54
|
+
form.assimilated_defective_base
|
|
55
|
+
when "hollow defective"
|
|
56
|
+
form.hollow_defective_base
|
|
57
|
+
when "assimilated"
|
|
58
|
+
form.assimilated_base
|
|
59
|
+
when "defective"
|
|
60
|
+
form.defective_base
|
|
61
|
+
when "hollow"
|
|
62
|
+
form.hollow_base
|
|
63
|
+
when "doubled"
|
|
64
|
+
form.doubled_base
|
|
65
|
+
when "regular"
|
|
66
|
+
form.regular_base
|
|
67
|
+
when "assimilated_taa"
|
|
68
|
+
form.assimilated_taa_base
|
|
69
|
+
when "morphed_taa"
|
|
70
|
+
form.morphed_taa_base
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative '../past_tense'
|
|
2
|
+
require_relative '../present_tense'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TenseFactory
|
|
6
|
+
MAPPING = {
|
|
7
|
+
"past" => Past,
|
|
8
|
+
"present" => Present
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
def initialize(verb)
|
|
12
|
+
@verb = verb
|
|
13
|
+
@tense = verb.opts[:tense]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_tense
|
|
17
|
+
MAPPING[@tense].new(@verb)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class TypeFactory
|
|
4
|
+
attr_reader :type
|
|
5
|
+
|
|
6
|
+
def initialize(root1, root2, root3, form)
|
|
7
|
+
@root1 = root1
|
|
8
|
+
@root2 = root2
|
|
9
|
+
@root3 = root3
|
|
10
|
+
@form = form
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def load_types
|
|
14
|
+
types = []
|
|
15
|
+
types << "assimilated defective" if assimilated_defective?
|
|
16
|
+
types << "hollow defective" if hollow_defective?
|
|
17
|
+
types << "defective" if defective?
|
|
18
|
+
types << "hollow" if hollow?
|
|
19
|
+
types << "doubled" if doubled?
|
|
20
|
+
types << "assimilated" if assimilated?
|
|
21
|
+
types << "assimilated_taa" if assimilated_taa?
|
|
22
|
+
types << "morphed_taa" if morphed_taa?
|
|
23
|
+
types << "regular" if types.empty?
|
|
24
|
+
types
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def assimilated_defective?
|
|
28
|
+
(@root1 == "و" || @root1 == "ي") && (@root3 == "و" || @root3 == "ي")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def hollow_defective?
|
|
32
|
+
(@root2 == "و" || @root2 == "ي") && (@root3 == "و" || @root3 == "ي")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def hollow?
|
|
36
|
+
@root2 == "و" || @root2 == "ي"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def defective?
|
|
40
|
+
@root3 == "و" || @root3 == "ي"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def doubled?
|
|
44
|
+
@root2 == @root3
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def assimilated?
|
|
48
|
+
@root1 == "و" || @root1 == "ي"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def assimilated_taa?
|
|
52
|
+
@form == "8" && ["ت", "ث", "د", "ط", "ظ"].include?(@root1)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def morphed_taa?
|
|
56
|
+
@form == "8" && ["ذ", "ز", "ص", "ض"].include?(@root1)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|