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
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '../../spec_helper' # Use the RSpec framework
3
4
  require_relative '../support/var2word'
4
5
  require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test
@@ -7,12 +8,12 @@ module Zenlish
7
8
  module Parser
8
9
  describe ZParser do
9
10
  include Var2Word
10
-
11
- subject { ZParser.new }
11
+
12
+ subject(:parser) { described_class.new }
12
13
 
13
14
  context 'Initialization:' do
14
- it 'should be initialized without argument' do
15
- expect { ZParser.new }.not_to raise_error
15
+ it 'is initialized without argument' do
16
+ expect { described_class.new }.not_to raise_error
16
17
  end
17
18
  end # context
18
19
 
@@ -21,14 +22,14 @@ module Zenlish
21
22
  # # OK, non-ambiguous sentence: "Lisa sees Tony."
22
23
  # literals = [lisa, sees, tony, dot]
23
24
  # result_type = Rley::PTree::ParseTree
24
- # expect(subject.to_pforest(literals)).to be_kind_of(result_type)
25
+ # expect(parser.to_pforest(literals)).to be_a(result_type)
25
26
  # end
26
27
 
27
- it 'should produce forest' do
28
+ it 'produces forest' do
28
29
  # Sentence: "Lisa sees Tony."
29
30
  literals = [lisa, sees, tony, dot]
30
31
  result_type = Rley::SPPF::ParseForest
31
- expect(subject.to_pforest(literals)).to be_kind_of(result_type)
32
+ expect(parser.to_pforest(literals)).to be_a(result_type)
32
33
  end
33
34
  end # context
34
35
  end # describe
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../../lib/zenlish/lang/dictionary'
2
4
 
3
5
  # Add a few words to dictionary for testing purposes...
@@ -1,7 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'minimal_lexicon'
2
4
  require_relative '../../../lib/zenlish/lex/literal'
3
5
 
4
6
  module Zenlish
7
+ # rubocop: disable Layout/SpaceBeforeSemicolon
8
+ # rubocop: disable Style/SingleLineMethods
9
+
5
10
  # Utility module. It defines variables that each are assgned a
6
11
  # Literal object.
7
12
  module Var2Word
@@ -106,8 +111,8 @@ module Zenlish
106
111
  literal2var('hear', 'hear')
107
112
  literal2var('hear', 'heard')
108
113
  literal2var('hear', 'hears')
109
- def here ; Lex::Literal.new('here', get_lexeme('here', WClasses::Adverb), 0) ; end
110
- def here_as_noun ; Lex::Literal.new('here', get_lexeme('here', WClasses::CommonNoun), 0) ; end
114
+ def here ; Lex::Literal.new('here', get_lexeme('here', WClasses::Adverb), 0) ; end
115
+ def here_as_noun ; Lex::Literal.new('here', get_lexeme('here', WClasses::CommonNoun), 0) ; end
111
116
  def i_pronoun ; Lex::Literal.new('I', get_lexeme('I'), 0) ; end
112
117
  literal2var('if', 'if', '_')
113
118
  literal2var('in', 'in', '_')
@@ -115,7 +120,7 @@ module Zenlish
115
120
  literal2var('it', 'it', '_')
116
121
  literal2var('its', 'its')
117
122
  literal2var('J', 'j', '_')
118
- def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
123
+ def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
119
124
  def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end
120
125
  literal2var('K', 'k', '_')
121
126
  literal2var('kind', 'kind')
@@ -216,7 +221,7 @@ module Zenlish
216
221
  literal2var('want', 'want')
217
222
  literal2var('want', 'wants')
