zenlish 0.2.05 → 0.2.07

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.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +228 -0
  3. data/CHANGELOG.md +19 -0
  4. data/Gemfile +5 -3
  5. data/LICENSE.txt +1 -1
  6. data/Rakefile +5 -3
  7. data/lib/zenlish/feature/boolean_domain.rb +6 -4
  8. data/lib/zenlish/feature/boolean_value.rb +3 -2
  9. data/lib/zenlish/feature/enumeration_domain.rb +5 -2
  10. data/lib/zenlish/feature/feature.rb +9 -7
  11. data/lib/zenlish/feature/feature_def.rb +9 -6
  12. data/lib/zenlish/feature/feature_domain.rb +4 -2
  13. data/lib/zenlish/feature/feature_struct.rb +3 -1
  14. data/lib/zenlish/feature/feature_struct_def.rb +5 -3
  15. data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
  16. data/lib/zenlish/feature/feature_value.rb +4 -2
  17. data/lib/zenlish/feature/identifier_domain.rb +5 -3
  18. data/lib/zenlish/feature/identifier_value.rb +3 -2
  19. data/lib/zenlish/feature/symbol_value.rb +3 -1
  20. data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
  21. data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
  22. data/lib/zenlish/inflect/concatenation.rb +3 -2
  23. data/lib/zenlish/inflect/equals_literal.rb +3 -1
  24. data/lib/zenlish/inflect/feature_heading.rb +2 -5
  25. data/lib/zenlish/inflect/formal_argument.rb +3 -1
  26. data/lib/zenlish/inflect/function_call.rb +4 -1
  27. data/lib/zenlish/inflect/heading.rb +2 -0
  28. data/lib/zenlish/inflect/inflection_rule.rb +2 -0
  29. data/lib/zenlish/inflect/inflection_table.rb +6 -4
  30. data/lib/zenlish/inflect/inflection_table_builder.rb +21 -18
  31. data/lib/zenlish/inflect/input_asis.rb +3 -0
  32. data/lib/zenlish/inflect/input_expression.rb +4 -2
  33. data/lib/zenlish/inflect/literal_asis.rb +4 -1
  34. data/lib/zenlish/inflect/matches_pattern.rb +2 -0
  35. data/lib/zenlish/inflect/membership.rb +2 -0
  36. data/lib/zenlish/inflect/method_heading.rb +3 -6
  37. data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
  38. data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
  39. data/lib/zenlish/inflect/output_expression.rb +6 -0
  40. data/lib/zenlish/inflect/substitution.rb +3 -1
  41. data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
  42. data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
  43. data/lib/zenlish/lang/dictionary.rb +19 -16
  44. data/lib/zenlish/lang/lemmatizer.rb +40 -0
  45. data/lib/zenlish/lang/zenlish_grammar.rb +6 -4
  46. data/lib/zenlish/lex/empty_lexicon_factory.rb +3 -2
  47. data/lib/zenlish/lex/lexeme.rb +6 -4
  48. data/lib/zenlish/lex/lexical_entry.rb +6 -4
  49. data/lib/zenlish/lex/lexicon.rb +4 -3
  50. data/lib/zenlish/lex/literal.rb +3 -1
  51. data/lib/zenlish/lexer/lexer.rb +144 -0
  52. data/lib/zenlish/trie/base_trie_node.rb +27 -0
  53. data/lib/zenlish/trie/trie.rb +132 -0
  54. data/lib/zenlish/trie/trie_node.rb +21 -0
  55. data/lib/zenlish/trie/trie_root.rb +10 -0
  56. data/lib/zenlish/version.rb +3 -1
  57. data/lib/zenlish/wclasses/adjective.rb +4 -2
  58. data/lib/zenlish/wclasses/adverb.rb +3 -1
  59. data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
  60. data/lib/zenlish/wclasses/adverb_not.rb +2 -0
  61. data/lib/zenlish/wclasses/all_word_classes.rb +3 -1
  62. data/lib/zenlish/wclasses/article.rb +2 -0
  63. data/lib/zenlish/wclasses/auxiliary.rb +2 -0
  64. data/lib/zenlish/wclasses/auxiliary_be.rb +7 -6
  65. data/lib/zenlish/wclasses/auxiliary_do.rb +6 -5
  66. data/lib/zenlish/wclasses/cardinal.rb +3 -1
  67. data/lib/zenlish/wclasses/common_noun.rb +2 -0
  68. data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
  69. data/lib/zenlish/wclasses/conjunction.rb +2 -0
  70. data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
  71. data/lib/zenlish/wclasses/coordinator.rb +4 -2
  72. data/lib/zenlish/wclasses/definite_article.rb +2 -0
  73. data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
  74. data/lib/zenlish/wclasses/demonstrative_determiner.rb +6 -4
  75. data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
  76. data/lib/zenlish/wclasses/determiner.rb +3 -1
  77. data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
  78. data/lib/zenlish/wclasses/existential_there.rb +2 -0
  79. data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
  80. data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
  81. data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
  82. data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
  83. data/lib/zenlish/wclasses/irregular_verb.rb +13 -15
  84. data/lib/zenlish/wclasses/irregular_verb_be.rb +8 -7
  85. data/lib/zenlish/wclasses/irregular_verb_can.rb +8 -7
  86. data/lib/zenlish/wclasses/irregular_verb_do.rb +7 -6
  87. data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -7
  88. data/lib/zenlish/wclasses/irregular_verb_have.rb +12 -11
  89. data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
  90. data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
  91. data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
  92. data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
  93. data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
  94. data/lib/zenlish/wclasses/modal_verb_can.rb +7 -5
  95. data/lib/zenlish/wclasses/noun.rb +4 -2
  96. data/lib/zenlish/wclasses/numeral.rb +2 -0
  97. data/lib/zenlish/wclasses/personal_pronoun.rb +8 -6
  98. data/lib/zenlish/wclasses/possessive_determiner.rb +13 -12
  99. data/lib/zenlish/wclasses/preposition.rb +3 -1
  100. data/lib/zenlish/wclasses/preposition_of.rb +2 -0
  101. data/lib/zenlish/wclasses/preposition_than.rb +2 -0
  102. data/lib/zenlish/wclasses/pronoun.rb +3 -1
  103. data/lib/zenlish/wclasses/proper_noun.rb +10 -8
  104. data/lib/zenlish/wclasses/quantifier.rb +3 -1
  105. data/lib/zenlish/wclasses/regular_verb.rb +9 -9
  106. data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
  107. data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
  108. data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
  109. data/lib/zenlish/wclasses/verb.rb +5 -3
  110. data/lib/zenlish/wclasses/word_class.rb +7 -5
  111. data/lib/zenlish.rb +3 -3
  112. data/spec/spec_helper.rb +3 -1
  113. data/spec/zenlish/feature/boolean_domain_spec.rb +16 -16
  114. data/spec/zenlish/feature/boolean_value_spec.rb +7 -6
  115. data/spec/zenlish/feature/enumeration_domain_spec.rb +21 -21
  116. data/spec/zenlish/feature/feature_def_spec.rb +15 -14
  117. data/spec/zenlish/feature/feature_spec.rb +17 -17
  118. data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +23 -21
  119. data/spec/zenlish/feature/feature_struct_def_spec.rb +26 -25
  120. data/spec/zenlish/feature/identifier_domain_spec.rb +15 -15
  121. data/spec/zenlish/feature/identifier_value_spec.rb +10 -9
  122. data/spec/zenlish/feature/symbol_value_spec.rb +9 -8
  123. data/spec/zenlish/inflect/concatenation_spec.rb +14 -14
  124. data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
  125. data/spec/zenlish/inflect/feature_heading_spec.rb +22 -21
  126. data/spec/zenlish/inflect/formal_argument_spec.rb +7 -7
  127. data/spec/zenlish/inflect/function_call_spec.rb +11 -12
  128. data/spec/zenlish/inflect/inflection_rule_spec.rb +28 -24
  129. data/spec/zenlish/inflect/inflection_table_builder_spec.rb +62 -57
  130. data/spec/zenlish/inflect/inflection_table_spec.rb +49 -46
  131. data/spec/zenlish/inflect/input_asis_spec.rb +12 -15
  132. data/spec/zenlish/inflect/literal_asis_spec.rb +10 -10
  133. data/spec/zenlish/inflect/matches_pattern_spec.rb +16 -15
  134. data/spec/zenlish/inflect/membership_spec.rb +17 -16
  135. data/spec/zenlish/inflect/method_heading_spec.rb +15 -14
  136. data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
  137. data/spec/zenlish/inflect/substitution_spec.rb +10 -11
  138. data/spec/zenlish/inflect/unconditionally_true_spec.rb +8 -6
  139. data/spec/zenlish/lang/dictionary_spec.rb +28 -31
  140. data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
  141. data/spec/zenlish/lang/zenlish_grammar_spec.rb +5 -5
  142. data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
  143. data/spec/zenlish/lex/lexeme_spec.rb +27 -28
  144. data/spec/zenlish/lex/lexical_entry_spec.rb +15 -15
  145. data/spec/zenlish/lex/lexicon_spec.rb +52 -50
  146. data/spec/zenlish/lex/literal_spec.rb +8 -8
  147. data/spec/zenlish/lexer/lexer_spec.rb +52 -0
  148. data/spec/zenlish/parser/lesson1_spec.rb +81 -81
  149. data/spec/zenlish/parser/lesson2_spec.rb +133 -138
  150. data/spec/zenlish/parser/lesson3_spec.rb +186 -226
  151. data/spec/zenlish/parser/zparser_spec.rb +8 -7
  152. data/spec/zenlish/support/minimal_lexicon.rb +2 -0
  153. data/spec/zenlish/support/var2word.rb +16 -9
  154. data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
  155. data/spec/zenlish/trie/trie_spec.rb +108 -0
  156. data/spec/zenlish/wclasses/common_noun_spec.rb +15 -19
  157. data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +12 -12
  158. data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +18 -18
  159. data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
  160. data/spec/zenlish/wclasses/irregular_verb_spec.rb +28 -28
  161. data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -9
  162. data/spec/zenlish/wclasses/modal_verb_can_spec.rb +12 -12
  163. data/spec/zenlish/wclasses/noun_spec.rb +7 -7
  164. data/spec/zenlish/wclasses/personal_pronoun_spec.rb +20 -23
  165. data/spec/zenlish/wclasses/possessive_determiner_spec.rb +28 -31
  166. data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
  167. data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
  168. data/spec/zenlish/wclasses/regular_verb_spec.rb +30 -30
  169. data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
  170. data/spec/zenlish/wclasses/verb_spec.rb +9 -9
  171. data/spec/zenlish_spec.rb +4 -2
  172. data/zenlish.gemspec +18 -14
  173. metadata +49 -16
@@ -10,24 +10,24 @@ require_relative '../../../lib/zenlish/wclasses/modal_verb_can'
10
10
  module Zenlish
11
11
  module WClasses
12
12
  describe ModalVerbCan do
13
- subject { ModalVerbCan.new }
13
+ subject(:modal_can) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { ModalVerbCan.new }.not_to raise_error
16
+ it 'is initialized without argument' do
17
+ expect { described_class.new }.not_to raise_error
18
18
  end
19
19
  end # context
20
20
 
21
21
  context 'Provided services:' do
22
- it 'should know its inherited feature definitions' do
23
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
24
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
25
- expect(subject['PARADIGM'].default.val).to eq('Verb_can_inflection')
22
+ it 'knows its inherited feature definitions' do
23
+ expect(modal_can['NUMBER']).to be_a(Feature::FeatureDef)
24
+ expect(modal_can['PERSON']).to be_a(Feature::FeatureDef)
25
+ expect(modal_can['PARADIGM'].default.val).to eq('Verb_can_inflection')
26
26
  end
27
27
 
28
28
  def build_verb(aBaseForm)
29
29
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
30
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
30
+ Zenlish::Lex::Lexeme.new(modal_can, entry)
31
31
  end
32
32
 
33
33
  def test_inflection_of(verb_form, pairs)
@@ -37,14 +37,14 @@ module Zenlish
37
37
  end
38
38
  end
39
39
 
40
- it 'should know how to inflect modal verb can' do
41
- expectations_1 = [
40
+ it 'knows how to inflect modal verb can' do
41
+ expectations1 = [
42
42
  [:present, 'can'],
43
43
  [:past_simple, 'could']
44
44
  ]
45
- test_inflection_of('can', expectations_1)
45
+ test_inflection_of('can', expectations1)
46
46
  end
47
47
  end # context
48
48
  end # describe
49
49
  end # module
50
- end # module
50
+ end # module
@@ -6,23 +6,23 @@ require_relative '../../../lib/zenlish/wclasses/noun' # Load the class under tes
6
6
  module Zenlish
7
7
  module WClasses
8
8
  describe Noun do
9
- subject { Noun.new }
9
+ subject(:noun) { described_class.new }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized without argument' do
13
- expect { Noun.new }.not_to raise_error
12
+ it 'is initialized without argument' do
13
+ expect { described_class.new }.not_to raise_error
14
14
  end
15
15
  end # context
16
16
 
17
17
  context 'Provided services:' do
18
- it 'should know that it is variable (has inflected forms)' do
19
- expect(subject).not_to be_invariable
18
+ it 'knows that it is variable (has inflected forms)' do
19
+ expect(noun).not_to be_invariable
20
20
  end
21
21
 
22
- it 'should know its feature names' do
22
+ it 'knows its feature names' do
23
23
  expectations = %w(NUMBER COUNTABILITY)
24
24
  expectations.each do |name|
25
- expect(subject[name]).not_to be_nil
25
+ expect(noun[name]).not_to be_nil
26
26
  end
27
27
  end
28
28
  end # context
@@ -10,22 +10,22 @@ module Zenlish
10
10
  module WClasses
11
11
  describe PersonalPronoun do
12
12
  include Feature::FeatureStructDefBearer
13
- subject { PersonalPronoun.new }
13
+ subject(:pronoun) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { PersonalPronoun.new }.not_to raise_error
16
+ it 'is initialized without argument' do
17
+ expect { described_class.new }.not_to raise_error
18
18
  end
19
19
 
20
- it 'should know that it is inflectable' do
21
- expect(subject).not_to be_invariable
20
+ it 'knows that it is inflectable' do
21
+ expect(pronoun).not_to be_invariable
22
22
  end
23
23
  end # context
24
24
 
25
25
  context 'Provided services:' do
26
26
  def build_ppn(aBaseForm, aFeatureHash)
27
27
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
28
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry, aFeatureHash)
28
+ Zenlish::Lex::Lexeme.new(pronoun, entry, aFeatureHash)
29
29
  end
30
30
 
31
31
  def test_all_inflections(det_form, aFeatureHash, wforms)
@@ -34,34 +34,31 @@ module Zenlish
34
34
  expect(inflected.sort).to eq(wforms.sort)
35
35
  end
36
36
 
37
- it 'should know its feature definitions' do
38
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
39
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
40
- expect(subject['GENDER']).to be_kind_of(Feature::FeatureDef)
41
- expect(subject['CASE']).to be_kind_of(Feature::FeatureDef)
42
- expect(subject['PARADIGM'].default.val).to eq('ppn_1st_paradigm')
37
+ it 'knows its feature definitions' do
38
+ expect(pronoun['NUMBER']).to be_a(Feature::FeatureDef)
39
+ expect(pronoun['PERSON']).to be_a(Feature::FeatureDef)
40
+ expect(pronoun['GENDER']).to be_a(Feature::FeatureDef)
41
+ expect(pronoun['CASE']).to be_a(Feature::FeatureDef)
42
+ expect(pronoun['PARADIGM'].default.val).to eq('ppn_1st_paradigm')
43
43
  end
44
44
 
45
- it 'should give all word forms for the first person' do
45
+ it 'gives all word forms for the first person' do
46
46
  feature_defs = { 'PERSON' => enumeration(:first),
47
- 'GENDER' => enumeration(:feminine, :masculine)
48
- }
49
- test_all_inflections('I', feature_defs, ['I', 'we', 'me', 'us'])
47
+ 'GENDER' => enumeration(:feminine, :masculine) }
48
+ test_all_inflections('I', feature_defs, %w[I we me us])
50
49
  end
51
50
 
52
- it 'should give all word forms for the second person' do
51
+ it 'gives all word forms for the second person' do
53
52
  feature_defs = { 'PERSON' => enumeration(:second),
54
53
  'GENDER' => enumeration(:feminine, :masculine),
55
- 'PARADIGM' => [identifier, 'ppn_2nd_paradigm']
56
- }
54
+ 'PARADIGM' => [identifier, 'ppn_2nd_paradigm'] }
57
55
  test_all_inflections('you', feature_defs, ['you'])
58
56
  end
59
57
 
60
- it 'should give all word forms for the third person' do
58
+ it 'gives all word forms for the third person' do
61
59
  feature_defs = { 'PERSON' => enumeration(:third),
62
- 'PARADIGM' => [identifier, 'ppn_3rd_paradigm']
63
- }
64
- test_all_inflections('it', feature_defs, ['she', 'he', 'it', 'they', 'her', 'him', 'them'])
60
+ 'PARADIGM' => [identifier, 'ppn_3rd_paradigm'] }
61
+ test_all_inflections('it', feature_defs, %w[she he it they her him them])
65
62
  end
66
63
  end # context
67
64
  end # describe
@@ -10,60 +10,57 @@ module Zenlish
10
10
  module WClasses
11
11
  describe PossessiveDeterminer do
12
12
  include Feature::FeatureStructDefBearer
13
- subject { PossessiveDeterminer.new }
13
+ subject(:determiner) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { PossessiveDeterminer.new }.not_to raise_error
16
+ it 'is initialized without argument' do
17
+ expect { described_class.new }.not_to raise_error
18
18
  end
19
19
  end # context
20
20
 
21
- context 'Provided services:' do
21
+ context 'Provided services:' do
22
22
  def build_det(aBaseForm, aFeatureHash)
23
23
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
24
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry, aFeatureHash)
24
+ Zenlish::Lex::Lexeme.new(determiner, entry, aFeatureHash)
25
25
  end
26
26
 
27
27
  def test_all_inflections(det_form, aFeatureHash, wforms)
28
28
  pronoun = build_det(det_form, aFeatureHash)
29
29
  inflected = pronoun.all_inflections
30
30
  expect(inflected.sort).to eq(wforms.sort)
31
- end
31
+ end
32
32
 
33
- it 'should know that it is inflectable' do
34
- expect(subject).not_to be_invariable
33
+ it 'knows that it is inflectable' do
34
+ expect(determiner).not_to be_invariable
35
35
  end
36
36
 
37
- it 'should know its feature definitions' do
38
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
39
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
40
- expect(subject['GENDER']).to be_kind_of(Feature::FeatureDef)
41
- expect(subject['PARADIGM'].default.val).to eq('possdet_1st_paradigm')
37
+ it 'knows its feature definitions' do
38
+ expect(determiner['NUMBER']).to be_a(Feature::FeatureDef)
39
+ expect(determiner['PERSON']).to be_a(Feature::FeatureDef)
40
+ expect(determiner['GENDER']).to be_a(Feature::FeatureDef)
41
+ expect(determiner['PARADIGM'].default.val).to eq('possdet_1st_paradigm')
42
42
  end
43
-
44
- it 'should give all word forms for the first person' do
45
- feature_defs = { 'PERSON' => enumeration(:first),
46
- 'GENDER' => enumeration(:feminine, :masculine)
47
- }
48
- test_all_inflections('my', feature_defs, ['my', 'our'])
43
+
44
+ it 'gives all word forms for the first person' do
45
+ feature_defs = { 'PERSON' => enumeration(:first),
46
+ 'GENDER' => enumeration(:feminine, :masculine) }
47
+ test_all_inflections('my', feature_defs, %w[my our])
49
48
  end
50
-
51
- it 'should give all word forms for the second person' do
52
- feature_defs = { 'PERSON' => enumeration(:second),
49
+
50
+ it 'gives all word forms for the second person' do
51
+ feature_defs = { 'PERSON' => enumeration(:second),
53
52
  'GENDER' => enumeration(:feminine, :masculine),
54
- 'PARADIGM' => [identifier, 'possdet_2nd_paradigm']
55
- }
53
+ 'PARADIGM' => [identifier, 'possdet_2nd_paradigm'] }
56
54
  test_all_inflections('your', feature_defs, ['your'])
57
55
  end
58
56
 
59
- it 'should give all word forms for the third person' do
60
- feature_defs = { 'PERSON' => enumeration(:third),
61
- 'PARADIGM' => [identifier, 'possdet_3rd_paradigm']
62
- }
63
- test_all_inflections('its', feature_defs, ['its', 'her', 'his', 'their'])
64
- end
57
+ it 'gives all word forms for the third person' do
58
+ feature_defs = { 'PERSON' => enumeration(:third),
59
+ 'PARADIGM' => [identifier, 'possdet_3rd_paradigm'] }
60
+ test_all_inflections('its', feature_defs, %w[its her his their])
61
+ end
65
62
 
66
- # it 'should give all word forms' do
63
+ # it 'gives all word forms' do
67
64
  # test_all_inflections('this', ['this', 'that', 'these', 'those'])
68
65
  # end
69
66
  end # context
@@ -6,17 +6,17 @@ require_relative '../../../lib/zenlish/wclasses/preposition' # Load the class un
6
6
  module Zenlish
7
7
  module WClasses
8
8
  describe Preposition do
9
- subject { Preposition.new }
9
+ subject(:preposition) { described_class.new }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized without argument' do
13
- expect { Preposition.new }.not_to raise_error
12
+ it 'is initialized without argument' do
13
+ expect { described_class.new }.not_to raise_error
14
14
  end
15
15
  end # context
16
16
 
17
17
  context 'Provided services:' do
18
- it 'should know that it is invariable' do
19
- expect(subject).to be_invariable
18
+ it 'is invariable' do
19
+ expect(preposition).to be_invariable
20
20
  end
21
21
  end # context
22
22
  end # describe
@@ -6,11 +6,11 @@ require_relative '../../../lib/zenlish/wclasses/proper_noun' # Load the class un
6
6
  module Zenlish
7
7
  module WClasses
8
8
  describe ProperNoun do
9
- subject { ProperNoun.new }
9
+ subject { described_class.new }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized without argument' do
13
- expect { ProperNoun.new }.not_to raise_error
12
+ it 'is initialized without argument' do
13
+ expect { described_class.new }.not_to raise_error
14
14
  end
15
15
  end # context
16
16
 
@@ -10,31 +10,25 @@ require_relative '../../../lib/zenlish/wclasses/regular_verb'
10
10
  module Zenlish
11
11
  module WClasses
12
12
  describe RegularVerb do
13
- subject { RegularVerb.new }
13
+ subject(:regular_verb) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { RegularVerb.new }.not_to raise_error
16
+ it 'is initialized without argument' do
17
+ expect { described_class.new }.not_to raise_error
18
18
  end
19
19
  end # context
20
20
 
21
21
  context 'Provided services:' do
22
- it 'should know its inherited feature definitions' do
23
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
24
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
25
- expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
26
- end
27
-
28
22
  let(:present_1sg) { [:first, :singular, :present, nil] }
29
23
  let(:present_3sg) { [:third, :singular, :present, nil] }
30
24
  let(:present_1pl) { [:first, :plural, :present, nil] }
31
25
  let(:progressive) { [nil, nil, :progressive, nil] }
32
26
  let(:past_simple) { [nil, nil, :past_simple, nil] }
33
- let(:past_participle) { [nil, nil, :past_participle, nil] }
34
-
27
+ let(:past_participle) { [nil, nil, :past_participle, nil] }
28
+
35
29
  def build_verb(aBaseForm)
36
30
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
37
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
31
+ Zenlish::Lex::Lexeme.new(regular_verb, entry)
38
32
  end
39
33
 
40
34
  def test_inflection_of(verb_form, pairs)
@@ -43,15 +37,21 @@ module Zenlish
43
37
  expect(verb.inflect(constraints)).to eq(expected_form)
44
38
  end
45
39
  end
46
-
40
+
47
41
  def test_all_inflections(verb_form, wforms)
48
42
  verb = build_verb(verb_form)
49
43
  inflected = verb.all_inflections
50
44
  expect(inflected.sort).to eq(wforms.sort)
51
45
  end
52
46
 
53
- it 'should know how to inflect regular verbs' do
54
- expectations_1 = [
47
+ it 'knows its inherited feature definitions' do
48
+ expect(regular_verb['NUMBER']).to be_a(Feature::FeatureDef)
49
+ expect(regular_verb['PERSON']).to be_a(Feature::FeatureDef)
50
+ expect(regular_verb['PARADIGM'].default.val).to eq('Regular_inflection')
51
+ end
52
+
53
+ it 'knows how to inflect regular verbs' do
54
+ expectations1 = [
55
55
  [present_1sg, 'exist'],
56
56
  [present_3sg, 'exists'],
57
57
  [present_1pl, 'exist'],
@@ -59,9 +59,9 @@ module Zenlish
59
59
  [past_simple, 'existed'],
60
60
  [past_participle, 'existed']
61
61
  ]
62
- test_inflection_of('exist', expectations_1)
62
+ test_inflection_of('exist', expectations1)
63
63
 
64
- expectations_2 = [
64
+ expectations2 = [
65
65
  [present_1sg, 'move'],
66
66
  [present_3sg, 'moves'],
67
67
  [present_1pl, 'move'],
@@ -69,9 +69,9 @@ module Zenlish
69
69
  [past_simple, 'moved'],
70
70
  [past_participle, 'moved']
71
71
  ]
72
- test_inflection_of('move', expectations_2)
72
+ test_inflection_of('move', expectations2)
73
73
 
74
- expectations_3 = [
74
+ expectations3 = [
75
75
  [present_1sg, 'try'],
76
76
  [present_3sg, 'tries'],
77
77
  [present_1pl, 'try'],
@@ -79,9 +79,9 @@ module Zenlish
79
79
  [past_simple, 'tried'],
80
80
  [past_participle, 'tried']
81
81
  ]
82
- test_inflection_of('try', expectations_3)
82
+ test_inflection_of('try', expectations3)
83
83
 
84
- expectations_4 = [
84
+ expectations4 = [
85
85
  [present_1sg, 'touch'],
86
86
  [present_3sg, 'touches'],
87
87
  [present_1pl, 'touch'],
@@ -89,9 +89,9 @@ module Zenlish
89
89
  [past_simple, 'touched'],
90
90
  [past_participle, 'touched']
91
91
  ]
92
- test_inflection_of('touch', expectations_4)
92
+ test_inflection_of('touch', expectations4)
93
93
 
94
- expectations_5 = [
94
+ expectations5 = [
95
95
  [present_1sg, 'die'],
96
96
  [present_3sg, 'dies'],
97
97
  [present_1pl, 'die'],
@@ -99,9 +99,9 @@ module Zenlish
99
99
  [past_simple, 'died'],
100
100
  [past_participle, 'died']
101
101
  ]
102
- test_inflection_of('die', expectations_5)
102
+ test_inflection_of('die', expectations5)
103
103
 
104
- expectations_6 = [
104
+ expectations6 = [
105
105
  [present_1sg, 'want'],
106
106
  [present_3sg, 'wants'],
107
107
  [present_1pl, 'want'],
@@ -109,13 +109,13 @@ module Zenlish
109
109
  [past_simple, 'wanted'],
110
110
  [past_participle, 'wanted']
111
111
  ]
112
- test_inflection_of('want', expectations_6)
112
+ test_inflection_of('want', expectations6)
113
113
  end
114
-
115
- it 'should give all word forms of a given verb' do
116
- test_all_inflections('die', ['die', 'dies', 'dying', 'died'])
114
+
115
+ it 'gives all word forms of a given verb' do
116
+ test_all_inflections('die', %w[die dies dying died])
117
117
  end
118
118
  end # context
119
119
  end # describe
120
120
  end # module
121
- end # module
121
+ end # module
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../spec_helper' # Use the RSpec framework
4
+ require_relative '../../../lib/zenlish/lex/lexical_entry'
5
+ require_relative '../../../lib/zenlish/lex/lexeme'
6
+
7
+ # Load the class under test
8
+ require_relative '../../../lib/zenlish/wclasses/regular_verb_want'
9
+
10
+ module Zenlish
11
+ module WClasses
12
+ describe RegularVerbWant do
13
+ subject(:the_verb) { described_class.new }
14
+
15
+ context 'Initialization:' do
16
+ it 'is initialized without argument' do
17
+ expect { described_class.new }.not_to raise_error
18
+ end
19
+ end # context
20
+
21
+ context 'Provided services:' do
22
+ it 'knows its inherited feature definitions' do
23
+ expect(the_verb['NUMBER']).to be_a(Feature::FeatureDef)
24
+ expect(the_verb['PERSON']).to be_a(Feature::FeatureDef)
25
+ expect(the_verb['PARADIGM'].default.val).to eq('Regular_inflection')
26
+ end
27
+ end # context
28
+ end # describe
29
+ end # module
30
+ end # module
@@ -13,23 +13,23 @@ module Zenlish
13
13
  end
14
14
 
15
15
  describe Verb do
16
- subject { Verb.new }
16
+ subject(:a_verb) { described_class.new }
17
17
 
18
18
  context 'Initialization:' do
19
- it 'should be initialized without argument' do
20
- expect { Verb.new }.not_to raise_error
19
+ it 'is initialized without argument' do
20
+ expect { described_class.new }.not_to raise_error
21
21
  end
22
22
  end # context
23
23
 
24
24
  context 'Provided services:' do
25
- it 'should know that it has inflected forms' do
26
- expect(subject).not_to be_invariable
25
+ it 'knows that it has inflected forms' do
26
+ expect(a_verb).not_to be_invariable
27
27
  end
28
28
 
29
- it 'should know its feature definitions' do
30
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
31
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
32
- expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
29
+ it 'knows its feature definitions' do
30
+ expect(a_verb['NUMBER']).to be_a(Feature::FeatureDef)
31
+ expect(a_verb['PERSON']).to be_a(Feature::FeatureDef)
32
+ expect(a_verb['PARADIGM'].default.val).to eq('Regular_inflection')
33
33
  end
34
34
  end # context
35
35
  end # describe
data/spec/zenlish_spec.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Zenlish do
2
- it "has a version number" do
3
- expect(Zenlish::VERSION).not_to be nil
4
+ it 'has a version number' do
5
+ expect(Zenlish::VERSION).not_to be_nil
4
6
  end
5
7
  end
data/zenlish.gemspec CHANGED
@@ -1,6 +1,8 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "zenlish/version"
5
+ require 'zenlish/version'
4
6
 
5
7
  # Implementation module
6
8
  module PkgExtending
@@ -14,7 +16,7 @@ module PkgExtending
14
16
  'Gemfile',
15
17
  'Rakefile',
16
18
  'CHANGELOG.md',
17
- 'CODE_OF_CONDUCT.md',
19
+ 'CODE_OF_CONDUCT.md',
18
20
  'LICENSE.txt',
19
21
  'README.md',
20
22
  'zenlish.gemspec',
@@ -34,29 +36,31 @@ module PkgExtending
34
36
  end
35
37
  end # module
36
38
 
37
-
38
39
  Gem::Specification.new do |spec|
39
40
  spec.name = 'zenlish'
40
41
  spec.version = Zenlish::VERSION
41
42
  spec.authors = ['Dimitri Geshef']
42
43
  spec.email = ['famished.tiger@yahoo.com']
43
44
 
44
- spec.summary = %q{A toolkit for the Zenlish language (a simplified English language).}
45
- spec.description = %q{A toolkit for the Zenlish language (a simplified English language).}
46
- spec.homepage = "https://github.com/famished-tiger/zenlish"
45
+ spec.summary = 'A toolkit for the Zenlish language (a simplified English language).'
46
+ spec.description = 'A toolkit for the Zenlish language (a simplified English language).'
47
+ spec.homepage = 'https://github.com/famished-tiger/zenlish'
47
48
  spec.license = 'MIT'
48
49
 
49
50
  spec.bindir = 'exe'
50
51
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
51
- spec.require_paths = ["lib"]
52
-
52
+ spec.require_paths = ['lib']
53
+
53
54
  PkgExtending.pkg_files(spec)
54
55
  PkgExtending.pkg_documentation(spec)
55
-
56
+
57
+ spec.required_ruby_version = '>= 3.1.0'
58
+ spec.metadata = { 'rubygems_mfa_required' => 'true' }
59
+
56
60
  # Runtime dependencies
57
- spec.add_dependency 'rley', '~> 0.7.06'
61
+ spec.add_dependency 'rley', '~> 0.9', '>= 0.9.02'
58
62
 
59
- spec.add_development_dependency "bundler", "~> 2.0"
60
- spec.add_development_dependency "rake", "~> 12.0"
61
- spec.add_development_dependency "rspec", "~> 3.0"
63
+ spec.add_development_dependency 'bundler', '~> 2.4', '>= 2.4.1'
64
+ spec.add_development_dependency 'rake', '~> 13'
65
+ spec.add_development_dependency 'rspec', '~> 3', '>= 3.10.0'
62
66
  end