zenlish 0.2.06 → 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.
- checksums.yaml +4 -4
- data/.rubocop.yml +48 -275
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/lib/zenlish/feature/feature_struct_def.rb +0 -2
- data/lib/zenlish/inflect/output_expression.rb +4 -0
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +0 -1
- data/lib/zenlish.rb +3 -3
- data/spec/zenlish/feature/boolean_domain_spec.rb +14 -14
- data/spec/zenlish/feature/boolean_value_spec.rb +6 -5
- data/spec/zenlish/feature/enumeration_domain_spec.rb +16 -16
- data/spec/zenlish/feature/feature_def_spec.rb +15 -14
- data/spec/zenlish/feature/feature_spec.rb +16 -16
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +16 -16
- data/spec/zenlish/feature/feature_struct_def_spec.rb +23 -23
- data/spec/zenlish/feature/identifier_domain_spec.rb +12 -12
- data/spec/zenlish/feature/identifier_value_spec.rb +6 -5
- data/spec/zenlish/feature/symbol_value_spec.rb +6 -5
- data/spec/zenlish/inflect/concatenation_spec.rb +8 -8
- data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/feature_heading_spec.rb +14 -13
- data/spec/zenlish/inflect/formal_argument_spec.rb +5 -5
- data/spec/zenlish/inflect/function_call_spec.rb +8 -9
- data/spec/zenlish/inflect/inflection_rule_spec.rb +20 -20
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +37 -37
- data/spec/zenlish/inflect/inflection_table_spec.rb +33 -32
- data/spec/zenlish/inflect/input_asis_spec.rb +10 -9
- data/spec/zenlish/inflect/literal_asis_spec.rb +7 -7
- data/spec/zenlish/inflect/matches_pattern_spec.rb +15 -14
- data/spec/zenlish/inflect/membership_spec.rb +16 -15
- data/spec/zenlish/inflect/method_heading_spec.rb +12 -11
- data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/substitution_spec.rb +9 -10
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +7 -5
- data/spec/zenlish/lang/dictionary_spec.rb +17 -19
- data/spec/zenlish/lang/lemmatizer_spec.rb +23 -23
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +3 -3
- data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
- data/spec/zenlish/lex/lexeme_spec.rb +18 -18
- data/spec/zenlish/lex/lexical_entry_spec.rb +14 -13
- data/spec/zenlish/lex/lexicon_spec.rb +44 -43
- data/spec/zenlish/lex/literal_spec.rb +6 -6
- data/spec/zenlish/lexer/lexer_spec.rb +10 -10
- data/spec/zenlish/parser/lesson1_spec.rb +79 -79
- data/spec/zenlish/parser/lesson2_spec.rb +102 -102
- data/spec/zenlish/parser/lesson3_spec.rb +89 -89
- data/spec/zenlish/parser/zparser_spec.rb +6 -6
- data/spec/zenlish/support/var2word.rb +0 -2
- data/spec/zenlish/trie/base_trie_node_spec.rb +11 -11
- data/spec/zenlish/trie/trie_spec.rb +46 -46
- data/spec/zenlish/wclasses/common_noun_spec.rb +9 -9
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +11 -11
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +19 -19
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +7 -7
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +9 -9
- data/spec/zenlish/wclasses/noun_spec.rb +7 -7
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +15 -15
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +15 -15
- data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
- data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
- data/spec/zenlish/wclasses/regular_verb_spec.rb +12 -12
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +7 -7
- data/spec/zenlish/wclasses/verb_spec.rb +9 -9
- data/spec/zenlish_spec.rb +1 -1
- data/zenlish.gemspec +6 -5
- metadata +32 -16
@@ -9,13 +9,13 @@ module Zenlish
|
|
9
9
|
describe ZParser do
|
10
10
|
include Var2Word
|
11
11
|
|
12
|
-
subject {
|
12
|
+
subject(:parser) { described_class.new }
|
13
13
|
|
14
14
|
context 'Parsing lesson 3:' do
|
15
|
-
it '
|
15
|
+
it 'parses sample sentences from lesson 3-A' do
|
16
16
|
# Sentence 3-01a definiendum: 'J happens to something that does K.'
|
17
17
|
literals = [j_, happens, to, something, that, does, k_, dot]
|
18
|
-
expect {
|
18
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
19
19
|
|
20
20
|
# Sentence 3-01b definiens: 'J happens to something.
|
21
21
|
# This same something does K.
|
@@ -23,11 +23,11 @@ module Zenlish
|
|
23
23
|
literals = [j_, happens, to, something, dot,
|
24
24
|
this, same, thing, does, k_, dot,
|
25
25
|
tony, has, something, that, lisa, wants, dot]
|
26
|
-
expect {
|
26
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
27
27
|
|
28
28
|
# Sentence 3-02a definiendum: 'J is true, and K is true.'
|
29
29
|
literals = [j_, is, true_, comma, and_, k_, is, true_, dot]
|
30
|
-
expect {
|
30
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
31
31
|
|
32
32
|
# Sentence 3-02b definiens: 'These two things are true: J is true.
|
33
33
|
# K is true.'
|
@@ -35,11 +35,11 @@ module Zenlish
|
|
35
35
|
literals = [these, two, things, are, true_, colon, j_, is, true_, dot,
|
36
36
|
k_, is, true_, dot,
|
37
37
|
lisa, sees, tony, comma, and_, tony, sees, lisa, dot]
|
38
|
-
expect {
|
38
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
39
39
|
|
40
40
|
# Sentence 3-02c definiendum: 'J and K do X.'
|
41
41
|
literals = [j_, and_, k_, do_, x_as_noun, dot]
|
42
|
-
expect {
|
42
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
43
43
|
|
44
44
|
# Sentence 3-02d definiens: 'These two things do X.
|
45
45
|
# J is one that does this.
|
@@ -51,99 +51,99 @@ module Zenlish
|
|
51
51
|
k_, is, another, that, does, this_as_pronoun, dot,
|
52
52
|
tony, and_, lisa, want, to, see, me, dot,
|
53
53
|
i_pronoun, see, tony, and_, lisa, dot]
|
54
|
-
expect {
|
54
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
55
55
|
|
56
56
|
# Sentence 3-03a definiendum: 'J is true, or K is true.'
|
57
57
|
literals = [j_, is, true_, comma, or_, k_, is, true_, dot]
|
58
|
-
expect {
|
58
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
59
59
|
|
60
60
|
# Sentence 3-03b definiens: 'If J is not true, then K is true.
|
61
61
|
# [Tony saw me, or Lisa heard me.]
|
62
62
|
literals = [if_, j_, is, not_, true_, comma,
|
63
63
|
then_, k_, is, true_, dot,
|
64
64
|
tony, saw, me, comma, or_, lisa, heard, me, dot]
|
65
|
-
expect {
|
65
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
66
66
|
|
67
67
|
# Sentence 3-03c definiendum: 'J or K does this.'
|
68
68
|
literals = [j_, or_, k_, does, this_as_pronoun, dot]
|
69
|
-
expect {
|
69
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
70
70
|
|
71
71
|
# Sentence 3-03d definiendum: 'If J does not do this, then K does this.'
|
72
72
|
literals = [if_, j_, does_aux, not_, do_, this_as_pronoun, comma,
|
73
73
|
then_, k_, does, this_as_pronoun, dot]
|
74
|
-
expect {
|
74
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
75
75
|
|
76
76
|
# Sentence 3-03e: '[Lisa or Tony said something.]
|
77
77
|
# [This belongs to Tony or Lisa.]'
|
78
78
|
literals = [lisa, or_, tony, said, something, dot,
|
79
79
|
this_as_pronoun, belongs, to, tony, or_, lisa, dot]
|
80
|
-
expect {
|
80
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
81
81
|
|
82
82
|
# Sentence 3-04a definiendum: 'It does something.'
|
83
83
|
literals = [it_, does, something, dot]
|
84
|
-
expect {
|
84
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
85
85
|
|
86
86
|
# Sentence 3-04b definiens: 'This thing does something.'
|
87
87
|
# [I touched this thing, and it moved.]
|
88
88
|
literals = [this, thing, does, something, dot,
|
89
89
|
i_pronoun, touched, this, thing, comma, and_, it_, moved, dot]
|
90
|
-
expect {
|
90
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
91
91
|
|
92
92
|
# Sentence 3-04c definiendum: 'They do something.'
|
93
93
|
literals = [they, does, something, dot]
|
94
|
-
expect {
|
94
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
95
95
|
|
96
96
|
# Sentence 3-04d definiens: 'These things or people do something.'
|
97
97
|
# [Something happens to them.] = Something happens to these things or people.
|
98
98
|
literals = [these, things, or_, people, do_, something, dot,
|
99
99
|
something, happens, to, them, dot,
|
100
100
|
something, happens, to, these, things, or_, people, dot]
|
101
|
-
expect {
|
101
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
102
102
|
end
|
103
103
|
|
104
|
-
it '
|
104
|
+
it 'parses sample sentences from lesson 3-B' do
|
105
105
|
# Sentence 3-05a definiendum: 'This is its X.'
|
106
106
|
literals = [this_as_pronoun, is, its, x_as_noun, dot]
|
107
|
-
expect {
|
107
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
108
108
|
|
109
109
|
# Sentence 3-05b definiens: 'This X belongs to it.
|
110
110
|
# [I saw this thing and touched some of its parts.]
|
111
111
|
# [These things are their things.] = These things belong to them.
|
112
112
|
literals = [this, x_as_noun, belongs, to, it_, dot,
|
113
113
|
i_pronoun, saw, this, thing, and_, touched, some, of, its, parts, dot]
|
114
|
-
expect {
|
114
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
115
115
|
|
116
116
|
# Sentence 3-05c definiendum: 'These things are their things.'
|
117
117
|
literals = [these, things, are, their, things, dot]
|
118
|
-
expect {
|
118
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
119
119
|
|
120
120
|
# Sentence 3-05d definiens: 'These things belong to them.
|
121
121
|
literals = [these, things, belong, to, them, dot]
|
122
|
-
expect {
|
122
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
123
123
|
|
124
124
|
# Sentence 3-06a definiendum: 'This is your X.'
|
125
125
|
literals = [this_as_pronoun, is, your, x_as_noun, dot]
|
126
|
-
expect {
|
126
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
127
127
|
|
128
128
|
# Sentence 3-06b definien: 'This X belongs to you.
|
129
129
|
# [You feel something touching your body.]
|
130
130
|
literals = [this, x_as_noun, belongs, to, you, dot,
|
131
131
|
you, feel, something, touching, your, body, dot]
|
132
|
-
expect {
|
132
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
133
133
|
|
134
134
|
# Sentence 3-07a definiendum: 'This is my X.'
|
135
135
|
literals = [this_as_pronoun, is, my, x_as_noun, dot]
|
136
|
-
expect {
|
136
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
137
137
|
|
138
138
|
# Sentence 3-07b definiens: 'This X belongs to me.
|
139
139
|
# [I do not want you to touch my body.]
|
140
140
|
literals = [this, x_as_noun, belongs, to, me, dot,
|
141
141
|
i_pronoun, do_aux, not_, want, to, touch, my, body, dot]
|
142
|
-
expect {
|
142
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
143
143
|
|
144
144
|
# Sentence 3-08a definiendum: 'There is an X here.'
|
145
145
|
literals = [there, is, an, x_as_noun, here, dot]
|
146
|
-
expect {
|
146
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
147
147
|
|
148
148
|
# Sentence 3-08b definiens: 'X is some kind of thing.
|
149
149
|
# There is one of this kind of thing here.
|
@@ -153,7 +153,7 @@ module Zenlish
|
|
153
153
|
there, is, one, of, this, kind, of, thing, here, dot,
|
154
154
|
this_as_pronoun, is, not_, one_as_adj, that, you, said, something,
|
155
155
|
about, a_as_art, short, time, before_as_adj, now_as_noun, dot]
|
156
|
-
expect {
|
156
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
157
157
|
|
158
158
|
# Sentence 3-Bxa 'Lisa sees a living thing that is very big.
|
159
159
|
# Lisa says: "I see one living thing. Its body is bigger than my body.", dot
|
@@ -162,13 +162,13 @@ module Zenlish
|
|
162
162
|
lisa, says, colon, quote, i_pronoun, see, one, living, thing, dot,
|
163
163
|
its, body, is, bigger, than, my, body, dot, quote, dot
|
164
164
|
]
|
165
|
-
expect {
|
165
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
166
166
|
end
|
167
167
|
|
168
|
-
it '
|
168
|
+
it 'parses sample sentences from lesson 3-C' do
|
169
169
|
# Sentence 3-09a definiendum: 'Something happens to the X.'
|
170
170
|
literals = [something, happens, to, the, x_as_noun, dot]
|
171
|
-
expect {
|
171
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
172
172
|
|
173
173
|
# Sentence 3-09b definiens: Something happens to X.
|
174
174
|
# This is the same X that someone said something about a short time before,
|
@@ -181,11 +181,11 @@ module Zenlish
|
|
181
181
|
as, x_as_noun, dot,
|
182
182
|
i_pronoun, saw, two, people, here, before_adverb, comma,
|
183
183
|
and_, now, i_pronoun, do_aux, not_, see, the, people, dot]
|
184
|
-
expect {
|
184
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
185
185
|
|
186
186
|
# Sentence 3-10a definiendum: 'X is an animal.'
|
187
187
|
literals = [x_as_noun, is, an, animal, dot]
|
188
|
-
expect {
|
188
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
189
189
|
|
190
190
|
# Sentence 3-10b definiens: There are many kinds of living things
|
191
191
|
# that can feel and can move when they want. X is one of these.
|
@@ -194,11 +194,11 @@ module Zenlish
|
|
194
194
|
that, can, feel, and_, can, move, when_, they, want, dot,
|
195
195
|
x_as_noun, is, one, of, these_as_pronoun, dot,
|
196
196
|
the, animal, moved, when_, someone, touched, its, body, dot]
|
197
|
-
expect {
|
197
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
198
198
|
|
199
199
|
# Sentence 3-11a definiendum: 'J causes K to happen.'
|
200
200
|
literals = [j_, causes, k_, to, happen, dot]
|
201
|
-
expect {
|
201
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
202
202
|
|
203
203
|
# Sentence 3-11b definiens: K happens because J happens
|
204
204
|
# or because J does something.
|
@@ -206,11 +206,11 @@ module Zenlish
|
|
206
206
|
literals = [k_, happens, because, j_, happens,
|
207
207
|
or_, because, j_, does, something, dot,
|
208
208
|
something, bad, caused, these, people, to, die, dot]
|
209
|
-
expect {
|
209
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
210
210
|
|
211
211
|
# Sentence 3-12a definiendum: 'J is true, but K is not true.'
|
212
212
|
literals = [j_, is, true_, comma, but, k_, is, not_, true_, dot]
|
213
|
-
expect {
|
213
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
214
214
|
|
215
215
|
# Sentence 3-12b definiens: You say J is true.
|
216
216
|
# Maybe when some people hear J is true,
|
@@ -222,7 +222,7 @@ module Zenlish
|
|
222
222
|
you, want, them, to, know, k_, is, not_, true_, comma,
|
223
223
|
and_, you, say, this_as_pronoun, dot,
|
224
224
|
i_pronoun, hear, tony, comma, but, i_pronoun, do_aux, not_, see, lisa, dot]
|
225
|
-
expect {
|
225
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
226
226
|
|
227
227
|
# Sentence 3-C Xtra Lisa says: "I can hear an animal, but I do not see it."
|
228
228
|
# Tony says: "I can see the animal that you hear.".
|
@@ -230,13 +230,13 @@ module Zenlish
|
|
230
230
|
animal, comma, but, i_pronoun, do_aux, not_, see, it_, dot, quote,
|
231
231
|
dot, tony, says, colon, quote, i_pronoun, can, see, the, animal,
|
232
232
|
that, you, hear, dot, quote, dot]
|
233
|
-
expect {
|
233
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
234
234
|
end
|
235
235
|
|
236
|
-
it '
|
236
|
+
it 'parses sample sentences from lesson 3-D' do
|
237
237
|
# Sentence 3-13a definiendum: 'You use this thing.'
|
238
238
|
literals = [you, use, this, thing, dot]
|
239
|
-
expect {
|
239
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
240
240
|
|
241
241
|
# Sentence 3-13b definiens: You do something with this thing
|
242
242
|
# because you think this can cause something to happen that you want.
|
@@ -246,11 +246,11 @@ module Zenlish
|
|
246
246
|
that, you, want, dot,
|
247
247
|
i_pronoun, used, something, big, to, cause, people, far, from,
|
248
248
|
here_as_noun, to, see, me, dot]
|
249
|
-
expect {
|
249
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
250
250
|
|
251
251
|
# Sentence 3-14a definiendum: 'You know X about each of these things.'
|
252
252
|
literals = [you, know, x_as_noun, about, each_, of, these, things, dot]
|
253
|
-
expect {
|
253
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
254
254
|
|
255
255
|
# Sentence 3-14b definiens: There are two or more things.
|
256
256
|
# You think about all these things like this:
|
@@ -263,11 +263,11 @@ module Zenlish
|
|
263
263
|
if_, something, is, one, of, these, things, comma,
|
264
264
|
then_, you, know, x_as_noun, about, it_, dot,
|
265
265
|
each_, person, here, said, something, to, me, dot]
|
266
|
-
expect {
|
266
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
267
267
|
|
268
268
|
# Sentence 3-15a definiendum: 'Someplace an X exists.'
|
269
269
|
literals = [someplace, an, x_as_noun, exists, dot]
|
270
|
-
expect {
|
270
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
271
271
|
|
272
272
|
# Sentence 3-15b definiens: Someplace there is an X,
|
273
273
|
# or someplace an X is alive.
|
@@ -275,11 +275,11 @@ module Zenlish
|
|
275
275
|
literals = [someplace, there, is, an, x_as_noun, comma,
|
276
276
|
or_, someplace, an, x_as_noun, is, alive, dot,
|
277
277
|
this, kind, of, thing, did, not_, exist, before, this, time, dot]
|
278
|
-
expect {
|
278
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
279
279
|
|
280
280
|
# Sentence 3-16a definiendum: 'J became K.'
|
281
281
|
literals = [j_, became, k_, dot]
|
282
|
-
expect {
|
282
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
283
283
|
|
284
284
|
# Sentence 3-16b definiens: Something happened to J for some time.
|
285
285
|
# After this happened, K is something true you can know about J.
|
@@ -290,7 +290,7 @@ module Zenlish
|
|
290
290
|
you, can, know, about, j_, dot,
|
291
291
|
these, two, animals, were, small, before_adverb, comma,
|
292
292
|
but, they, became, big, dot]
|
293
|
-
expect {
|
293
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
294
294
|
|
295
295
|
# Sentence 3-Dx: There are some animals here.
|
296
296
|
# Each of these animals was small when it existed a short time.
|
@@ -300,24 +300,24 @@ module Zenlish
|
|
300
300
|
existed, a_as_art, short, time, dot,
|
301
301
|
after_, a_as_art, long, time, comma, each_, of, these, animals,
|
302
302
|
became, big, dot]
|
303
|
-
expect {
|
303
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
304
304
|
end
|
305
305
|
|
306
|
-
it '
|
306
|
+
it 'parses sample sentences from lesson 3-E' do
|
307
307
|
# Sentence 3-17a definiendum: 'These things are different.'
|
308
308
|
literals = [things, are, different, dot]
|
309
|
-
expect {
|
309
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
310
310
|
|
311
311
|
# Sentence 3-17b definiens: These things are not the same.
|
312
312
|
# [I want this kind of thing, but you want something different.]
|
313
313
|
literals = [these, things, are, not_, the, same_as_pronoun, dot,
|
314
314
|
i_pronoun, want, this, kind, of, thing, comma,
|
315
315
|
but, you, want, something, different, dot]
|
316
|
-
expect {
|
316
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
317
317
|
|
318
318
|
# Sentence 3-18a definiendum: 'J made K.'
|
319
319
|
literals = [j_, made, k_, dot]
|
320
|
-
expect {
|
320
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
321
321
|
|
322
322
|
# Sentence 3-18b definiens: J did something to some things
|
323
323
|
# and caused them to become parts of one different
|
@@ -332,11 +332,11 @@ module Zenlish
|
|
332
332
|
i_pronoun, used, many, small, things, to, make, this, big, thing, dot,
|
333
333
|
j_, made, k_, happen, dot,
|
334
334
|
j_, caused, k_, to, happen, dot]
|
335
|
-
expect {
|
335
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
336
336
|
|
337
337
|
# Sentence 3-19a definiendum: 'J contains K.'
|
338
338
|
literals = [j_, contains, k_, dot]
|
339
|
-
expect {
|
339
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
340
340
|
|
341
341
|
# Sentence 3-19b definiens: K is inside J.
|
342
342
|
# [I made something to contain all these small things.]
|
@@ -344,11 +344,11 @@ module Zenlish
|
|
344
344
|
literals = [k_, is, inside, j_, dot,
|
345
345
|
i_pronoun, made, something, to, contain, all, these, small, things, dot,
|
346
346
|
your, body, contains, many, parts, dot]
|
347
|
-
expect {
|
347
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
348
348
|
|
349
349
|
# Sentence 3-20a definiendum: 'X is a container.'
|
350
350
|
literals = [x_as_noun, is, a_as_art, container, dot]
|
351
|
-
expect {
|
351
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
352
352
|
|
353
353
|
# Sentence 3-20b definiens: X is something that people make because
|
354
354
|
# they want to use it to contain other things.
|
@@ -356,19 +356,19 @@ module Zenlish
|
|
356
356
|
literals = [x_as_noun, is, something, that, people, make, because,
|
357
357
|
they, want, to, use, it_, to, contain, other, things, dot,
|
358
358
|
there, are, two, things, inside, this, container, dot]
|
359
|
-
expect {
|
359
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
360
360
|
|
361
361
|
# Sentence 3-Extra: Someone made these containers.
|
362
362
|
# Each contains a different kind of animal.
|
363
363
|
literals = [someone, made, these, containers, dot,
|
364
364
|
each_as_pronoun, contains, a_as_art, different, kind, of, animal, dot]
|
365
|
-
expect {
|
365
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
366
366
|
end
|
367
367
|
|
368
|
-
it '
|
368
|
+
it 'parses sample sentences from lesson 3-F' do
|
369
369
|
# Sentence 3-21a definiendum: 'You try to do X.'
|
370
370
|
literals = [you, try_, to, do_, x_as_noun, dot]
|
371
|
-
expect {
|
371
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
372
372
|
|
373
373
|
# Sentence 3-21b definiens: Because you want X to happen,
|
374
374
|
# you do things that you think can cause X to happen.
|
@@ -377,11 +377,11 @@ module Zenlish
|
|
377
377
|
you, do_, things, that, you, think, can, cause, x_as_noun,
|
378
378
|
to, happen, dot,
|
379
379
|
i_pronoun, tried, to, do_, something, good, dot]
|
380
|
-
expect {
|
380
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
381
381
|
|
382
382
|
# Sentence 3-22a definiendum: 'X changed.'
|
383
383
|
literals = [x_as_noun, changed, dot]
|
384
|
-
expect {
|
384
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
385
385
|
|
386
386
|
# Sentence 3-22b definiens: Something happened to X.
|
387
387
|
# Because of this, X is not the same as before.
|
@@ -391,11 +391,11 @@ module Zenlish
|
|
391
391
|
as, before_adverb, dot,
|
392
392
|
after_, this, kind, of, animal, is, alive, for_, some, time, comma,
|
393
393
|
its, body, changes, dot]
|
394
|
-
expect {
|
394
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
395
395
|
|
396
396
|
# Sentence 3-22c definiendum: 'J changed K.'
|
397
397
|
literals = [j_, changed, k_, dot]
|
398
|
-
expect {
|
398
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
399
399
|
|
400
400
|
# Sentence 3-22d definiens: J caused K to change.
|
401
401
|
# Because of this, X is not the same as before.
|
@@ -403,11 +403,11 @@ module Zenlish
|
|
403
403
|
literals = [j_, caused, k_, to, change_, dot,
|
404
404
|
when_, these, people, did, something, bad, comma,
|
405
405
|
it_, changed, what, i_pronoun, thought, about, them, dot]
|
406
|
-
expect {
|
406
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
407
407
|
|
408
408
|
# Sentence 3-23a definiendum: 'You see the surface of X.'
|
409
409
|
literals = [you, see, the, surface, of, x_as_noun, dot]
|
410
|
-
expect {
|
410
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
411
411
|
|
412
412
|
# Sentence 3-23b definiens: You see part of X.
|
413
413
|
# This part is where other things can touch X.
|
@@ -419,27 +419,27 @@ module Zenlish
|
|
419
419
|
but, i_pronoun, can, not_, see, what, is, inside, dot,
|
420
420
|
when_, i_pronoun, touched, this, thing, comma, i_pronoun, could,
|
421
421
|
feel, parts, of, it_, moving, below, its, surface, dot]
|
422
|
-
expect {
|
422
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
423
423
|
|
424
424
|
# Sentence 3-23c definiendum: 'J is on the surface of K.'
|
425
425
|
literals = [j_, is, on, the, surface, of, k_, dot]
|
426
|
-
expect {
|
426
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
427
427
|
|
428
428
|
# Sentence 3-23d definiens: J is touching the surface of K.
|
429
429
|
literals = [j_, is, touching, the, surface, of, k_, dot]
|
430
|
-
expect {
|
430
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
431
431
|
|
432
432
|
# Sentence 3-F xtra: Tony wants to know what is inside this container.
|
433
433
|
# Tony tries to touch things inside the container.
|
434
434
|
literals = [tony, wants, to, know, what, is, inside, this, container, dot,
|
435
435
|
tony, tries, to, touch, things, inside, the, container, dot]
|
436
|
-
expect {
|
436
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
437
437
|
end
|
438
438
|
|
439
|
-
it '
|
439
|
+
it 'parses sample sentences from lesson 3-G' do
|
440
440
|
# Sentence 3-24a definiendum: 'You choose one of these things.'
|
441
441
|
literals = [you, choose, one, of, these, things, dot]
|
442
|
-
expect {
|
442
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
443
443
|
|
444
444
|
# Sentence 3-24b definiendum: 'There are two or more things you can do.
|
445
445
|
# If you do one of these, you cannot do another.
|
@@ -459,40 +459,40 @@ module Zenlish
|
|
459
459
|
to, do_, this, one_as_pronoun, dot,
|
460
460
|
you, can, choose, to, have, one, of, these, things, dot,
|
461
461
|
i_pronoun, chose, this, big, one_as_pronoun, dot]
|
462
|
-
expect {
|
462
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
463
463
|
|
464
464
|
# Sentence 3-25a definiendum: 'X is in a place between J and K.'
|
465
465
|
literals = [x_as_noun, is, in_, a_as_art, place, between, j_, and_, k_, dot]
|
466
|
-
expect {
|
466
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
467
467
|
|
468
468
|
# Sentence 3-25b definiens: X is in a place.
|
469
469
|
# J is on one side of X, and K is on the other side of X.
|
470
470
|
literals = [x_as_noun, is, in_, a_as_art, place, dot,
|
471
471
|
j_, is, on, one, side, of, x_as_noun, comma, and_,
|
472
472
|
k_, is, on, the, other, side, of, x_as_noun, dot]
|
473
|
-
expect {
|
473
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
474
474
|
|
475
475
|
# Sentence 3-25c definiendum: 'X happens at a time between J and K.'
|
476
476
|
literals = [x_as_noun, happens, at, a_as_art, time, between, j_, and_, k_, dot]
|
477
|
-
expect {
|
477
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
478
478
|
|
479
479
|
# Sentence 3-25d definiens: X happens after J and before K
|
480
480
|
literals = [x_as_noun, happens, after_as_prep, j_, and_,
|
481
481
|
before_as_prep, k_, dot]
|
482
|
-
expect {
|
482
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
483
483
|
|
484
484
|
# Sentence 3-25e definiendum: 'X is between J and K.'
|
485
485
|
literals = [x_as_noun, is, between, j_, and_, k_, dot]
|
486
|
-
expect {
|
486
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
487
487
|
|
488
488
|
# Sentence 3-25f definiens: X is more than J but not more than K.
|
489
489
|
literals = [x_as_noun, is, more, than, j_,
|
490
490
|
but, not_, more, than, k_, dot]
|
491
|
-
expect {
|
491
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
492
492
|
|
493
493
|
# Sentence 3-26a definiendum: 'X moved here from this other place.'
|
494
494
|
literals = [x_as_noun, moved, here, from, this, other, place, dot]
|
495
|
-
expect {
|
495
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
496
496
|
|
497
497
|
# Sentence 3-26b definiens: 'X was in this other place before
|
498
498
|
# it moved for some time. Because X moved, it is here after this,
|
@@ -501,11 +501,11 @@ module Zenlish
|
|
501
501
|
it_, moved, for_, some, time, dot,
|
502
502
|
because, x_as_noun, moved, comma, it_, is, here, after_,
|
503
503
|
this_as_pronoun, comma, and_, it_, is, not_, in_, this, other, place, dot]
|
504
|
-
expect {
|
504
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
505
505
|
|
506
506
|
# Sentence 3-27a definiendum: 'X is a machine.'
|
507
507
|
literals = [x_as_noun, is, a_as_art, machine, dot]
|
508
|
-
expect {
|
508
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
509
509
|
|
510
510
|
# Sentence 3-27b definiens: 'X is something people make.
|
511
511
|
# When people make some things like X, they use many parts to make these things.
|
@@ -524,7 +524,7 @@ module Zenlish
|
|
524
524
|
and_, more_as_adverb, than, people, want, to, do_, dot,
|
525
525
|
i_pronoun, used, a_as_art, machine, to, cause, these, big, things,
|
526
526
|
to, move, dot]
|
527
|
-
expect {
|
527
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
528
528
|
|
529
529
|
# Sentence 3-G xtra: Tony wants to make something using a machine.
|
530
530
|
# Tony is between two different machines.
|
@@ -534,13 +534,13 @@ module Zenlish
|
|
534
534
|
tony, is, between, two, different, machines, dot,
|
535
535
|
tony, says, colon, quote, i_pronoun, can, choose, to, use,
|
536
536
|
one, of, these, machines, dot, quote, dot]
|
537
|
-
expect {
|
537
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
538
538
|
end
|
539
539
|
|
540
|
-
it '
|
540
|
+
it 'parses sample sentences from lesson 3-H' do
|
541
541
|
# Sentence 3-28a definiendum: 'J damaged K.'
|
542
542
|
literals = [j_, damaged, k_, dot]
|
543
|
-
expect {
|
543
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
544
544
|
|
545
545
|
# Sentence 3-28b definiens: 'J did something to K that was bad for K
|
546
546
|
# and it changed K like this: Before this happened,
|
@@ -555,11 +555,11 @@ module Zenlish
|
|
555
555
|
things, more, than, it_, can_irregular, now, dot,
|
556
556
|
you, can, not_, move, now, because, something, damaged,
|
557
557
|
part, of, your, body, dot]
|
558
|
-
expect {
|
558
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
559
559
|
|
560
560
|
# Sentence 3-29a definiendum: 'Doing X is difficult.'
|
561
561
|
# literals = [doing, x_as_noun, is, difficult, dot]
|
562
|
-
# expect {
|
562
|
+
# expect { parser.to_pforest(literals) }.not_to raise_error
|
563
563
|
end
|
564
564
|
=begin
|
565
565
|
3-29. difficult.
|
@@ -9,11 +9,11 @@ module Zenlish
|
|
9
9
|
describe ZParser do
|
10
10
|
include Var2Word
|
11
11
|
|
12
|
-
subject {
|
12
|
+
subject(:parser) { described_class.new }
|
13
13
|
|
14
14
|
context 'Initialization:' do
|
15
|
-
it '
|
16
|
-
expect {
|
15
|
+
it 'is initialized without argument' do
|
16
|
+
expect { described_class.new }.not_to raise_error
|
17
17
|
end
|
18
18
|
end # context
|
19
19
|
|
@@ -22,14 +22,14 @@ module Zenlish
|
|
22
22
|
# # OK, non-ambiguous sentence: "Lisa sees Tony."
|
23
23
|
# literals = [lisa, sees, tony, dot]
|
24
24
|
# result_type = Rley::PTree::ParseTree
|
25
|
-
# expect(
|
25
|
+
# expect(parser.to_pforest(literals)).to be_a(result_type)
|
26
26
|
# end
|
27
27
|
|
28
|
-
it '
|
28
|
+
it 'produces forest' do
|
29
29
|
# Sentence: "Lisa sees Tony."
|
30
30
|
literals = [lisa, sees, tony, dot]
|
31
31
|
result_type = Rley::SPPF::ParseForest
|
32
|
-
expect(
|
32
|
+
expect(parser.to_pforest(literals)).to be_a(result_type)
|
33
33
|
end
|
34
34
|
end # context
|
35
35
|
end # describe
|
@@ -4,7 +4,6 @@ require_relative 'minimal_lexicon'
|
|
4
4
|
require_relative '../../../lib/zenlish/lex/literal'
|
5
5
|
|
6
6
|
module Zenlish
|
7
|
-
# rubocop: disable Layout/EmptyLineBetweenDefs
|
8
7
|
# rubocop: disable Layout/SpaceBeforeSemicolon
|
9
8
|
# rubocop: disable Style/SingleLineMethods
|
10
9
|
|
@@ -241,5 +240,4 @@ module Zenlish
|
|
241
240
|
end # module
|
242
241
|
# rubocop: enable Style/SingleLineMethods
|
243
242
|
# rubocop: enable Layout/SpaceBeforeSemicolon
|
244
|
-
# rubocop: enable Layout/EmptyLineBetweenDefs
|
245
243
|
end # module
|
@@ -6,26 +6,26 @@ require_relative '../../../lib/zenlish/trie/base_trie_node' # Load the class und
|
|
6
6
|
module Zenlish
|
7
7
|
module Trie
|
8
8
|
describe BaseTrieNode do
|
9
|
-
subject {
|
9
|
+
subject(:node) { described_class.new }
|
10
10
|
|
11
11
|
context 'Initialization:' do
|
12
|
-
it '
|
13
|
-
expect {
|
12
|
+
it 'is initialized without argument' do
|
13
|
+
expect { described_class.new }.not_to raise_error
|
14
14
|
end
|
15
15
|
|
16
|
-
it '
|
17
|
-
expect(
|
16
|
+
it 'is a leaf node at start' do
|
17
|
+
expect(node).to be_leaf
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
21
21
|
context 'Provided services:' do
|
22
|
-
it '
|
23
|
-
some_node =
|
22
|
+
it 'accepts the addition of a successor' do
|
23
|
+
some_node = described_class.new
|
24
24
|
|
25
|
-
expect(
|
26
|
-
expect {
|
27
|
-
expect(
|
28
|
-
expect(
|
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
29
|
end
|
30
30
|
end # context
|
31
31
|
end # describe
|