zenlish 0.1.23 → 0.1.24
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/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,503 @@
|
|
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 2:' do
|
14
|
+
it 'should parse sample sentences from lesson 2-A' do
|
15
|
+
# Sentence 2-01a: "This thing is like two of the other things."
|
16
|
+
literals = [this, thing, is, like, two, of, the, other, things, dot]
|
17
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
18
|
+
|
19
|
+
# Sentence 2-01b: "One of these things is not like the other things."
|
20
|
+
literals = [one, of, these, things, is, not_, like, the, other, things, dot]
|
21
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
22
|
+
|
23
|
+
# Sentence 2-02a: "Lisa has something."
|
24
|
+
literals = [lisa, has, something, dot]
|
25
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
26
|
+
|
27
|
+
# Sentence 2-02b: "Tony has another thing."
|
28
|
+
literals = [tony, has, another, thing, dot]
|
29
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
30
|
+
|
31
|
+
# Sentence 2-02c: "Lisa does not have the same kind of thing as Tony has."
|
32
|
+
literals = [lisa, does_aux, not_, have, the, same, kind, of, thing, as, tony, has, dot]
|
33
|
+
# Ambiguous parse
|
34
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
35
|
+
|
36
|
+
# Sentence 2-03a: "Lisa is touching part of this thing."
|
37
|
+
literals = [lisa, is_aux, touching, part, of, this, thing, dot]
|
38
|
+
# Ambiguous parse
|
39
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
40
|
+
|
41
|
+
# Sentence 2-03b: "Tony is touching the other part."
|
42
|
+
literals = [tony, is_aux, touching, the, other, part, dot]
|
43
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
44
|
+
|
45
|
+
# Sentence 2-Ax: "What Tony has is like what Lisa has."
|
46
|
+
literals = [what, tony, has, is, like, what, lisa, has, dot]
|
47
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should parse sample sentences from lesson 2-B' do
|
51
|
+
# Sentence 2-04a: "Lisa does something."
|
52
|
+
literals = [lisa, does, something, dot]
|
53
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
54
|
+
|
55
|
+
# Sentence 2-04b: "Lisa does something with this thing."
|
56
|
+
literals = [lisa, does, something, with, this, thing, dot]
|
57
|
+
# Ambiguous parse
|
58
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
59
|
+
|
60
|
+
# Sentence 2-04c: "Lisa does something to Tony."
|
61
|
+
literals = [lisa, does, something, to, tony, dot]
|
62
|
+
# Ambiguous parse
|
63
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
64
|
+
|
65
|
+
# Sentence 2-04d: "Lisa does something to Tony with this thing."
|
66
|
+
literals = [lisa, does, something, to, tony, with, this, thing, dot]
|
67
|
+
# Ambiguous parse
|
68
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
69
|
+
|
70
|
+
# Sentence 2-05a: "Something happens."
|
71
|
+
literals = [something, happens, dot]
|
72
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
73
|
+
|
74
|
+
# Sentence 2-05b: "Something happens to Lisa."
|
75
|
+
literals = [something, happens, to, lisa, dot]
|
76
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
77
|
+
|
78
|
+
# Sentence 2-06a: "Tony does something."
|
79
|
+
literals = [tony, does, something, dot]
|
80
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
81
|
+
|
82
|
+
# Sentence 2-06b: "Something happens to Lisa because of this."
|
83
|
+
literals = [something, happens, to, lisa, because, of, this_as_pronoun, dot]
|
84
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
85
|
+
|
86
|
+
# Sentence 2-06c: "Something happens to Lisa because Tony does this."
|
87
|
+
literals = [something, happens, to, lisa, because, tony, does, this_as_pronoun, dot]
|
88
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
89
|
+
|
90
|
+
# Sentence 2-06: "Something happens to this living thing."
|
91
|
+
literals = [something, happens, to, this, living, thing, dot]
|
92
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should parse sample sentences from lesson 2-C' do
|
96
|
+
# Sentence 2-07a: "Lisa thinks Tony is inside this thing."
|
97
|
+
literals = [lisa, thinks, tony, is, inside, this, thing, dot]
|
98
|
+
# Ambiguous parse
|
99
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
100
|
+
|
101
|
+
# Sentence 2-07b: "Lisa thinks something about Tony."
|
102
|
+
literals = [lisa, thinks, something, about, tony, dot]
|
103
|
+
# Ambiguous parse
|
104
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
105
|
+
|
106
|
+
# Sentence 2-08a: "Tony knows Lisa is inside this thing, because Tony sees Lisa inside."
|
107
|
+
literals = [tony, knows, lisa, is, inside, this, thing, comma,
|
108
|
+
because, tony, sees, lisa, inside, dot]
|
109
|
+
# Ambiguous parse
|
110
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
111
|
+
|
112
|
+
# Sentence 2-08b: "Tony knows something about Lisa."
|
113
|
+
literals = [tony, knows, something, about, lisa, dot]
|
114
|
+
# Ambiguous parse
|
115
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
116
|
+
|
117
|
+
# Sentence 2-09a: "Tony wants this thing."
|
118
|
+
literals = [tony, wants, this, thing, dot]
|
119
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
120
|
+
|
121
|
+
# Sentence 2-09b: "Tony wants to have this thing."
|
122
|
+
literals = [tony, wants, to, have, this, thing, dot]
|
123
|
+
# Ambiguous parse
|
124
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
125
|
+
|
126
|
+
# Sentence 2-10a: "Tony wants to do something."
|
127
|
+
literals = [tony, wants, to, do_, something, dot]
|
128
|
+
# Ambiguous parse
|
129
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
130
|
+
|
131
|
+
# Sentence 2-10b: "Lisa wants to do the same thing."
|
132
|
+
literals = [lisa, wants, to, do_, the, same, thing, dot]
|
133
|
+
# Ambiguous parse
|
134
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
135
|
+
|
136
|
+
# Sentence 2-10c: "Tony can do this."
|
137
|
+
literals = [tony, can, do_, this_as_pronoun, dot]
|
138
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
139
|
+
|
140
|
+
# Sentence 2-10d: "This is not something Lisa can do."
|
141
|
+
literals = [this_as_pronoun, is, not_, something, lisa, can, do_, dot]
|
142
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
143
|
+
|
144
|
+
# Sentence 2-10e: "Lisa cannot do this."
|
145
|
+
literals = [lisa, can, not_, do_, this_as_pronoun, dot]
|
146
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should parse sample sentences from lesson 2-D' do
|
150
|
+
# Sentence 2-11a: "This person does something bad."
|
151
|
+
literals = [this, person, does, something, bad, dot]
|
152
|
+
# Ambiguous parse
|
153
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
154
|
+
|
155
|
+
# Sentence 2-11b: "This person does something bad for Tony."
|
156
|
+
literals = [this, person, does, something, bad, for_, tony, dot]
|
157
|
+
# Ambiguous parse
|
158
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
159
|
+
|
160
|
+
# Sentence 2-12a: "Tony does something good."
|
161
|
+
literals = [tony, does, something, good, dot]
|
162
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
163
|
+
|
164
|
+
# Sentence 2-12b: "Tony does something good for Lisa."
|
165
|
+
literals = [tony, does, something, good, for_, lisa, dot]
|
166
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
167
|
+
|
168
|
+
# Sentence 2-13a: "Tony feels something."
|
169
|
+
literals = [tony, feels, something, dot]
|
170
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
171
|
+
|
172
|
+
# Sentence 2-13b: "This does not feel good for Tony."
|
173
|
+
literals = [this_as_pronoun, does_aux, not_, feel, good, for_, tony, dot]
|
174
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
175
|
+
|
176
|
+
# Sentence 2-13b: "This feels bad for Tony."
|
177
|
+
literals = [this_as_pronoun, feels, bad, for_, tony, dot]
|
178
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
179
|
+
|
180
|
+
# Sentence 2-Dx: "Lisa thinks about something bad happening to this
|
181
|
+
# living thing. Thinking about this feels bad for Lisa."
|
182
|
+
literals = [lisa, thinks, about, something, bad, happening, to, this,
|
183
|
+
living, thing, dot,
|
184
|
+
#thinking, about, this_as_pronoun, feels, bad,
|
185
|
+
#for_, lisa, dot
|
186
|
+
]
|
187
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should parse sample sentences from lesson 2-E' do
|
191
|
+
# Sentence 2-14a: "Lisa says something at this time."
|
192
|
+
literals = [lisa, says, something, at, this, time, dot]
|
193
|
+
# Ambiguous parse
|
194
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
195
|
+
|
196
|
+
# Sentence 2-14b: "Tony is not in this place at this time."
|
197
|
+
literals = [tony, is, not_, in_, this, place, at, this, time, dot]
|
198
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
199
|
+
|
200
|
+
# Sentence 2-15a: "At one time, Tony does something to this thing."
|
201
|
+
literals = [at, one, time, comma, tony, does, something, to, this, thing, dot]
|
202
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
203
|
+
|
204
|
+
# Sentence 2-15b: "At another time, Lisa says something."
|
205
|
+
literals = [at, another, time, comma, lisa, says, something, dot]
|
206
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
207
|
+
|
208
|
+
# Sentence 2-15c: "Tony does something to this thing before Lisa says something."
|
209
|
+
literals = [tony, does, something, to, this, thing, before, lisa, says, something, dot]
|
210
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
211
|
+
|
212
|
+
# Sentence 2-16a: "Lisa does something for a long time."
|
213
|
+
literals = [lisa, does, something, for_, a_as_art, long, time, dot]
|
214
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
215
|
+
|
216
|
+
# Sentence 2-17a: "Tony does something for a short time."
|
217
|
+
literals = [tony, does, something, for_, a_as_art, short, time, dot]
|
218
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
219
|
+
|
220
|
+
# Sentence 2-17a: "Tony does not do this for a long time."
|
221
|
+
literals = [tony, does_aux, not_, do_, this_as_pronoun, for_, a_as_art, long, time, dot]
|
222
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
223
|
+
|
224
|
+
# Sentence 2-18a: "Lisa sees something move."
|
225
|
+
literals = [lisa, sees, something, move, dot]
|
226
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
227
|
+
|
228
|
+
# Sentence 2-18a: "Lisa moves near to this thing."
|
229
|
+
literals = [lisa, moves, near_to, this, thing, dot]
|
230
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
231
|
+
|
232
|
+
# Sentence 2-E-Xa: "A short time before, Tony was far from Lisa."
|
233
|
+
# Case of a time adverbial adjunct that is put in front position.
|
234
|
+
literals = [a_as_art, short, time, before_adverb, comma, tony, was, far, from, lisa, dot]
|
235
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
236
|
+
|
237
|
+
# Sentence 2-E-Xa: "At this time, Tony is near to Lisa"
|
238
|
+
literals = [at, this, time, comma, tony, is, near_to, lisa, dot]
|
239
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
240
|
+
|
241
|
+
# Sentence 2-E-Xa: "Tony is near to Lisa because Tony moved"
|
242
|
+
# Case of a time adverbial adjunct that is put in front position.
|
243
|
+
literals = [tony, is, near_to, lisa, because, tony, moved, dot]
|
244
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should parse sample sentences from lesson 2-F' do
|
248
|
+
# Sentence 2-19a: 'Tony says: "I did X.".'
|
249
|
+
literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
|
250
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
251
|
+
|
252
|
+
# Sentence 2-19a definiendum: 'Tony says: "I did X.".'
|
253
|
+
literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
|
254
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
255
|
+
|
256
|
+
# Sentence 2-19a definiens: 'Tony says something about Tony. Tony says: Tony did X.'
|
257
|
+
literals = [tony, says, something, about, tony, dot,
|
258
|
+
tony, says, colon, tony, did, x_as_noun, dot]
|
259
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
260
|
+
|
261
|
+
# Sentence 2-19a: 'Tony says: "I see Lisa.".'
|
262
|
+
literals = [tony, says, colon, quote, i_pronoun, see, lisa, dot, quote, dot]
|
263
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
264
|
+
|
265
|
+
# Sentence 2-19b definiendum: 'Lisa says: "X happened to me.".'
|
266
|
+
literals = [lisa, says, colon, quote, x_as_noun, happened, to, me, dot, quote, dot]
|
267
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
268
|
+
|
269
|
+
# Sentence 2-19b definiens: 'Lisa says something about Lisa. Lisa says: X happened to Lisa.'
|
270
|
+
literals = [lisa, says, something, about, lisa, dot,
|
271
|
+
lisa, says, colon, x_as_noun, happened, to, lisa, dot]
|
272
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
273
|
+
|
274
|
+
# Sentence 2-19c: 'Lisa says: "Tony sees me."'
|
275
|
+
literals = [lisa, says, colon, quote, tony, sees, me, dot, quote, dot]
|
276
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
277
|
+
|
278
|
+
# Sentence 2-20a definiendum: 'Tony says to Lisa: "I can see you.".'
|
279
|
+
literals = [tony, says, to, lisa, colon, quote, i_pronoun, can, see, you, dot, quote, dot]
|
280
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
281
|
+
|
282
|
+
# Sentence 2-20a definiens: 'Tony says something about Lisa.
|
283
|
+
# Tony says this to Lisa. Tony says: Tony can see Lisa.'
|
284
|
+
literals = [tony, says, something, about, lisa, dot,
|
285
|
+
tony, says, this_as_pronoun, to, lisa, dot,
|
286
|
+
tony, says, colon, tony, can, see, lisa, dot]
|
287
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
288
|
+
|
289
|
+
# Sentence 2-20b: "I know you have something good."
|
290
|
+
literals = [i_pronoun, know, you, have, something, good, dot]
|
291
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
292
|
+
|
293
|
+
# Sentence 2-20c: "I want you to do something good for me."
|
294
|
+
literals = [i_pronoun, want, you, to, do_, something, good, for_, me, dot]
|
295
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
296
|
+
|
297
|
+
# Sentence 2-21a definiendum: 'Tony says: "X happens here.".'
|
298
|
+
literals = [tony, says, colon, quote, x_as_noun, happens, here, dot, quote, dot]
|
299
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
300
|
+
|
301
|
+
# Sentence 2-21a definiens: "Tony is in a place. Tony says: X happens in this place."
|
302
|
+
literals = [tony, is, in_, a_as_art, place, dot,
|
303
|
+
tony, says, colon, x_as_noun, happens, in_, this, place, dot]
|
304
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
305
|
+
|
306
|
+
# Sentence 2-21b: "Many people were here at one time."
|
307
|
+
literals = [many, people, were, here, at, one, time, dot]
|
308
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
309
|
+
|
310
|
+
# Sentence 2-22a definiendum: 'Lisa says: "X happens now.".'
|
311
|
+
literals = [lisa, says, colon, quote, x_as_noun, happens, now, dot, quote, dot]
|
312
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
313
|
+
|
314
|
+
# Sentence 2-22a definiens: 'Lisa says something at a time.
|
315
|
+
# Lisa says: X happens at this same time.'
|
316
|
+
literals = [lisa, says, something, at, a_as_art, time, dot,
|
317
|
+
lisa, says, colon, x_as_noun, happens, at, this, time, dot]
|
318
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
319
|
+
|
320
|
+
# Sentence 2-22b: "There are not many people here now."
|
321
|
+
literals = [there, are, not_, many, people, here, now , dot]
|
322
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
323
|
+
|
324
|
+
# Sentence 2-Fa: "Lisa says to Tony: "I can see many living things here."."
|
325
|
+
literals = [lisa, says, to, tony, colon, quote, i_pronoun,
|
326
|
+
can, see, many, living, things, here, dot, quote, dot]
|
327
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should parse sample sentences from lesson 2-G' do
|
331
|
+
# Sentence 2-23a definiendum: 'Someone does X.'
|
332
|
+
literals = [someone, does, x_as_noun, dot]
|
333
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
334
|
+
|
335
|
+
# Sentence 2-23a definiens: 'Something does X. This something can
|
336
|
+
# think like people think. This something can be one person.'
|
337
|
+
literals = [something, does, x_as_noun, dot,
|
338
|
+
this, something, can, think, like, people, think, dot,
|
339
|
+
this, something, can, be_, a_as_art, person, dot]
|
340
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
341
|
+
|
342
|
+
# Sentence 2-23b: Someone said something to Tony.
|
343
|
+
literals = [someone, said, something, to, tony, dot]
|
344
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
345
|
+
|
346
|
+
# Sentence 2-23c definiendum: 'J knows who did K.'
|
347
|
+
literals = [j_, knows, who, did, k_, dot]
|
348
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
349
|
+
|
350
|
+
# Sentence 2-23c definiens: J thinks about someone.
|
351
|
+
# J knows this someone did K.
|
352
|
+
literals = [j_, thinks, about, someone, dot,
|
353
|
+
j_, knows, this, someone, did, k_, dot]
|
354
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
355
|
+
|
356
|
+
# Sentence 2-23d: Tony knows who said something.
|
357
|
+
literals = [tony, knows, who, said, something, dot]
|
358
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
359
|
+
|
360
|
+
# Sentence 2-24a definiendum: 'J happens after K happens.'
|
361
|
+
literals = [j_, happens, after_, k_, happens, dot]
|
362
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
363
|
+
|
364
|
+
# Sentence 2-24a definiens: K happens before J happens.
|
365
|
+
literals = [k_, happens, before, j_, happens, dot]
|
366
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
367
|
+
|
368
|
+
# Sentence 2-24b: After you do something for a long time,
|
369
|
+
# you can know much more about this.
|
370
|
+
literals = [after_, you, do_, something, for_, a_as_art, long, time,
|
371
|
+
comma, you, can, know, much, more_as_adverb, about, this_as_pronoun, dot]
|
372
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
373
|
+
|
374
|
+
# Sentence 2-25a definiendum: 'X is true for some time.'
|
375
|
+
literals = [x_as_noun, is, true_, for_, some, time, dot]
|
376
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
377
|
+
|
378
|
+
# Sentence 2-25a definiens: X is true at a time.
|
379
|
+
# Some parts of this one time happen before other parts.
|
380
|
+
# Some parts of this one time happen after other parts.
|
381
|
+
# X is true at all parts of this one time.
|
382
|
+
literals = [x_as_noun, is, true_, at, a_as_art, time, dot,
|
383
|
+
some, parts, of, this, one, time, happen, before_adverb, other, parts, dot,
|
384
|
+
some, parts, of, this, one, time, happen, after_adverb, other, parts, dot,
|
385
|
+
x_as_noun, is, true_, at, all, parts, of, this, one, time, dot]
|
386
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
387
|
+
|
388
|
+
# Sentence 2-25b: After I moved for some time,
|
389
|
+
# I was near the other side of this place.
|
390
|
+
literals = [after_, i_pronoun, moved, for_, some, time,
|
391
|
+
comma, i_pronoun, was, near, the, other, side, of, this, place, dot]
|
392
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
393
|
+
|
394
|
+
# Sentence 2-26a definiendum: 'X happens in a moment.'
|
395
|
+
literals = [x_as_noun, happens, in_, a_as_art, moment, dot]
|
396
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
397
|
+
|
398
|
+
# Sentence 2-26a definiens: X happens for one very short time.
|
399
|
+
# There are not parts of this very short time when one part
|
400
|
+
# happens before other parts.
|
401
|
+
literals = [x_as_noun, happens, for_, one, very, short, time, dot,
|
402
|
+
there, are, not_, parts, of, this, very, short, time, when_,
|
403
|
+
one, part, happens, before_adverb, other, part, dot]
|
404
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
405
|
+
|
406
|
+
# Sentence 2-26b: In a moment, I knew something here was not good.
|
407
|
+
# 'here' is adverb that modifies the 'knew' verb
|
408
|
+
literals = [in_, a_as_art, moment, comma, i_pronoun, knew, something,
|
409
|
+
here, was, not_, good, dot ]
|
410
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
411
|
+
|
412
|
+
# Sentence 2-Gx: Tony is inside this thing for some time.
|
413
|
+
# Lisa says: "I want to know who is inside this thing.".
|
414
|
+
# Tony hears Lisa. Because of this, Tony says: "I am inside.".
|
415
|
+
# Tony says this after Tony hears Lisa.
|
416
|
+
literals = [tony, is, inside, this, thing, for_, some, time, dot,
|
417
|
+
lisa, says, colon, quote, i_pronoun, want, to, know, who, is,
|
418
|
+
inside, this, thing, dot, quote, dot, tony, hears, lisa, dot,
|
419
|
+
because, of, this_as_pronoun, comma, tony, says, colon,
|
420
|
+
quote, i_pronoun, am, inside, dot, quote, dot,
|
421
|
+
tony, says, this_as_pronoun, after_, tony, hears, lisa, dot]
|
422
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
423
|
+
end
|
424
|
+
|
425
|
+
it 'should parse sample sentences from lesson 2-H' do
|
426
|
+
# Sentence 2-27a definiendum: 'X is the body of this person.'
|
427
|
+
literals = [x_as_noun, is, the, body, of, this, person, dot]
|
428
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
429
|
+
|
430
|
+
# Sentence 2-27b "Parts of this person can touch other things.
|
431
|
+
# Parts of this person can touch other parts inside this person.
|
432
|
+
# X is all of these parts of this person."
|
433
|
+
# [One part of the body of this person felt very bad.]
|
434
|
+
literals = [ parts, of, this, person, can, touch, other, things, dot,
|
435
|
+
parts, of, this, person, can, touch, other, parts, inside,
|
436
|
+
this, person, dot,
|
437
|
+
x_as_noun, is, all, of, these, parts, of, this, person, dot,
|
438
|
+
one, part, of, the, body, of, this, person, felt, very, bad, dot
|
439
|
+
]
|
440
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
441
|
+
|
442
|
+
# Sentence 2-28a definiendum "X dies."
|
443
|
+
literals = [x_as_noun, dies, dot]
|
444
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
445
|
+
|
446
|
+
# Sentence 2-28b definiens "Something happens to X in a moment.
|
447
|
+
# X is alive before this moment. X is not alive after this moment.
|
448
|
+
# [After this person lived for a long time, this person died."
|
449
|
+
literals = [ something, happens, to, x_as_noun, in_, a_as_art,
|
450
|
+
moment, dot,
|
451
|
+
x_as_noun, is, alive, before_adverb, this, moment, dot,
|
452
|
+
x_as_noun, is, not_, alive, after_adverb, this, moment, dot,
|
453
|
+
after_, this, person, lived, for_, a_as_art, long, time, comma,
|
454
|
+
this, person, died, dot
|
455
|
+
]
|
456
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
457
|
+
|
458
|
+
# Sentence 2-29a definiendum "You think maybe X is true."
|
459
|
+
literals = [you, think, maybe, x_as_noun, is, true_, dot]
|
460
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
461
|
+
|
462
|
+
# Sentence 2-29b definiens "You think something like X
|
463
|
+
# can be true. You do not know X is true.
|
464
|
+
# You do not know X is not true.
|
465
|
+
# [Maybe some people far from here can see me.]"
|
466
|
+
literals = [ you, do_aux, not_, know, x_as_noun, is, true_, dot,
|
467
|
+
you, do_aux, not_, know, x_as_noun, is, not_, true_, dot,
|
468
|
+
maybe, some, people, far_from, here_as_noun, can, see, me, dot
|
469
|
+
]
|
470
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
471
|
+
|
472
|
+
# Sentence 2-30a definiendum "J is below K."
|
473
|
+
literals = [j_, is, below, k_, dot]
|
474
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
475
|
+
|
476
|
+
# Sentence 2-30b definiens "K is above J.
|
477
|
+
# [I am touching this thing below me.]
|
478
|
+
literals = [ j_, is, below, k_, dot,
|
479
|
+
i_pronoun, am, touching, this, thing, below, me, dot
|
480
|
+
]
|
481
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
482
|
+
|
483
|
+
# Sentence 2-H extra "Someone sees this thing.
|
484
|
+
# The body of this thing is not moving.
|
485
|
+
# Maybe this thing is dead."
|
486
|
+
literals = [ someone, sees, thing, dot,
|
487
|
+
the, body, of, this, thing, is_aux, not_, moving, dot
|
488
|
+
]
|
489
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
490
|
+
end
|
491
|
+
=begin
|
492
|
+
TODO
|
493
|
+
|
494
|
+
Lesson 2.C
|
495
|
+
|
496
|
+
Xtra:
|
497
|
+
Tony knows Lisa has something, because Tony sees what Lisa has.
|
498
|
+
Tony thinks about what Lisa has, because Tony want to have the same kind of thing.
|
499
|
+
=end
|
500
|
+
end # context
|
501
|
+
end # describe
|
502
|
+
end # module
|
503
|
+
end # module
|