218
223
  def was ; Lex::Literal.new('was', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
219
- def were ; Lex::Literal.new('were', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
224
+ def were ; Lex::Literal.new('were', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
220
225
  literal2var('what', 'what')
221
226
  literal2var('when', 'when', '_')
222
227
  def where ; Lex::Literal.new('where', get_lexeme('where', WClasses::Adverb), 0) ; end
@@ -228,9 +233,11 @@ module Zenlish
228
233
  literal2var('you', 'you')
229
234
  literal2var('you', 'your')
230
235
 
231
- def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end
232
- def comma ; Lex::Literal.new(',', get_lexeme(','), 0) ; end
233
- def dot ; Lex::Literal.new('.', get_lexeme('.'), 0) ; end
234
- def quote ; Lex::Literal.new('"', get_lexeme('"'), 0) ; end
236
+ def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end
237
+ def comma ; Lex::Literal.new(',', get_lexeme(','), 0) ; end
238
+ def dot ; Lex::Literal.new('.', get_lexeme('.'), 0) ; end
239
+ def quote ; Lex::Literal.new('"', get_lexeme('"'), 0) ; end
235
240
  end # module
236
- end # module
241
+ # rubocop: enable Style/SingleLineMethods
242
+ # rubocop: enable Layout/SpaceBeforeSemicolon
243
+ end # module
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../spec_helper' # Use the RSpec framework
4
+ require_relative '../../../lib/zenlish/trie/base_trie_node' # Load the class under test
5
+
6
+ module Zenlish
7
+ module Trie
8
+ describe BaseTrieNode do
9
+ subject(:node) { described_class.new }
10
+
11
+ context 'Initialization:' do
12
+ it 'is initialized without argument' do
13
+ expect { described_class.new }.not_to raise_error
14
+ end
15
+
16
+ it 'is a leaf node at start' do
17
+ expect(node).to be_leaf
18
+ end
19
+ end # context
20
+
21
+ context 'Provided services:' do
22
+ it 'accepts the addition of a successor' do
23
+ some_node = described_class.new
24
+
25
+ expect(node).not_to include('f')
26
+ expect { node.add_succ('f', some_node) }.not_to raise_error
27
+ expect(node).to include('f')
28
+ expect(node.succ['f']).to eq(some_node)
29
+ end
30
+ end # context
31
+ end # describe
32
+ end # module
33
+ end # module
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../spec_helper' # Use the RSpec framework
4
+ require_relative '../../../lib/zenlish/trie/trie' # Load the class under test
5
+
6
+ module Zenlish
7
+ module Trie
8
+ describe Trie do
9
+ subject(:trie) { described_class.new }
10
+
11
+ context 'Initialization:' do
12
+ it 'is initialized without argument' do
13
+ expect { described_class.new }.not_to raise_error
14
+ end
15
+
16
+ it 'is a leaf node at start' do
17
+ expect(trie.root).to be_a(TrieRoot)
18
+ end
19
+ end # context
20
+
21
+ context 'Provided services:' do
22
+ it 'accepts the addition of one single node' do
23
+ expect { trie.add('a', 'OK') }.not_to raise_error
24
+ expect(trie.root).to include('a')
25
+ expect(trie.root.succ['a']).to be_a(TrieNode)
26
+ expect(trie.root.succ['a'].value).to eq('OK')
27
+ end
28
+
29
+ it 'accepts the addition of a node string' do
30
+ expect { trie.add('abc', 'OK') }.not_to raise_error
31
+ expect(trie.root).to include('a')
32
+ expect(trie.root).not_to include('b')
33
+
34
+ node_a = trie.root.succ['a']
35
+ expect(node_a).to be_a(TrieNode)
36
+ expect(node_a.value).to be_nil
37
+ expect(node_a).to include('b')
38
+ expect(node_a).not_to include('c')
39
+
40
+ node_b = node_a.succ['b']
41
+ expect(node_b).to be_a(TrieNode)
42
+ expect(node_b.value).to be_nil
43
+ expect(node_b).to include('c')
44
+
45
+ node_c = node_b.succ['c']
46
+ expect(node_c).to be_a(TrieNode)
47
+ expect(node_c.value).to eq('OK')
48
+ expect(node_c).to be_leaf
49
+ end
50
+
51
+ it 'accepts the addition of multiple node strings' do
52
+ trie.add('abc', 'ABC')
53
+ expect { trie.add('abe', 'ABE') }.not_to raise_error
54
+ root = trie.root
55
+ expect(root).to include('a')
56
+ expect(root).not_to include('b')
57
+
58
+ node_a = root.succ['a']
59
+
60
+ node_b = node_a.succ['b']
61
+ expect(node_b).to be_a(TrieNode)
62
+ expect(node_b.value).to be_nil
63
+ expect(node_b).to include('c')
64
+ expect(node_b).to include('e')
65
+
66
+ node_c = node_b.succ['c']
67
+ expect(node_c).to be_a(TrieNode)
68
+ expect(node_c.value).to eq('ABC')
69
+ expect(node_c).to be_leaf
70
+
71
+ node_e = node_b.succ['e']
72
+ expect(node_e).to be_a(TrieNode)
73
+ expect(node_e.value).to eq('ABE')
74
+ expect(node_e).to be_leaf
75
+ end
76
+
77
+ it 'retrieves the node matching a given string' do
78
+ trie.add('abc', 'ABC')
79
+ trie.add('hello', 'WORLD')
80
+ trie.add('hellene', 'GREEK')
81
+
82
+ hello_node = trie.search('hello')
83
+ expect(hello_node.key).to eq('o')
84
+ expect(hello_node.value).to eq('WORLD')
85
+ hellish = trie.search('hell')
86
+ expect(hellish.key).to eq('l')
87
+ expect(hellish.value).to be_nil
88
+ expect(trie.search('greeting')).to be_nil
89
+ hellene_node = trie.search('hellene')
90
+ expect(hellene_node.key).to eq('e')
91
+ expect(hellene_node.value).to eq('GREEK')
92
+ expect(trie.search('hellenes')).to be_nil
93
+ end
94
+
95
+ it 'accepts the addition of "synonyms"' do
96
+ trie.add('abd', 'first')
97
+ trie.add('abduce', 'ABDUCE')
98
+
99
+ abd_node = trie.search('abd')
100
+ expect(abd_node.value).to eq('first')
101
+
102
+ trie.add('abd', 'second')
103
+ expect(abd_node.value).to eq(%w[first second])
104
+ end
105
+ end # context
106
+ end # describe
107
+ end # module
108
+ end # module
@@ -7,53 +7,49 @@ require_relative '../../../lib/zenlish/wclasses/common_noun' # Load the class un
7
7
  module Zenlish
8
8
  module WClasses
9
9
  describe CommonNoun do
10
- subject { CommonNoun.new }
10
+ subject(:noun) { described_class.new }
11
11
 
12
12
  context 'Initialization:' do
13
- it 'should be initialized without argument' do
14
- expect { CommonNoun.new }.not_to raise_error
13
+ it 'is initialized without argument' do
14
+ expect { described_class.new }.not_to raise_error
15
15
  end
16
16
  end # context
17
17
 
18
18
  context 'Provided services:' do
19
- it 'should provide a default inflection paradigm' do
20
- expect(subject.paradigm).not_to be_nil
19
+ it 'provides a default inflection paradigm' do
20
+ expect(noun.paradigm).not_to be_nil
21
21
  end
22
22
 
23
- it 'should support the pluralization of common nouns' do
24
- samples = %w[animal body people]
23
+ it 'supports the pluralization of common nouns' do
24
+ samples = %w[animal body people]
25
25
  lexemes = []
26
26
  Lang::Dictionary.entries.each do |ent|
27
- lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(Zenlish::WClasses::CommonNoun) }
27
+ lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(described_class) }
28
28
  if lexm && samples.include?(ent.lemma)
29
29
  lexemes.concat(lexm)
30
30
  end
31
31
  end
32
32
  plural_sample = { 'animal' => 'animals',
33
33
  'body' => 'bodies',
34
- 'people' => 'people'
35
- }
36
-
34
+ 'people' => 'people' }
37
35
  lexemes.map do |lx|
38
36
  pluralized = lx.inflect([:plural, nil])
39
37
  expect(pluralized).to eq(plural_sample[lx.base_form])
40
38
  end
41
39
  end
42
-
43
- it 'should know all its inflections' do
44
- samples = %w[animal body people]
40
+
41
+ it 'knows all its inflections' do
42
+ samples = %w[animal body people]
45
43
  lexemes = []
46
44
  Lang::Dictionary.entries.each do |ent|
47
- lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(Zenlish::WClasses::CommonNoun) }
45
+ lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(described_class) }
48
46
  if lexm && samples.include?(ent.lemma)
49
47
  lexemes.concat(lexm)
50
48
  end
51
49
  end
52
- lexemes.map do |lxm|
53
- lxm.all_inflections
54
- end
50
+ lexemes.map(&:all_inflections)
55
51
  end
56
52
  end # context
57
53
  end # describe
58
54
  end # module
59
- end # module
55
+ end # module
@@ -8,18 +8,18 @@ require_relative '../../../lib/zenlish/wclasses/demonstrative_determiner' # Load
8
8
  module Zenlish
9
9
  module WClasses
10
10
  describe DemonstrativeDeterminer do
11
- subject { DemonstrativeDeterminer.new }
11
+ subject(:determiner) { described_class.new }
12
12
 
13
13
  context 'Initialization:' do
14
- it 'should be initialized without argument' do
15
- expect { DemonstrativeDeterminer.new }.not_to raise_error
14
+ it 'is initialized without argument' do
15
+ expect { described_class.new }.not_to raise_error
16
16
  end
17
17
  end # context
18
18
 
19
19
  context 'Provided services:' do
20
20
  def build_det(aBaseForm)
21
21
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
22
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
22
+ Zenlish::Lex::Lexeme.new(determiner, entry)
23
23
  end
24
24
 
25
25
  def test_all_inflections(det_form, wforms)
@@ -28,18 +28,18 @@ module Zenlish
28
28
  expect(inflected.sort).to eq(wforms.sort)
29
29
  end
30
30
 
31
- it 'should know that it is inflectable' do
32
- expect(subject).not_to be_invariable
31
+ it 'knows that it is inflectable' do
32
+ expect(determiner).not_to be_invariable
33
33
  end
34
34
 
35
- it 'should know its feature definitions' do
36
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
37
- expect(subject['DISTANCE']).to be_kind_of(Feature::FeatureDef)
38
- expect(subject['PARADIGM'].default.val).to eq('Demonstrative_det_paradigm')
35
+ it 'knows its feature definitions' do
36
+ expect(determiner['NUMBER']).to be_a(Feature::FeatureDef)
37
+ expect(determiner['DISTANCE']).to be_a(Feature::FeatureDef)
38
+ expect(determiner['PARADIGM'].default.val).to eq('Demonstrative_det_paradigm')
39
39
  end
40
40
 
41
- it 'should give all word forms' do
42
- test_all_inflections('this', ['this', 'that', 'these', 'those'])
41
+ it 'gives all word forms' do
42
+ test_all_inflections('this', %w[this that these those])
43
43
  end
44
44
  end # context
45
45
  end # describe
@@ -10,24 +10,24 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb_can'
10
10
  module Zenlish
11
11
  module WClasses
12
12
  describe IrregularVerbCan do
13
- subject { IrregularVerbCan.new }
13
+ subject(:irreg_can) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { IrregularVerbCan.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(irreg_can['NUMBER']).to be_a(Feature::FeatureDef)
24
+ expect(irreg_can['PERSON']).to be_a(Feature::FeatureDef)
25
+ expect(irreg_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(irreg_can, entry)
31
31
  end
32
32
 
33
33
  def test_inflection_of(verb_form, pairs)
@@ -36,25 +36,25 @@ module Zenlish
36
36
  expect(verb.inflect([time])).to eq(expected_form)
37
37
  end
38
38
  end
39
-
39
+
40
40
  def test_all_inflections(verb_form, wforms)
41
41
  verb = build_verb(verb_form)
42
42
  inflected = verb.all_inflections
43
43
  expect(inflected.sort).to eq(wforms.sort)
44
- end
44
+ end
45
45
 
46
- it 'should know how to inflect modal verb can' do
47
- expectations_1 = [
46
+ it 'knows how to inflect modal verb can' do
47
+ expectations1 = [
48
48
  [:present, 'can'],
49
49
  [:past_simple, 'could']
50
50
  ]
51
- test_inflection_of('can', expectations_1)
51
+ test_inflection_of('can', expectations1)
52
+ end
53
+
54
+ it 'gives all word forms of a given verb' do
55
+ test_all_inflections('can', %w[can could])
52
56
  end
53
-
54
- it 'should give all word forms of a given verb' do
55
- test_all_inflections('can', ['can', 'could'])
56
- end
57
57
  end # context
58
58
  end # describe
59
59
  end # module
60
- end # module
60
+ end # module
@@ -8,28 +8,28 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb_extension'
8
8
  module Zenlish
9
9
  module WClasses
10
10
  describe IrregularVerbExtension do
11
- subject do
11
+ subject(:verb) do
12
12
  obj = Object.new
13
- obj.extend(IrregularVerbExtension)
13
+ obj.extend(described_class)
14
14
  obj.init_extension(obj)
15
15
  obj
16
16
  end
17
17
 
18
18
  context 'Initialization:' do
19
- it 'should mix-in with a host object' do
20
- expect { Object.new.extend(IrregularVerbExtension) }.not_to raise_error
19
+ it 'allows mix-in with a host object' do
20
+ expect { Object.new.extend(described_class) }.not_to raise_error
21
21
  end
22
22
 
23
- it 'should inject an instance variable' do
24
- expect(subject.instance_variable_get(:@forms)).to be_kind_of(Array)
23
+ it 'injects an instance variable' do
24
+ expect(verb.instance_variable_get(:@forms)).to be_a(Array)
25
25
  end
26
26
  end # context
27
27
 
28
28
  context 'Provided services:' do
29
- it 'should provide a write accessor' do
30
- subject.forms past_simple: 'chose', past_participle: 'chosen'
31
- expect(subject.past_simple).to eq('chose')
32
- expect(subject.past_participle).to eq('chosen')
29
+ it 'provides a write accessor' do
30
+ verb.forms past_simple: 'chose', past_participle: 'chosen'
31
+ expect(verb.past_simple).to eq('chose')
32
+ expect(verb.past_participle).to eq('chosen')
33
33
  end
34
34
  end # context
35
35
  end # describe
@@ -10,31 +10,18 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb'
10
10
  module Zenlish
11
11
  module WClasses
12
12
  describe IrregularVerb do
13
- subject { IrregularVerb.new }
13
+ subject(:verb) { described_class.new }
14
14
 
15
15
  context 'Initialization:' do
16
- it 'should be initialized without argument' do
17
- expect { IrregularVerb.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('Irregular_inflection')
26
- end
27
-
28
- let(:present_1sg) { [:first, :singular, :present, nil] }
29
- let(:present_3sg) { [:third, :singular, :present, nil] }
30
- let(:present_1pl) { [:first, :plural, :present, nil] }
31
- let(:progressive) { [nil, nil, :progressive, nil] }
32
- let(:past_simple) { [nil, nil, :past_simple, nil] }
33
- let(:past_participle) { [nil, nil, :past_participle, nil] }
34
-
35
22
  def build_verb(aBaseForm, p_simple, p_participle)
36
23
  entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
37
- lexeme = Zenlish::Lex::Lexeme.new(subject, entry)
24
+ lexeme = Zenlish::Lex::Lexeme.new(verb, entry)
38
25
  lexeme.forms past_simple: p_simple, past_participle: p_participle
39
26
  lexeme
40
27
  end
@@ -45,15 +32,28 @@ module Zenlish
45
32
  expect(verb.inflect(constraints)).to eq(expected_form)
46
33
  end
47
34
  end
48
-
35
+
49
36
  def test_all_inflections(verb_form, p_simple, p_participle, wforms)
50
37
  verb = build_verb(verb_form, p_simple, p_participle)
51
38
  inflected = verb.all_inflections
52
39
  expect(inflected.sort).to eq(wforms.sort)
53
- end
40
+ end
54
41
 
55
- it 'should know how to inflect irregular verbs' do
56
- expectations_1 = [
42
+ let(:present_1sg) { [:first, :singular, :present, nil] }
43
+ let(:present_3sg) { [:third, :singular, :present, nil] }
44
+ let(:present_1pl) { [:first, :plural, :present, nil] }
45
+ let(:progressive) { [nil, nil, :progressive, nil] }
46
+ let(:past_simple) { [nil, nil, :past_simple, nil] }
47
+ let(:past_participle) { [nil, nil, :past_participle, nil] }
48
+
49
+ it 'knows its inherited feature definitions' do
50
+ expect(verb['NUMBER']).to be_a(Feature::FeatureDef)
51
+ expect(verb['PERSON']).to be_a(Feature::FeatureDef)
52
+ expect(verb['PARADIGM'].default.val).to eq('Irregular_inflection')
53
+ end
54
+
55
+ it 'knows how to inflect irregular verbs' do
56
+ expectations1 = [
57
57
  [present_1sg, 'see'],
58
58
  [present_3sg, 'sees'],
59
59
  [present_1pl, 'see'],
@@ -61,9 +61,9 @@ module Zenlish
61
61
  [past_simple, 'saw'],
62
62
  [past_participle, 'seen']
63
63
  ]
64
- test_inflection_of('see', 'saw', 'seen', expectations_1)
64
+ test_inflection_of('see', 'saw', 'seen', expectations1)
65
65
 
66
- expectations_2 = [
66
+ expectations2 = [
67
67
  [present_1sg, 'make'],
68
68
  [present_3sg, 'makes'],
69
69
  [present_1pl, 'make'],
@@ -71,12 +71,12 @@ module Zenlish
71
71
  [past_simple, 'made'],
72
72
  [past_participle, 'made']
73
73
  ]
74
- test_inflection_of('make', 'made', 'made', expectations_2)
74
+ test_inflection_of('make', 'made', 'made', expectations2)
75
+ end
76
+
77
+ it 'gives all word forms of a given verb' do
78
+ test_all_inflections('see', 'saw', 'seen', %w[see sees seeing saw seen])
75
79
  end
76
-
77
- it 'should give all word forms of a given verb' do
78
- test_all_inflections('see', 'saw', 'seen', ['see', 'sees', 'seeing', 'saw', 'seen'])
79
- end
80
80
  end # context
81
81
  end # describe
82
82
  end # module
@@ -3,7 +3,7 @@
3
3
  require_relative '../../spec_helper' # Use the RSpec framework
4
4
 
5
5
  # Load the class under test
6
- require_relative '../../../lib/zenlish/wclasses/lexical_verb'
6
+ require_relative '../../../lib/zenlish/wclasses/lexical_verb'
7
7
 
8
8
  module Zenlish
9
9
  module WClasses
@@ -13,21 +13,21 @@ module Zenlish
13
13
  # Empty method
14
14
  end
15
15
  end
16
-
16
+
17
17
  describe LexicalVerb do
18
- subject { LexicalVerb.new }
18
+ subject(:verb) { described_class.new }
19
19
 
20
20
  context 'Initialization:' do
21
- it 'should be initialized without argument' do
22
- expect { LexicalVerb.new }.not_to raise_error
21
+ it 'is initialized without argument' do
22
+ expect { described_class.new }.not_to raise_error
23
23
  end
24
24
  end # context
25
25
 
26
26
  context 'Provided services:' do
27
- it 'should know its inherited feature definitions' do
28
- expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
29
- expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
30
- expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
27
+ it 'knows its inherited feature definitions' do
28
+ expect(verb['NUMBER']).to be_a(Feature::FeatureDef)
29
+ expect(verb['PERSON']).to be_a(Feature::FeatureDef)
30
+ expect(verb['PARADIGM'].default.val).to eq('Regular_inflection')
31
31
  end
32
32
  end # context
33
33
  end # describe