zenlish 0.2.02 → 0.2.03

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
  SHA256:
3
- metadata.gz: 5a4f38ce593249cf97998ec7d51977400b6bb1445a368823b3c8db0f779aec41
4
- data.tar.gz: 30e519af42ccf67586f3314892d63a8150200e671a4c42e5185154746ea2218d
3
+ metadata.gz: 5525de088c625d91774e9f3e33898026f720c697f8901a0dce1764f28137194e
4
+ data.tar.gz: 4c7be3992f7fa3535a7cba502ad34cf43ecbecb0925a85824dea9682452a4ed4
5
5
  SHA512:
6
- metadata.gz: 007460f06685b5a84c239b70f14503d1420deffd8291b087bea657a966292e3c04be01f3dd973cbd7e6f543ba1e0daf86afad73d2085da2b7c23ad5c3e3e7624
7
- data.tar.gz: 9a3a5904dfd78edbb50a7886d1d830e400619039bc736760356381c9845dd9ec2919089c0803c64ffef89b2d9d55fe0b061b4542e25a1371550c6863a7d4aafa
6
+ metadata.gz: 3a729cc73a70e8ea628a02ed3133e16c7bb6bedacc70650d205562ee42cd367e1ebeab403c5699b6390649c8d78721f619e258c8540659a3e83963e688f6d274
7
+ data.tar.gz: ee8a24b35b41f87fab98c8d441a1a9051fafa07c44e1e8af5c7133a59f268440b883073cfd1cec2151856d23a8f8ae65c8bd0014eb178b8fbe92b19f138b4f1e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  # CHANGELOG
2
+ ## [0.2.03] - 2020-02-07
3
+ Zenlish can now inflect the irregular verbs `be`, `do`, and `have`.
4
+
5
+ ## Changed
6
+ - Class `WClass::IrreglarVerbBe`: added specific inflection table.
7
+ - Class `WClass::IrreglarVerbDo`: added specific inflection table.
8
+ - Class `WClass::IrreglarVerbHave`: added specific inflection table.
9
+
2
10
  ## [0.2.02] - 2020-02-06
3
11
  Extending the inflection model to irregular verbs. Zenlish can inflect all irregular verbs in its dictionary (except modals and be).
4
12
 
@@ -23,7 +31,6 @@ Extending the inflection model to regular verbs. Zenlish can inflect all regular
23
31
  - Class `Inflect::Membership` Now an inflection table can test whether a value is included in a set of values.
24
32
  - Class `Inflect::NotEquals` Now an inflection table can test for inequality
25
33
 
26
-
27
34
  ## [0.2.00] - 2020-01-30
28
35
  A lot of internal additions, such an initial feature model, embryonic inflection model.
29
36
  This is WIP.
@@ -26,7 +26,7 @@ module Zenlish
26
26
  else
27
27
  theConstraints
28
28
  end
29
- err_msg = "Table has #{headings.size} headings."
29
+ err_msg = "Table has #{headings.size} headings, instead of #{constraints.size}"
30
30
  raise StandardError, err_msg if constraints.size != headings.size
31
31
  actuals = []
32
32
  headings.each_with_index do |hd, idx|
@@ -83,13 +83,13 @@ module Zenlish
83
83
 
84
84
  inequality_cond
85
85
  end
86
-
86
+
87
87
  def in?(*theMembers)
88
88
  arg = FormalArgument.new(conds.size)
89
89
  membership_cond = Membership.new(arg, theMembers)
90
90
  conds << membership_cond
91
91
 
92
- membership_cond
92
+ membership_cond
93
93
  end
94
94
 
95
95
  def dont_care
@@ -99,6 +99,10 @@ module Zenlish
99
99
  item
100
100
  end
101
101
 
102
+ def literal(aLiteral)
103
+ LiteralAsIs.new(aLiteral)
104
+ end
105
+
102
106
  def col(aColName)
103
107
  col_index = headings.find_index { |hd| hd.label == aColName }
104
108
  err_msg = "Cannot find heading named '#{aColName}'."
@@ -71,9 +71,7 @@ unless defined?(Zenlish::Lang::Dictionary)
71
71
  add_entry('difficult', 'Adjective')
72
72
  add_entry('different', 'Adjective')
73
73
  add_entry('do', 'AuxiliaryDo')
74
- add_entry('do', 'IrregularVerbDo') do
75
- forms past_simple: 'did', past_participle: 'done'
76
- end
74
+ add_entry('do', 'IrregularVerbDo')
77
75
  add_entry('each', 'DistributiveDeterminer')
78
76
  add_entry('each', 'Pronoun')
79
77
  add_entry('exist', 'RegularVerb')
@@ -88,7 +86,9 @@ unless defined?(Zenlish::Lang::Dictionary)
88
86
  add_entry('good', 'Adjective')
89
87
  add_entry('have', 'IrregularVerbHave')
90
88
  add_entry('happen', 'RegularVerb')
91
- add_entry('hear', 'IrregularLinkingVerb')
89
+ add_entry('hear', 'IrregularLinkingVerb') do
90
+ forms past_simple: 'heard', past_participle: 'heard'
91
+ end
92
92
  add_entry('here', 'Adverb')
