zenlish 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +11 -9
- data/lib/zenlish/lang/dictionary.rb +10 -4
- data/lib/zenlish/lang/zenlish_grammar.rb +9 -0
- data/lib/zenlish/lex/empty_lexicon_factory.rb +1 -0
- data/lib/zenlish/lex/lexicon.rb +7 -1
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/all_word_classes.rb +1 -0
- data/lib/zenlish/wclasses/modal_verb_could.rb +9 -0
- data/spec/zenlish/parser/lesson1_spec.rb +331 -0
- data/spec/zenlish/parser/lesson2_spec.rb +503 -0
- data/spec/zenlish/parser/lesson3_spec.rb +473 -0
- data/spec/zenlish/parser/zparser_spec.rb +3 -1407
- data/spec/zenlish/support/var2word.rb +223 -0
- metadata +10 -2
@@ -0,0 +1,473 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
3
|
+
require_relative '../support/var2word'
|
4
|
+
require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test
|
5
|
+
|
6
|
+
module Zenlish
|
7
|
+
module Parser
|
8
|
+
describe ZParser do
|
9
|
+
include Var2Word
|
10
|
+
|
11
|
+
subject { ZParser.new }
|
12
|
+
|
13
|
+
context 'Parsing lesson 3:' do
|
14
|
+
it 'should parse sample sentences from lesson 3-A' do
|
15
|
+
# Sentence 3-01a definiendum: 'J happens to something that does K.'
|
16
|
+
literals = [j_, happens, to, something, that, does, k_, dot]
|
17
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
18
|
+
|
19
|
+
# Sentence 3-01b definiens: 'J happens to something.
|
20
|
+
# This same something does K.
|
21
|
+
# [Tony has something that Lisa wants.]'
|
22
|
+
literals = [j_, happens, to, something, dot,
|
23
|
+
this, same, thing, does, k_, dot,
|
24
|
+
tony, has, something, that, lisa, wants, dot
|
25
|
+
]
|
26
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
27
|
+
|
28
|
+
# Sentence 3-02a definiendum: 'J is true, and K is true.'
|
29
|
+
literals = [j_, is, true_, comma, and_, k_, is, true_, dot]
|
30
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
31
|
+
|
32
|
+
# Sentence 3-02b definiens: 'These two things are true: J is true.
|
33
|
+
# K is true.'
|
34
|
+
# [Lisa sees Tony, and Tony sees Lisa.]'
|
35
|
+
literals = [these, two, things, are, true_, colon, j_, is, true_, dot,
|
36
|
+
k_, is, true_, dot,
|
37
|
+
lisa, sees, tony, comma, and_, tony, sees, lisa, dot
|
38
|
+
]
|
39
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
40
|
+
|
41
|
+
# Sentence 3-02c definiendum: 'J and K do X.'
|
42
|
+
literals = [j_, and_, k_, do_, x_as_noun, dot]
|
43
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
44
|
+
|
45
|
+
# Sentence 3-02d definiens: 'These two things do X.
|
46
|
+
# J is one that does this.
|
47
|
+
# K is another that does this.'
|
48
|
+
# [Tony and Lisa want to see me.]
|
49
|
+
# [I see Tony and Lisa.]'
|
50
|
+
literals = [these, two, things, do_, x_as_noun, dot,
|
51
|
+
j_, is, one_as_adj, that, does, this_as_pronoun, dot,
|
52
|
+
k_, is, another, that, does, this_as_pronoun, dot,
|
53
|
+
tony, and_, lisa, want, to, see, me, dot,
|
54
|
+
i_pronoun, see, tony, and_, lisa, dot
|
55
|
+
]
|
56
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
57
|
+
|
58
|
+
# Sentence 3-03a definiendum: 'J is true, or K is true.'
|
59
|
+
literals = [j_, is, true_, comma, or_, k_, is, true_, dot]
|
60
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
61
|
+
|
62
|
+
# Sentence 3-03b definiens: 'If J is not true, then K is true.
|
63
|
+
# [Tony saw me, or Lisa heard me.]
|
64
|
+
literals = [if_, j_, is, not_, true_, comma,
|
65
|
+
then_, k_, is, true_, dot,
|
66
|
+
tony, saw, me, comma, or_, lisa, heard, me, dot
|
67
|
+
]
|
68
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
69
|
+
|
70
|
+
# Sentence 3-03c definiendum: 'J or K does this.'
|
71
|
+
literals = [j_, or_, k_, does, this_as_pronoun, dot]
|
72
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
73
|
+
|
74
|
+
# Sentence 3-03d definiendum: 'If J does not do this, then K does this.'
|
75
|
+
literals = [if_, j_, does_aux, not_, do_, this_as_pronoun, comma,
|
76
|
+
then_, k_, does, this_as_pronoun, dot]
|
77
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
78
|
+
|
79
|
+
# Sentence 3-03e: '[Lisa or Tony said something.]
|
80
|
+
# [This belongs to Tony or Lisa.]'
|
81
|
+
literals = [lisa, or_, tony, said, something, dot,
|
82
|
+
this_as_pronoun, belongs, to, tony, or_, lisa, dot
|
83
|
+
]
|
84
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
85
|
+
|
86
|
+
# Sentence 3-04a definiendum: 'It does something.'
|
87
|
+
literals = [it_, does, something, dot]
|
88
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
89
|
+
|
90
|
+
# Sentence 3-04b definiens: 'This thing does something.'
|
91
|
+
# [I touched this thing, and it moved.]
|
92
|
+
literals = [this, thing, does, something, dot,
|
93
|
+
i_pronoun, touched, this, thing, comma, and_, it_, moved, dot
|
94
|
+
]
|
95
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
96
|
+
|
97
|
+
# Sentence 3-04c definiendum: 'They do something.'
|
98
|
+
literals = [they, does, something, dot
|
99
|
+
]
|
100
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
101
|
+
|
102
|
+
# Sentence 3-04d definiens: 'These things or people do something.'
|
103
|
+
# [Something happens to them.] = Something happens to these things or people.
|
104
|
+
literals = [ these, things, or_, people, do_, something, dot,
|
105
|
+
something, happens, to, them, dot,
|
106
|
+
something, happens, to, these, things, or_, people, dot
|
107
|
+
]
|
108
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should parse sample sentences from lesson 3-B' do
|
112
|
+
# Sentence 3-05a definiendum: 'This is its X.'
|
113
|
+
literals = [this_as_pronoun, is, its, x_as_noun, dot
|
114
|
+
]
|
115
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
116
|
+
|
117
|
+
# Sentence 3-05b definiens: 'This X belongs to it.
|
118
|
+
# [I saw this thing and touched some of its parts.]
|
119
|
+
# [These things are their things.] = These things belong to them.
|
120
|
+
literals = [this, x_as_noun, belongs, to, it_, dot,
|
121
|
+
i_pronoun, saw, this, thing, and_, touched, some, of, its, parts, dot
|
122
|
+
]
|
123
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
124
|
+
|
125
|
+
# Sentence 3-05c definiendum: 'These things are their things.'
|
126
|
+
literals = [these, things, are, their, things, dot
|
127
|
+
]
|
128
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
129
|
+
|
130
|
+
# Sentence 3-05d definiens: 'These things belong to them.
|
131
|
+
literals = [these, things, belong, to, them, dot]
|
132
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
133
|
+
|
134
|
+
# Sentence 3-06a definiendum: 'This is your X.'
|
135
|
+
literals = [this_as_pronoun, is, your, x_as_noun, dot]
|
136
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
137
|
+
|
138
|
+
# Sentence 3-06b definien: 'This X belongs to you.
|
139
|
+
# [You feel something touching your body.]
|
140
|
+
literals = [this, x_as_noun, belongs, to, you, dot,
|
141
|
+
you, feel, something, touching, your, body, dot
|
142
|
+
]
|
143
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
144
|
+
|
145
|
+
# Sentence 3-07a definiendum: 'This is my X.'
|
146
|
+
literals = [this_as_pronoun, is, my, x_as_noun, dot,
|
147
|
+
]
|
148
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
149
|
+
|
150
|
+
# Sentence 3-07b definiens: 'This X belongs to me.
|
151
|
+
# [I do not want you to touch my body.]
|
152
|
+
literals = [this, x_as_noun, belongs, to, me, dot,
|
153
|
+
i_pronoun, do_aux, not_, want, to, touch, my, body, dot
|
154
|
+
]
|
155
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
156
|
+
|
157
|
+
# Sentence 3-08a definiendum: 'There is an X here.'
|
158
|
+
literals = [there, is, an, x_as_noun, here, dot]
|
159
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
160
|
+
|
161
|
+
# Sentence 3-08b definiens: 'X is some kind of thing.
|
162
|
+
# There is one of this kind of thing here.
|
163
|
+
# This is not one that you said something about a short time before now.
|
164
|
+
# [I did not know there was a person in this place.]
|
165
|
+
literals = [x_as_noun, is, some, kind, of, thing, dot,
|
166
|
+
there, is, one, of, this, kind, of, thing, here, dot,
|
167
|
+
this_as_pronoun, is, not_, one_as_adj, that, you, said, something,
|
168
|
+
about, a_as_art, short, time, before_as_adj, now_as_noun, dot
|
169
|
+
]
|
170
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
171
|
+
|
172
|
+
# Sentence 3-Bxa 'Lisa sees a living thing that is very big.
|
173
|
+
# Lisa says: "I see one living thing. Its body is bigger than my body.", dot
|
174
|
+
literals = [
|
175
|
+
lisa, sees, a_as_art, living, thing, that, is, very, big, dot,
|
176
|
+
lisa, says, colon, quote, i_pronoun, see, one, living, thing, dot,
|
177
|
+
its, body, is, bigger, than, my, body, dot, quote, dot
|
178
|
+
]
|
179
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should parse sample sentences from lesson 3-C' do
|
183
|
+
# Sentence 3-09a definiendum: 'Something happens to the X.'
|
184
|
+
literals = [something, happens, to, the, x_as_noun, dot]
|
185
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
186
|
+
|
187
|
+
# Sentence 3-09b definiens: Something happens to X.
|
188
|
+
# This is the same X that someone said something about a short time before,
|
189
|
+
# or there is not another thing that is the same kind as X.
|
190
|
+
# [I saw two people here before, and now I do not see the people.]
|
191
|
+
literals = [something, happens, to, x_as_noun, dot,
|
192
|
+
this_as_pronoun, is, the, same, x_as_noun, that, someone, said, something, about,
|
193
|
+
a_as_art, short, time, before_as_adj, comma,
|
194
|
+
or_, there, is, not_, another, thing, that, is, the, same, kind,
|
195
|
+
as, x_as_noun, dot,
|
196
|
+
i_pronoun, saw, two, people, here, before_adverb, comma,
|
197
|
+
and_, now, i_pronoun, do_aux, not_, see, the, people, dot
|
198
|
+
]
|
199
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
200
|
+
|
201
|
+
# Sentence 3-10a definiendum: 'X is an animal.'
|
202
|
+
literals = [x_as_noun, is, an, animal, dot]
|
203
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
204
|
+
|
205
|
+
# Sentence 3-10b definiens: There are many kinds of living things
|
206
|
+
# that can feel and can move when they want. X is one of these.
|
207
|
+
# [The animal moved when someone touched its body.]
|
208
|
+
literals = [ there, are, many, kinds, of, living, things,
|
209
|
+
that, can, feel, and_, can, move, when_, they, want, dot,
|
210
|
+
x_as_noun, is, one, of, these_as_pronoun, dot,
|
211
|
+
the, animal, moved, when_, someone, touched, its, body, dot
|
212
|
+
]
|
213
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
214
|
+
|
215
|
+
# Sentence 3-11a definiendum: 'J causes K to happen.'
|
216
|
+
literals = [j_, causes, k_, to, happen, dot]
|
217
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
218
|
+
|
219
|
+
# Sentence 3-11b definiens: K happens because J happens
|
220
|
+
# or because J does something.
|
221
|
+
# [Someone bad caused these people to die.]
|
222
|
+
literals = [ k_, happens, because, j_, happens,
|
223
|
+
or_, because, j_, does, something, dot,
|
224
|
+
something, bad, caused, these, people, to, die, dot
|
225
|
+
]
|
226
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
227
|
+
|
228
|
+
# Sentence 3-12a definiendum: 'J is true, but K is not true.'
|
229
|
+
literals = [j_, is, true_, comma, but, k_, is, not_, true_, dot]
|
230
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
231
|
+
|
232
|
+
# Sentence 3-12b definiens: You say J is true.
|
233
|
+
# Maybe when some people hear J is true,
|
234
|
+
# they think K is true because of this.
|
235
|
+
# You want them to know K is not true, and you say this.
|
236
|
+
# [I hear Tony, but I do not see Tony.]
|
237
|
+
literals = [ maybe, when_, some, people, hear, j_, is, true_, comma,
|
238
|
+
they, think, k_, is, true_, because, of, this_as_pronoun, dot,
|
239
|
+
you, want, them, to, know, k_, is, not_, true_, comma,
|
240
|
+
and_, you, say, this_as_pronoun, dot,
|
241
|
+
i_pronoun, hear, tony, comma, but, i_pronoun, do_aux, not_, see, lisa, dot
|
242
|
+
]
|
243
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
244
|
+
|
245
|
+
# Sentence 3-C Xtra Lisa says: "I can hear an animal, but I do not see it."
|
246
|
+
# Tony says: "I can see the animal that you hear.".
|
247
|
+
literals = [ lisa, says, colon, quote, i_pronoun, can, hear, an,
|
248
|
+
animal, comma, but, i_pronoun, do_aux, not_, see, it_, dot, quote,
|
249
|
+
dot, tony, says, colon, quote, i_pronoun, can, see, the, animal,
|
250
|
+
that, you, hear, dot, quote, dot
|
251
|
+
]
|
252
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should parse sample sentences from lesson 3-D' do
|
256
|
+
# Sentence 3-13a definiendum: 'You use this thing.'
|
257
|
+
literals = [you, use, this, thing, dot]
|
258
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
259
|
+
|
260
|
+
# Sentence 3-13b definiens: You do something with this thing
|
261
|
+
# because you think this can cause something to happen that you want.
|
262
|
+
# [I used something big to cause people far from here to see me.]
|
263
|
+
literals = [ you, do_, something, with, this, thing, because, you,
|
264
|
+
think, this_as_pronoun, can, cause, something, to, happen,
|
265
|
+
that, you, want, dot,
|
266
|
+
i_pronoun, used, something, big, to, cause, people, far, from,
|
267
|
+
here_as_noun, to, see, me, dot
|
268
|
+
]
|
269
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
270
|
+
|
271
|
+
# Sentence 3-14a definiendum: 'You know X about each of these things.'
|
272
|
+
literals = [you, know, x_as_noun, about, each_, of, these, things, dot]
|
273
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
274
|
+
|
275
|
+
# Sentence 3-14b definiens: There are two or more things.
|
276
|
+
# You think about all these things like this:
|
277
|
+
# If something is one of these things, then you know X about it.
|
278
|
+
# [Each person here said something to me.]
|
279
|
+
# because you think this can cause something to happen that you want.
|
280
|
+
# [I used something big to cause people far from here to see me.]
|
281
|
+
literals = [ there, are, two, or_, more, things, dot,
|
282
|
+
you, think, about, all, these, things, like, this_as_pronoun, colon,
|
283
|
+
if_, something, is, one, of, these, things, comma,
|
284
|
+
then_, you, know, x_as_noun, about, it_, dot,
|
285
|
+
each_, person, here, said, something, to, me, dot
|
286
|
+
]
|
287
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
288
|
+
|
289
|
+
# Sentence 3-15a definiendum: 'Someplace an X exists.'
|
290
|
+
literals = [someplace, an, x_as_noun, exists, dot]
|
291
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
292
|
+
|
293
|
+
# Sentence 3-15b definiens: Someplace there is an X,
|
294
|
+
# or someplace an X is alive.
|
295
|
+
# [This kind of thing did not exist before this time.]
|
296
|
+
literals = [ someplace, there, is, an, x_as_noun, comma,
|
297
|
+
or_, someplace, an, x_as_noun, is, alive, dot,
|
298
|
+
this, kind, of, thing, did, not_, exist, before, this, time, dot]
|
299
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
300
|
+
|
301
|
+
# Sentence 3-16a definiendum: 'J became K.'
|
302
|
+
literals = [j_, became, k_, dot]
|
303
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
304
|
+
|
305
|
+
# Sentence 3-16b definiens: Something happened to J for some time.
|
306
|
+
# After this happened, K is something true you can know about J.
|
307
|
+
# But before this happened, K was not true.
|
308
|
+
# [These two animals were small before, but they became big.]
|
309
|
+
literals = [ something, happened, to, j_, for_, some, time, dot,
|
310
|
+
after_, this_as_pronoun, happened, comma, k_, is, something, true_,
|
311
|
+
you, can, know, about, j_, dot,
|
312
|
+
these, two, animals, were, small, before_adverb, comma,
|
313
|
+
but, they, became, big, dot
|
314
|
+
]
|
315
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
316
|
+
|
317
|
+
# Sentence 3-Dx: There are some animals here.
|
318
|
+
# Each of these animals was small when it existed a short time.
|
319
|
+
# After a long time, each of these animals became big.
|
320
|
+
literals = [there, are, some, animal, here, dot,
|
321
|
+
each_, of, these, animals, was, small, when_, it_,
|
322
|
+
existed, a_as_art, short, time, dot,
|
323
|
+
after_, a_as_art, long, time, comma, each_, of, these, animals,
|
324
|
+
became, big, dot
|
325
|
+
]
|
326
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'should parse sample sentences from lesson 3-E' do
|
330
|
+
# Sentence 3-17a definiendum: 'These things are different.'
|
331
|
+
literals = [things, are, different, dot]
|
332
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
333
|
+
|
334
|
+
# Sentence 3-17b definiens: These things are not the same.
|
335
|
+
# [I want this kind of thing, but you want something different.]
|
336
|
+
literals = [ these, things, are, not_, the, same_as_pronoun, dot,
|
337
|
+
i_pronoun, want, this, kind, of, thing, comma,
|
338
|
+
but, you, want, something, different, dot
|
339
|
+
]
|
340
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
341
|
+
|
342
|
+
# Sentence 3-18a definiendum: 'J made K.'
|
343
|
+
literals = [j_, made, k_, dot]
|
344
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
345
|
+
|
346
|
+
# Sentence 3-18b definiens: J did something to some things
|
347
|
+
# and caused them to become parts of one different
|
348
|
+
# kind of thing that was not here before.
|
349
|
+
# K is this thing that now exists because of this.
|
350
|
+
# [I used many small things to make this big thing.]
|
351
|
+
# [J made K happen.] = J caused K to happen.
|
352
|
+
literals = [ j_, did, something, to, some, things, and_,
|
353
|
+
caused, them, to, become, parts, of, one, different, kind, of,
|
354
|
+
thing, that, was, not_, here, before_adverb, dot,
|
355
|
+
k_, is, this, thing, that, now, exists, because, of, this_as_pronoun, dot,
|
356
|
+
i_pronoun, used, many, small, things, to, make, this, big, thing, dot,
|
357
|
+
j_, made, k_, happen, dot,
|
358
|
+
j_, caused, k_, to, happen, dot
|
359
|
+
]
|
360
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
361
|
+
|
362
|
+
# Sentence 3-19a definiendum: 'J contains K.'
|
363
|
+
literals = [j_, contains, k_, dot]
|
364
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
365
|
+
|
366
|
+
# Sentence 3-19b definiens: K is inside J.
|
367
|
+
# [I made something to contain all these small things.]
|
368
|
+
# [Your body contains many parts.]
|
369
|
+
literals = [ k_, is, inside, j_, dot,
|
370
|
+
i_pronoun, made, something, to, contain, all, these, small, things, dot,
|
371
|
+
your, body, contains, many, parts, dot,
|
372
|
+
]
|
373
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
374
|
+
|
375
|
+
# Sentence 3-20a definiendum: 'X is a container.'
|
376
|
+
literals = [x_as_noun, is, a_as_art, container, dot]
|
377
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
378
|
+
|
379
|
+
# Sentence 3-20b definiens: X is something that people make because
|
380
|
+
# they want to use it to contain other things.
|
381
|
+
# [There are two things inside this container.]
|
382
|
+
literals = [ x_as_noun, is, something, that, people, make, because,
|
383
|
+
they, want, to, use, it_, to, contain, other, things, dot,
|
384
|
+
there, are, two, things, inside, this, container, dot
|
385
|
+
]
|
386
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
387
|
+
|
388
|
+
# Sentence 3-Extra: Someone made these containers.
|
389
|
+
# Each contains a different kind of animal.
|
390
|
+
literals = [someone, made, these, containers, dot,
|
391
|
+
each_as_pronoun, contains, a_as_art, different, kind, of, animal, dot
|
392
|
+
]
|
393
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
394
|
+
end
|
395
|
+
it 'should parse sample sentences from lesson 3-F' do
|
396
|
+
# Sentence 3-21a definiendum: 'You try to do X.'
|
397
|
+
literals = [you, try_, to, do_, x_as_noun, dot]
|
398
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
399
|
+
|
400
|
+
# Sentence 3-21b definiens: Because you want X to happen,
|
401
|
+
# you do things that you think can cause X to happen.
|
402
|
+
# [I tried to do something good.]
|
403
|
+
literals = [ because, you, want, x_as_noun, to, happen, comma,
|
404
|
+
you, do_, things, that, you, think, can, cause, x_as_noun,
|
405
|
+
to, happen, dot,
|
406
|
+
i_pronoun, tried, to, do_, something, good, dot
|
407
|
+
]
|
408
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
409
|
+
|
410
|
+
# Sentence 3-22a definiendum: 'X changed.'
|
411
|
+
literals = [x_as_noun, changed, dot]
|
412
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
413
|
+
|
414
|
+
# Sentence 3-22b definiens: Something happened to X.
|
415
|
+
# Because of this, X is not the same as before.
|
416
|
+
# [After this kind of animal is alive for some time, its body changes.]
|
417
|
+
literals = [ something, happened, to, x_as_noun, dot,
|
418
|
+
because, of, this_as_pronoun, comma, x_as_noun, is, not_, the, same_as_pronoun,
|
419
|
+
as, before_adverb, dot,
|
420
|
+
after_, this, kind, of, animal, is, alive, for_, some, time, comma,
|
421
|
+
its, body, changes, dot
|
422
|
+
]
|
423
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
424
|
+
|
425
|
+
# Sentence 3-22c definiendum: 'J changed K.'
|
426
|
+
literals = [j_, changed, k_, dot]
|
427
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
428
|
+
|
429
|
+
# Sentence 3-22d definiens: J caused K to change.
|
430
|
+
# Because of this, X is not the same as before.
|
431
|
+
# [When these people did something bad, it changed what I thought about them.]
|
432
|
+
literals = [ j_, caused, k_, to, change_, dot,
|
433
|
+
when_, these, people, did, something, bad, comma,
|
434
|
+
it_, changed, what, i_pronoun, thought, about, them, dot
|
435
|
+
]
|
436
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
437
|
+
|
438
|
+
# Sentence 3-23a definiendum: 'You see the surface of X.'
|
439
|
+
literals = [you, see, the, surface, of, x_as_noun, dot]
|
440
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
441
|
+
|
442
|
+
# Sentence 3-23b definiens: You see part of X.
|
443
|
+
# This part is where other things can touch X.
|
444
|
+
# [I can see the surface of this thing, but I cannot see what is inside.]
|
445
|
+
# [When I touched this thing, I could feel parts of it moving below its surface.]
|
446
|
+
# comment: `where` word was implicitly defined in section 1-25.
|
447
|
+
# `could` verb was implicitly defined in section 2-10.
|
448
|
+
literals = [ i_pronoun, can, see, the, surface, of, this, thing, comma,
|
449
|
+
but, i_pronoun, can, not_, see, what, is, inside, dot,
|
450
|
+
when_, i_pronoun, touched, this, thing, comma, i_pronoun, could,
|
451
|
+
feel, parts, of, it_, moving, below, its, surface, dot
|
452
|
+
]
|
453
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
454
|
+
|
455
|
+
# Sentence 3-23c definiendum: 'J is on the surface of K.'
|
456
|
+
literals = [j_, is, on, the, surface, of, k_, dot]
|
457
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
458
|
+
|
459
|
+
# Sentence 3-23d definiens: J is touching the surface of K.
|
460
|
+
literals = [ j_, is, touching, the, surface, of, k_, dot]
|
461
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
462
|
+
|
463
|
+
# Sentence 3-F xtra: Tony wants to know what is inside this container.
|
464
|
+
# Tony tries to touch things inside the container.
|
465
|
+
literals = [ tony, wants, to, know, what, is, inside, this, container, dot,
|
466
|
+
tony, tries, to, touch, things, inside, the, container, dot
|
467
|
+
]
|
468
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
469
|
+
end
|
470
|
+
end # context
|
471
|
+
end # describe
|
472
|
+
end # module
|
473
|
+
end # module
|