93
93
  # example: ...from here (works as a pronoun of a place)
94
94
  add_entry('here', 'CommonNoun', {'NUMBER' => enumeration(:singular),
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.2.02'.freeze
2
+ VERSION = '0.2.03'.freeze
3
3
  end
@@ -4,6 +4,59 @@ module Zenlish
4
4
  module WClasses
5
5
  # The `be` verb used as a lexical verb (as opposed auxiliary verb).
6
6
  class IrregularVerbBe < IrregularVerb
7
+ def initialize
8
+ super()
9
+ end
10
+
11
+ # The mix-in module used to extend the lexeme
12
+ # @return [Module, NilClass]
13
+ def extension
14
+ nil
15
+ end
16
+
17
+ private
18
+
19
+ def init_feature_defs
20
+ super
21
+ # Create standard feature definitions for irregular verbs.
22
+ feature_def_dsl {
23
+ feature_def 'PARADIGM' => [identifier, 'Verb_be_inflection'] # 2nd item is default value
24
+ }
25
+ end
26
+
27
+ def init_paradigms
28
+ builder = Inflect::InflectionTableBuilder.new
29
+ table = builder.build('Verb_be_inflection') do
30
+ feature_heading 'PERSON'
31
+ feature_heading 'NUMBER'
32
+ feature_heading 'TIME'
33
+ # PERSON NUMBER TIME
34
+ rule([equals(:first), equals(:singular), equals(:present) ], literal('am'))
35
+ rule([equals(:second), equals(:singular), equals(:present) ], literal('are'))
36
+ rule([equals(:third), equals(:singular), equals(:present) ], literal('is'))
37
+ rule([dont_care, equals(:plural), equals(:present) ], literal('are'))
38
+ rule([dont_care, dont_care, equals(:progressive) ], literal('being'))
39
+ rule([in?(:first, :third), equals(:singular), equals(:past_simple) ], literal('was'))
40
+ rule([equals(:second), equals(:singular), equals(:past_simple) ], literal('were'))
41
+ rule([dont_care, equals(:plural), equals(:past_simple) ], literal('were'))
42
+ rule([dont_care, dont_care, equals(:past_participle)], literal('been'))
43
+ end
44
+ add_paradigm(table)
45
+ end
46
+
47
+ def add_paradigm(anInflectionTable)
48
+ @paradigms[anInflectionTable.name] = anInflectionTable
49
+ end
7
50
  end # class
51
+ =begin
52
+
53
+
54
+
55
+ private
56
+
57
+
58
+
59
+
60
+ =end
8
61
  end # module
9
62
  end # module
@@ -4,6 +4,46 @@ module Zenlish
4
4
  module WClasses
5
5
  # The `do` verb used as a lexical verb (as opposed auxiliary verb).
6
6
  class IrregularVerbDo < IrregularVerb
7
+ def initialize
8
+ super()
9
+ end
10
+
11
+ # The mix-in module used to extend the lexeme
12
+ # @return [Module, NilClass]
13
+ def extension
14
+ nil
15
+ end
16
+
17
+ private
18
+
19
+ def init_feature_defs
20
+ super
21
+ # Create standard feature definitions for irregular verbs.
22
+ feature_def_dsl {
23
+ feature_def 'PARADIGM' => [identifier, 'Verb_do_inflection'] # 2nd item is default value
24
+ }
25
+ end
26
+
27
+ def init_paradigms
28
+ builder = Inflect::InflectionTableBuilder.new
29
+ table = builder.build('Verb_do_inflection') do
30
+ feature_heading 'PERSON'
31
+ feature_heading 'NUMBER'
32
+ feature_heading 'TIME'
33
+ # PERSON NUMBER TIME
34
+ rule([not_equal(:third), equals(:singular), equals(:present) ], literal('do'))
35
+ rule([equals(:third), equals(:singular), equals(:present) ], literal('does'))
36
+ rule([dont_care, equals(:plural), equals(:present) ], literal('do'))
37
+ rule([dont_care, dont_care, equals(:progressive) ], literal('doing'))
38
+ rule([dont_care, dont_care, equals(:past_simple) ], literal('did'))
39
+ rule([dont_care, dont_care, equals(:past_participle)], literal('done'))
40
+ end
41
+ add_paradigm(table)
42
+ end
43
+
44
+ def add_paradigm(anInflectionTable)
45
+ @paradigms[anInflectionTable.name] = anInflectionTable
46
+ end
7
47
  end # class
8
48
  end # module
9
49
  end # module
@@ -4,6 +4,46 @@ module Zenlish
4
4
  module WClasses
5
5
  # The `have` verb used as a lexical verb (as opposed auxiliary verb).
6
6
  class IrregularVerbHave < IrregularVerb
7
+ def initialize
8
+ super()
9
+ end
10
+
11
+ # The mix-in module used to extend the lexeme
12
+ # @return [Module, NilClass]
13
+ def extension
14
+ nil
15
+ end
16
+
17
+ private
18
+
19
+ def init_feature_defs
20
+ super
21
+ # Create standard feature definitions for irregular verbs.
22
+ feature_def_dsl {
23
+ feature_def 'PARADIGM' => [identifier, 'Verb_have_inflection'] # 2nd item is default value
24
+ }
25
+ end
26
+
27
+ def init_paradigms
28
+ builder = Inflect::InflectionTableBuilder.new
29
+ table = builder.build('Verb_have_inflection') do
30
+ feature_heading 'PERSON'
31
+ feature_heading 'NUMBER'
32
+ feature_heading 'TIME'
33
+ # PERSON NUMBER TIME
34
+ rule([not_equal(:third), equals(:singular), equals(:present) ], literal('have'))
35
+ rule([equals(:third), equals(:singular), equals(:present) ], literal('has'))
36
+ rule([dont_care, equals(:plural), equals(:present) ], literal('have'))
37
+ rule([dont_care, dont_care, equals(:progressive) ], literal('having'))
38
+ rule([dont_care, dont_care, equals(:past_simple) ], literal('had'))
39
+ rule([dont_care, dont_care, equals(:past_participle)], literal('had'))
40
+ end
41
+ add_paradigm(table)
42
+ end
43
+
44
+ def add_paradigm(anInflectionTable)
45
+ @paradigms[anInflectionTable.name] = anInflectionTable
46
+ end
7
47
  end # class
8
48
  end # module
9
49
  end # module
@@ -27,16 +27,21 @@ module Zenlish
27
27
  expect(common_nouns.all? { |c_n| lemmas.include?(c_n) }).to be_truthy
28
28
  end
29
29
 
30
- let(:present_1sg) { [:first, :singular, :present, nil] }
31
- let(:present_3sg) { [:third, :singular, :present, nil] }
32
- let(:present_1pl) { [:first, :plural, :present, nil] }
33
- let(:progressive) { [nil, nil, :progressive, nil] }
34
- let(:past_simple) { [nil, nil, :past_simple, nil] }
35
- let(:past_participle) { [nil, nil, :past_participle, nil] }
30
+ let(:present_1sg) { [:first, :singular, :present, nil] }
31
+ let(:present_2sg) { [:second, :singular, :present, nil] }
32
+ let(:present_3sg) { [:third, :singular, :present, nil] }
33
+ let(:present_1pl) { [:first, :plural, :present, nil] }
34
+ let(:progressive) { [nil, nil, :progressive, nil] }
35
+ let(:past_simple) { [:first, :singular, :past_simple, nil] }
36
+ let(:past_simple_2sg) { [:second, :singular, :past_simple, nil] }
37
+ let(:past_simple_3sg) { [:third, :singular, :past_simple, nil] }
38
+ let(:past_simple_1pl) { [:first, :plural, :past_simple, nil] }
39
+ let(:past_participle) { [nil, nil, :past_participle, nil] }
36
40
 
37
- def test_inflection_of(verb_lexeme, pairs)
41
+ def test_inflection_of(verb_lexeme, pairs, drop_last_column = false)
38
42
  pairs.each do |(constraints, expected_form)|
39
- expect(verb_lexeme.inflect(constraints)).to eq(expected_form)
43
+ restriction = drop_last_column ? constraints.slice(0..-2) : constraints
44
+ expect(verb_lexeme.inflect(restriction)).to eq(expected_form)
40
45
  end
41
46
  end
42
47
 
@@ -61,8 +66,37 @@ module Zenlish
61
66
  [past_simple, 'did'],
62
67
  [past_participle, 'done']
63
68
  ]
64
- test_inflection_of(lexm, expectations_2)
69
+ test_inflection_of(lexm, expectations_2, true)
70
+
71
+ lexm = subject.get_lexeme('have', WClasses::IrregularVerbHave)
72
+ expectations_3 = [
73
+ [present_1sg, 'have'],
74
+ [present_3sg, 'has'],
75
+ [present_1pl, 'have'],
76
+ [progressive, 'having'],
77
+ [past_simple, 'had'],
78
+ [past_participle, 'had']
79
+ ]
80
+ test_inflection_of(lexm, expectations_3, true)
81
+ end
82
+
83
+ it 'should know how to inflect the verb be' do
84
+ lexm = subject.get_lexeme('be', WClasses::IrregularVerbBe)
85
+ expectations_1 = [
86
+ [present_1sg, 'am'],
87
+ [present_2sg, 'are'],
88
+ [present_3sg, 'is'],
89
+ [present_1pl, 'are'],
90
+ [progressive, 'being'],
91
+ [past_simple, 'was'],
92
+ [past_simple_2sg, 'were'],
93
+ [past_simple_3sg, 'was'],
94
+ [past_simple_1pl, 'were'],
95
+ [past_participle, 'been']
96
+ ]
97
+ test_inflection_of(lexm, expectations_1, true)
65
98
  end
99
+
66
100
  end # context
67
101
  end # describe
68
102
  end # module
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenlish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.02
4
+ version: 0.2.03
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-06 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley