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.
- checksums.yaml +4 -4
- data/.rubocop.yml +228 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +5 -3
- data/LICENSE.txt +1 -1
- data/Rakefile +5 -3
- data/lib/zenlish/feature/boolean_domain.rb +6 -4
- data/lib/zenlish/feature/boolean_value.rb +3 -2
- data/lib/zenlish/feature/enumeration_domain.rb +5 -2
- data/lib/zenlish/feature/feature.rb +9 -7
- data/lib/zenlish/feature/feature_def.rb +9 -6
- data/lib/zenlish/feature/feature_domain.rb +4 -2
- data/lib/zenlish/feature/feature_struct.rb +3 -1
- data/lib/zenlish/feature/feature_struct_def.rb +5 -3
- data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
- data/lib/zenlish/feature/feature_value.rb +4 -2
- data/lib/zenlish/feature/identifier_domain.rb +5 -3
- data/lib/zenlish/feature/identifier_value.rb +3 -2
- data/lib/zenlish/feature/symbol_value.rb +3 -1
- data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
- data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
- data/lib/zenlish/inflect/concatenation.rb +3 -2
- data/lib/zenlish/inflect/equals_literal.rb +3 -1
- data/lib/zenlish/inflect/feature_heading.rb +2 -5
- data/lib/zenlish/inflect/formal_argument.rb +3 -1
- data/lib/zenlish/inflect/function_call.rb +4 -1
- data/lib/zenlish/inflect/heading.rb +2 -0
- data/lib/zenlish/inflect/inflection_rule.rb +2 -0
- data/lib/zenlish/inflect/inflection_table.rb +6 -4
- data/lib/zenlish/inflect/inflection_table_builder.rb +21 -18
- data/lib/zenlish/inflect/input_asis.rb +3 -0
- data/lib/zenlish/inflect/input_expression.rb +4 -2
- data/lib/zenlish/inflect/literal_asis.rb +4 -1
- data/lib/zenlish/inflect/matches_pattern.rb +2 -0
- data/lib/zenlish/inflect/membership.rb +2 -0
- data/lib/zenlish/inflect/method_heading.rb +3 -6
- data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
- data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
- data/lib/zenlish/inflect/output_expression.rb +6 -0
- data/lib/zenlish/inflect/substitution.rb +3 -1
- data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
- data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
- data/lib/zenlish/lang/dictionary.rb +19 -16
- data/lib/zenlish/lang/lemmatizer.rb +40 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +6 -4
- data/lib/zenlish/lex/empty_lexicon_factory.rb +3 -2
- data/lib/zenlish/lex/lexeme.rb +6 -4
- data/lib/zenlish/lex/lexical_entry.rb +6 -4
- data/lib/zenlish/lex/lexicon.rb +4 -3
- data/lib/zenlish/lex/literal.rb +3 -1
- data/lib/zenlish/lexer/lexer.rb +144 -0
- data/lib/zenlish/trie/base_trie_node.rb +27 -0
- data/lib/zenlish/trie/trie.rb +132 -0
- data/lib/zenlish/trie/trie_node.rb +21 -0
- data/lib/zenlish/trie/trie_root.rb +10 -0
- data/lib/zenlish/version.rb +3 -1
- data/lib/zenlish/wclasses/adjective.rb +4 -2
- data/lib/zenlish/wclasses/adverb.rb +3 -1
- data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
- data/lib/zenlish/wclasses/adverb_not.rb +2 -0
- data/lib/zenlish/wclasses/all_word_classes.rb +3 -1
- data/lib/zenlish/wclasses/article.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary_be.rb +7 -6
- data/lib/zenlish/wclasses/auxiliary_do.rb +6 -5
- data/lib/zenlish/wclasses/cardinal.rb +3 -1
- data/lib/zenlish/wclasses/common_noun.rb +2 -0
- data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
- data/lib/zenlish/wclasses/conjunction.rb +2 -0
- data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/coordinator.rb +4 -2
- data/lib/zenlish/wclasses/definite_article.rb +2 -0
- data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
- data/lib/zenlish/wclasses/demonstrative_determiner.rb +6 -4
- data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/determiner.rb +3 -1
- data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
- data/lib/zenlish/wclasses/existential_there.rb +2 -0
- data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
- data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
- data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
- data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb.rb +13 -15
- data/lib/zenlish/wclasses/irregular_verb_be.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_can.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_do.rb +7 -6
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_have.rb +12 -11
- data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
- data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
- data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
- data/lib/zenlish/wclasses/modal_verb_can.rb +7 -5
- data/lib/zenlish/wclasses/noun.rb +4 -2
- data/lib/zenlish/wclasses/numeral.rb +2 -0
- data/lib/zenlish/wclasses/personal_pronoun.rb +8 -6
- data/lib/zenlish/wclasses/possessive_determiner.rb +13 -12
- data/lib/zenlish/wclasses/preposition.rb +3 -1
- data/lib/zenlish/wclasses/preposition_of.rb +2 -0
- data/lib/zenlish/wclasses/preposition_than.rb +2 -0
- data/lib/zenlish/wclasses/pronoun.rb +3 -1
- data/lib/zenlish/wclasses/proper_noun.rb +10 -8
- data/lib/zenlish/wclasses/quantifier.rb +3 -1
- data/lib/zenlish/wclasses/regular_verb.rb +9 -9
- data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
- data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
- data/lib/zenlish/wclasses/verb.rb +5 -3
- data/lib/zenlish/wclasses/word_class.rb +7 -5
- data/lib/zenlish.rb +3 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/zenlish/feature/boolean_domain_spec.rb +16 -16
- data/spec/zenlish/feature/boolean_value_spec.rb +7 -6
- data/spec/zenlish/feature/enumeration_domain_spec.rb +21 -21
- data/spec/zenlish/feature/feature_def_spec.rb +15 -14
- data/spec/zenlish/feature/feature_spec.rb +17 -17
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +23 -21
- data/spec/zenlish/feature/feature_struct_def_spec.rb +26 -25
- data/spec/zenlish/feature/identifier_domain_spec.rb +15 -15
- data/spec/zenlish/feature/identifier_value_spec.rb +10 -9
- data/spec/zenlish/feature/symbol_value_spec.rb +9 -8
- data/spec/zenlish/inflect/concatenation_spec.rb +14 -14
- data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/feature_heading_spec.rb +22 -21
- data/spec/zenlish/inflect/formal_argument_spec.rb +7 -7
- data/spec/zenlish/inflect/function_call_spec.rb +11 -12
- data/spec/zenlish/inflect/inflection_rule_spec.rb +28 -24
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +62 -57
- data/spec/zenlish/inflect/inflection_table_spec.rb +49 -46
- data/spec/zenlish/inflect/input_asis_spec.rb +12 -15
- data/spec/zenlish/inflect/literal_asis_spec.rb +10 -10
- data/spec/zenlish/inflect/matches_pattern_spec.rb +16 -15
- data/spec/zenlish/inflect/membership_spec.rb +17 -16
- data/spec/zenlish/inflect/method_heading_spec.rb +15 -14
- data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/substitution_spec.rb +10 -11
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +8 -6
- data/spec/zenlish/lang/dictionary_spec.rb +28 -31
- data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +5 -5
- data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
- data/spec/zenlish/lex/lexeme_spec.rb +27 -28
- data/spec/zenlish/lex/lexical_entry_spec.rb +15 -15
- data/spec/zenlish/lex/lexicon_spec.rb +52 -50
- data/spec/zenlish/lex/literal_spec.rb +8 -8
- data/spec/zenlish/lexer/lexer_spec.rb +52 -0
- data/spec/zenlish/parser/lesson1_spec.rb +81 -81
- data/spec/zenlish/parser/lesson2_spec.rb +133 -138
- data/spec/zenlish/parser/lesson3_spec.rb +186 -226
- data/spec/zenlish/parser/zparser_spec.rb +8 -7
- data/spec/zenlish/support/minimal_lexicon.rb +2 -0
- data/spec/zenlish/support/var2word.rb +16 -9
- data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
- data/spec/zenlish/trie/trie_spec.rb +108 -0
- data/spec/zenlish/wclasses/common_noun_spec.rb +15 -19
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +12 -12
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +18 -18
- data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +28 -28
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -9
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +12 -12
- data/spec/zenlish/wclasses/noun_spec.rb +7 -7
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +20 -23
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +28 -31
- 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 +30 -30
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -9
- data/spec/zenlish_spec.rb +4 -2
- data/zenlish.gemspec +18 -14
- 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
|
@@ -8,372 +9,371 @@ module Zenlish
|
|
8
9
|
describe ZParser do
|
9
10
|
include Var2Word
|
10
11
|
|
11
|
-
subject {
|
12
|
+
subject(:parser) { described_class.new }
|
12
13
|
|
13
14
|
context 'Parsing lesson 2:' do
|
14
|
-
it '
|
15
|
+
it 'parses sample sentences from lesson 2-A' do
|
15
16
|
# Sentence 2-01a: "This thing is like two of the other things."
|
16
17
|
literals = [this, thing, is, like, two, of, the, other, things, dot]
|
17
|
-
expect {
|
18
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
18
19
|
|
19
20
|
# Sentence 2-01b: "One of these things is not like the other things."
|
20
21
|
literals = [one, of, these, things, is, not_, like, the, other, things, dot]
|
21
|
-
expect {
|
22
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
22
23
|
|
23
24
|
# Sentence 2-02a: "Lisa has something."
|
24
25
|
literals = [lisa, has, something, dot]
|
25
|
-
expect {
|
26
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
26
27
|
|
27
28
|
# Sentence 2-02b: "Tony has another thing."
|
28
29
|
literals = [tony, has, another, thing, dot]
|
29
|
-
expect {
|
30
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
30
31
|
|
31
32
|
# Sentence 2-02c: "Lisa does not have the same kind of thing as Tony has."
|
32
33
|
literals = [lisa, does_aux, not_, have, the, same, kind, of, thing, as, tony, has, dot]
|
33
34
|
# Ambiguous parse
|
34
|
-
expect {
|
35
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
35
36
|
|
36
37
|
# Sentence 2-03a: "Lisa is touching part of this thing."
|
37
38
|
literals = [lisa, is_aux, touching, part, of, this, thing, dot]
|
38
39
|
# Ambiguous parse
|
39
|
-
expect {
|
40
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
40
41
|
|
41
42
|
# Sentence 2-03b: "Tony is touching the other part."
|
42
43
|
literals = [tony, is_aux, touching, the, other, part, dot]
|
43
|
-
expect {
|
44
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
44
45
|
|
45
46
|
# Sentence 2-Ax: "What Tony has is like what Lisa has."
|
46
47
|
literals = [what, tony, has, is, like, what, lisa, has, dot]
|
47
|
-
expect {
|
48
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
48
49
|
end
|
49
50
|
|
50
|
-
it '
|
51
|
+
it 'parses sample sentences from lesson 2-B' do
|
51
52
|
# Sentence 2-04a: "Lisa does something."
|
52
53
|
literals = [lisa, does, something, dot]
|
53
|
-
expect {
|
54
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
54
55
|
|
55
56
|
# Sentence 2-04b: "Lisa does something with this thing."
|
56
57
|
literals = [lisa, does, something, with, this, thing, dot]
|
57
58
|
# Ambiguous parse
|
58
|
-
expect {
|
59
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
59
60
|
|
60
61
|
# Sentence 2-04c: "Lisa does something to Tony."
|
61
62
|
literals = [lisa, does, something, to, tony, dot]
|
62
63
|
# Ambiguous parse
|
63
|
-
expect {
|
64
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
64
65
|
|
65
66
|
# Sentence 2-04d: "Lisa does something to Tony with this thing."
|
66
67
|
literals = [lisa, does, something, to, tony, with, this, thing, dot]
|
67
68
|
# Ambiguous parse
|
68
|
-
expect {
|
69
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
69
70
|
|
70
71
|
# Sentence 2-05a: "Something happens."
|
71
72
|
literals = [something, happens, dot]
|
72
|
-
expect {
|
73
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
73
74
|
|
74
75
|
# Sentence 2-05b: "Something happens to Lisa."
|
75
76
|
literals = [something, happens, to, lisa, dot]
|
76
|
-
expect {
|
77
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
77
78
|
|
78
79
|
# Sentence 2-06a: "Tony does something."
|
79
80
|
literals = [tony, does, something, dot]
|
80
|
-
expect {
|
81
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
81
82
|
|
82
83
|
# Sentence 2-06b: "Something happens to Lisa because of this."
|
83
84
|
literals = [something, happens, to, lisa, because, of, this_as_pronoun, dot]
|
84
|
-
expect {
|
85
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
85
86
|
|
86
87
|
# Sentence 2-06c: "Something happens to Lisa because Tony does this."
|
87
88
|
literals = [something, happens, to, lisa, because, tony, does, this_as_pronoun, dot]
|
88
|
-
expect {
|
89
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
89
90
|
|
90
91
|
# Sentence 2-06: "Something happens to this living thing."
|
91
92
|
literals = [something, happens, to, this, living, thing, dot]
|
92
|
-
expect {
|
93
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
93
94
|
end
|
94
95
|
|
95
|
-
it '
|
96
|
+
it 'parses sample sentences from lesson 2-C' do
|
96
97
|
# Sentence 2-07a: "Lisa thinks Tony is inside this thing."
|
97
98
|
literals = [lisa, thinks, tony, is, inside, this, thing, dot]
|
98
99
|
# Ambiguous parse
|
99
|
-
expect {
|
100
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
100
101
|
|
101
102
|
# Sentence 2-07b: "Lisa thinks something about Tony."
|
102
103
|
literals = [lisa, thinks, something, about, tony, dot]
|
103
104
|
# Ambiguous parse
|
104
|
-
expect {
|
105
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
105
106
|
|
106
107
|
# Sentence 2-08a: "Tony knows Lisa is inside this thing, because Tony sees Lisa inside."
|
107
108
|
literals = [tony, knows, lisa, is, inside, this, thing, comma,
|
108
109
|
because, tony, sees, lisa, inside, dot]
|
109
110
|
# Ambiguous parse
|
110
|
-
expect {
|
111
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
111
112
|
|
112
113
|
# Sentence 2-08b: "Tony knows something about Lisa."
|
113
114
|
literals = [tony, knows, something, about, lisa, dot]
|
114
115
|
# Ambiguous parse
|
115
|
-
expect {
|
116
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
116
117
|
|
117
118
|
# Sentence 2-09a: "Tony wants this thing."
|
118
119
|
literals = [tony, wants, this, thing, dot]
|
119
|
-
expect {
|
120
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
120
121
|
|
121
122
|
# Sentence 2-09b: "Tony wants to have this thing."
|
122
123
|
literals = [tony, wants, to, have, this, thing, dot]
|
123
124
|
# Ambiguous parse
|
124
|
-
expect {
|
125
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
125
126
|
|
126
127
|
# Sentence 2-10a: "Tony wants to do something."
|
127
128
|
literals = [tony, wants, to, do_, something, dot]
|
128
129
|
# Ambiguous parse
|
129
|
-
expect {
|
130
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
130
131
|
|
131
132
|
# Sentence 2-10b: "Lisa wants to do the same thing."
|
132
133
|
literals = [lisa, wants, to, do_, the, same, thing, dot]
|
133
134
|
# Ambiguous parse
|
134
|
-
expect {
|
135
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
135
136
|
|
136
137
|
# Sentence 2-10c: "Tony can do this."
|
137
138
|
literals = [tony, can, do_, this_as_pronoun, dot]
|
138
|
-
expect {
|
139
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
139
140
|
|
140
141
|
# Sentence 2-10d: "This is not something Lisa can do."
|
141
142
|
literals = [this_as_pronoun, is, not_, something, lisa, can, do_, dot]
|
142
|
-
expect {
|
143
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
143
144
|
|
144
145
|
# Sentence 2-10e: "Lisa cannot do this."
|
145
146
|
literals = [lisa, can, not_, do_, this_as_pronoun, dot]
|
146
|
-
expect {
|
147
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
147
148
|
end
|
148
149
|
|
149
|
-
it '
|
150
|
+
it 'parses sample sentences from lesson 2-D' do
|
150
151
|
# Sentence 2-11a: "This person does something bad."
|
151
152
|
literals = [this, person, does, something, bad, dot]
|
152
153
|
# Ambiguous parse
|
153
|
-
expect {
|
154
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
154
155
|
|
155
156
|
# Sentence 2-11b: "This person does something bad for Tony."
|
156
157
|
literals = [this, person, does, something, bad, for_, tony, dot]
|
157
158
|
# Ambiguous parse
|
158
|
-
expect {
|
159
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
159
160
|
|
160
161
|
# Sentence 2-12a: "Tony does something good."
|
161
162
|
literals = [tony, does, something, good, dot]
|
162
|
-
expect {
|
163
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
163
164
|
|
164
165
|
# Sentence 2-12b: "Tony does something good for Lisa."
|
165
166
|
literals = [tony, does, something, good, for_, lisa, dot]
|
166
|
-
expect {
|
167
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
167
168
|
|
168
169
|
# Sentence 2-13a: "Tony feels something."
|
169
170
|
literals = [tony, feels, something, dot]
|
170
|
-
expect {
|
171
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
171
172
|
|
172
173
|
# Sentence 2-13b: "This does not feel good for Tony."
|
173
174
|
literals = [this_as_pronoun, does_aux, not_, feel, good, for_, tony, dot]
|
174
|
-
expect {
|
175
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
175
176
|
|
176
177
|
# Sentence 2-13b: "This feels bad for Tony."
|
177
178
|
literals = [this_as_pronoun, feels, bad, for_, tony, dot]
|
178
|
-
expect {
|
179
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
179
180
|
|
180
181
|
# Sentence 2-Dx: "Lisa thinks about something bad happening to this
|
181
182
|
# living thing. Thinking about this feels bad for Lisa."
|
182
183
|
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
|
184
|
+
living, thing, dot]
|
185
|
+
# thinking, about, this_as_pronoun, feels, bad,
|
186
|
+
# for_, lisa, dot]
|
187
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
188
188
|
end
|
189
189
|
|
190
|
-
it '
|
190
|
+
it 'parses sample sentences from lesson 2-E' do
|
191
191
|
# Sentence 2-14a: "Lisa says something at this time."
|
192
192
|
literals = [lisa, says, something, at, this, time, dot]
|
193
193
|
# Ambiguous parse
|
194
|
-
expect {
|
194
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
195
195
|
|
196
196
|
# Sentence 2-14b: "Tony is not in this place at this time."
|
197
197
|
literals = [tony, is, not_, in_, this, place, at, this, time, dot]
|
198
|
-
expect {
|
198
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
199
199
|
|
200
200
|
# Sentence 2-15a: "At one time, Tony does something to this thing."
|
201
201
|
literals = [at, one, time, comma, tony, does, something, to, this, thing, dot]
|
202
|
-
expect {
|
202
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
203
203
|
|
204
204
|
# Sentence 2-15b: "At another time, Lisa says something."
|
205
205
|
literals = [at, another, time, comma, lisa, says, something, dot]
|
206
|
-
expect {
|
206
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
207
207
|
|
208
208
|
# Sentence 2-15c: "Tony does something to this thing before Lisa says something."
|
209
209
|
literals = [tony, does, something, to, this, thing, before, lisa, says, something, dot]
|
210
|
-
expect {
|
210
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
211
211
|
|
212
212
|
# Sentence 2-16a: "Lisa does something for a long time."
|
213
213
|
literals = [lisa, does, something, for_, a_as_art, long, time, dot]
|
214
|
-
expect {
|
214
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
215
215
|
|
216
216
|
# Sentence 2-17a: "Tony does something for a short time."
|
217
217
|
literals = [tony, does, something, for_, a_as_art, short, time, dot]
|
218
|
-
expect {
|
218
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
219
219
|
|
220
220
|
# Sentence 2-17a: "Tony does not do this for a long time."
|
221
221
|
literals = [tony, does_aux, not_, do_, this_as_pronoun, for_, a_as_art, long, time, dot]
|
222
|
-
expect {
|
222
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
223
223
|
|
224
224
|
# Sentence 2-18a: "Lisa sees something move."
|
225
225
|
literals = [lisa, sees, something, move, dot]
|
226
|
-
expect {
|
226
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
227
227
|
|
228
228
|
# Sentence 2-18a: "Lisa moves near to this thing."
|
229
229
|
literals = [lisa, moves, near_to, this, thing, dot]
|
230
|
-
expect {
|
230
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
231
231
|
|
232
232
|
# Sentence 2-E-Xa: "A short time before, Tony was far from Lisa."
|
233
233
|
# Case of a time adverbial adjunct that is put in front position.
|
234
234
|
literals = [a_as_art, short, time, before_adverb, comma, tony, was, far, from, lisa, dot]
|
235
|
-
expect {
|
235
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
236
236
|
|
237
237
|
# Sentence 2-E-Xa: "At this time, Tony is near to Lisa"
|
238
238
|
literals = [at, this, time, comma, tony, is, near_to, lisa, dot]
|
239
|
-
expect {
|
239
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
240
240
|
|
241
241
|
# Sentence 2-E-Xa: "Tony is near to Lisa because Tony moved"
|
242
242
|
# Case of a time adverbial adjunct that is put in front position.
|
243
243
|
literals = [tony, is, near_to, lisa, because, tony, moved, dot]
|
244
|
-
expect {
|
244
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
245
245
|
end
|
246
246
|
|
247
|
-
it '
|
247
|
+
it 'parses sample sentences from lesson 2-F' do
|
248
248
|
# Sentence 2-19a: 'Tony says: "I did X.".'
|
249
249
|
literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
|
250
|
-
expect {
|
250
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
251
251
|
|
252
252
|
# Sentence 2-19a definiendum: 'Tony says: "I did X.".'
|
253
253
|
literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
|
254
|
-
expect {
|
254
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
255
255
|
|
256
256
|
# Sentence 2-19a definiens: 'Tony says something about Tony. Tony says: Tony did X.'
|
257
257
|
literals = [tony, says, something, about, tony, dot,
|
258
|
-
|
259
|
-
expect {
|
258
|
+
tony, says, colon, tony, did, x_as_noun, dot]
|
259
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
260
260
|
|
261
261
|
# Sentence 2-19a: 'Tony says: "I see Lisa.".'
|
262
262
|
literals = [tony, says, colon, quote, i_pronoun, see, lisa, dot, quote, dot]
|
263
|
-
expect {
|
263
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
264
264
|
|
265
265
|
# Sentence 2-19b definiendum: 'Lisa says: "X happened to me.".'
|
266
266
|
literals = [lisa, says, colon, quote, x_as_noun, happened, to, me, dot, quote, dot]
|
267
|
-
expect {
|
267
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
268
268
|
|
269
269
|
# Sentence 2-19b definiens: 'Lisa says something about Lisa. Lisa says: X happened to Lisa.'
|
270
270
|
literals = [lisa, says, something, about, lisa, dot,
|
271
|
-
|
272
|
-
expect {
|
271
|
+
lisa, says, colon, x_as_noun, happened, to, lisa, dot]
|
272
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
273
273
|
|
274
274
|
# Sentence 2-19c: 'Lisa says: "Tony sees me."'
|
275
275
|
literals = [lisa, says, colon, quote, tony, sees, me, dot, quote, dot]
|
276
|
-
expect {
|
276
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
277
277
|
|
278
278
|
# Sentence 2-20a definiendum: 'Tony says to Lisa: "I can see you.".'
|
279
279
|
literals = [tony, says, to, lisa, colon, quote, i_pronoun, can, see, you, dot, quote, dot]
|
280
|
-
expect {
|
280
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
281
281
|
|
282
282
|
# Sentence 2-20a definiens: 'Tony says something about Lisa.
|
283
283
|
# Tony says this to Lisa. Tony says: Tony can see Lisa.'
|
284
284
|
literals = [tony, says, something, about, lisa, dot,
|
285
|
-
|
286
|
-
|
287
|
-
expect {
|
285
|
+
tony, says, this_as_pronoun, to, lisa, dot,
|
286
|
+
tony, says, colon, tony, can, see, lisa, dot]
|
287
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
288
288
|
|
289
289
|
# Sentence 2-20b: "I know you have something good."
|
290
290
|
literals = [i_pronoun, know, you, have, something, good, dot]
|
291
|
-
expect {
|
291
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
292
292
|
|
293
293
|
# Sentence 2-20c: "I want you to do something good for me."
|
294
294
|
literals = [i_pronoun, want, you, to, do_, something, good, for_, me, dot]
|
295
|
-
expect {
|
295
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
296
296
|
|
297
297
|
# Sentence 2-21a definiendum: 'Tony says: "X happens here.".'
|
298
298
|
literals = [tony, says, colon, quote, x_as_noun, happens, here, dot, quote, dot]
|
299
|
-
expect {
|
299
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
300
300
|
|
301
301
|
# Sentence 2-21a definiens: "Tony is in a place. Tony says: X happens in this place."
|
302
302
|
literals = [tony, is, in_, a_as_art, place, dot,
|
303
|
-
|
304
|
-
expect {
|
303
|
+
tony, says, colon, x_as_noun, happens, in_, this, place, dot]
|
304
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
305
305
|
|
306
306
|
# Sentence 2-21b: "Many people were here at one time."
|
307
307
|
literals = [many, people, were, here, at, one, time, dot]
|
308
|
-
expect {
|
308
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
309
309
|
|
310
310
|
# Sentence 2-22a definiendum: 'Lisa says: "X happens now.".'
|
311
311
|
literals = [lisa, says, colon, quote, x_as_noun, happens, now, dot, quote, dot]
|
312
|
-
expect {
|
312
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
313
313
|
|
314
314
|
# Sentence 2-22a definiens: 'Lisa says something at a time.
|
315
315
|
# Lisa says: X happens at this same time.'
|
316
316
|
literals = [lisa, says, something, at, a_as_art, time, dot,
|
317
|
-
|
318
|
-
expect {
|
317
|
+
lisa, says, colon, x_as_noun, happens, at, this, time, dot]
|
318
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
319
319
|
|
320
320
|
# Sentence 2-22b: "There are not many people here now."
|
321
|
-
literals = [there, are, not_, many, people, here, now
|
322
|
-
expect {
|
321
|
+
literals = [there, are, not_, many, people, here, now, dot]
|
322
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
323
323
|
|
324
324
|
# Sentence 2-Fa: "Lisa says to Tony: "I can see many living things here."."
|
325
325
|
literals = [lisa, says, to, tony, colon, quote, i_pronoun,
|
326
|
-
|
327
|
-
expect {
|
326
|
+
can, see, many, living, things, here, dot, quote, dot]
|
327
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
328
328
|
end
|
329
329
|
|
330
|
-
it '
|
330
|
+
it 'parses sample sentences from lesson 2-G' do
|
331
331
|
# Sentence 2-23a definiendum: 'Someone does X.'
|
332
332
|
literals = [someone, does, x_as_noun, dot]
|
333
|
-
expect {
|
333
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
334
334
|
|
335
335
|
# Sentence 2-23a definiens: 'Something does X. This something can
|
336
336
|
# think like people think. This something can be one person.'
|
337
337
|
literals = [something, does, x_as_noun, dot,
|
338
|
-
|
339
|
-
|
340
|
-
expect {
|
338
|
+
this, something, can, think, like, people, think, dot,
|
339
|
+
this, something, can, be_, a_as_art, person, dot]
|
340
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
341
341
|
|
342
342
|
# Sentence 2-23b: Someone said something to Tony.
|
343
343
|
literals = [someone, said, something, to, tony, dot]
|
344
|
-
expect {
|
344
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
345
345
|
|
346
346
|
# Sentence 2-23c definiendum: 'J knows who did K.'
|
347
347
|
literals = [j_, knows, who, did, k_, dot]
|
348
|
-
expect {
|
348
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
349
349
|
|
350
350
|
# Sentence 2-23c definiens: J thinks about someone.
|
351
351
|
# J knows this someone did K.
|
352
352
|
literals = [j_, thinks, about, someone, dot,
|
353
353
|
j_, knows, this, someone, did, k_, dot]
|
354
|
-
expect {
|
354
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
355
355
|
|
356
356
|
# Sentence 2-23d: Tony knows who said something.
|
357
357
|
literals = [tony, knows, who, said, something, dot]
|
358
|
-
expect {
|
358
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
359
359
|
|
360
360
|
# Sentence 2-24a definiendum: 'J happens after K happens.'
|
361
361
|
literals = [j_, happens, after_, k_, happens, dot]
|
362
|
-
expect {
|
362
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
363
363
|
|
364
364
|
# Sentence 2-24a definiens: K happens before J happens.
|
365
365
|
literals = [k_, happens, before, j_, happens, dot]
|
366
|
-
expect {
|
366
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
367
367
|
|
368
368
|
# Sentence 2-24b: After you do something for a long time,
|
369
369
|
# you can know much more about this.
|
370
370
|
literals = [after_, you, do_, something, for_, a_as_art, long, time,
|
371
371
|
comma, you, can, know, much, more_as_adverb, about, this_as_pronoun, dot]
|
372
|
-
expect {
|
372
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
373
373
|
|
374
374
|
# Sentence 2-25a definiendum: 'X is true for some time.'
|
375
375
|
literals = [x_as_noun, is, true_, for_, some, time, dot]
|
376
|
-
expect {
|
376
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
377
377
|
|
378
378
|
# Sentence 2-25a definiens: X is true at a time.
|
379
379
|
# Some parts of this one time happen before other parts.
|
@@ -383,17 +383,17 @@ module Zenlish
|
|
383
383
|
some, parts, of, this, one, time, happen, before_adverb, other, parts, dot,
|
384
384
|
some, parts, of, this, one, time, happen, after_adverb, other, parts, dot,
|
385
385
|
x_as_noun, is, true_, at, all, parts, of, this, one, time, dot]
|
386
|
-
expect {
|
386
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
387
387
|
|
388
388
|
# Sentence 2-25b: After I moved for some time,
|
389
389
|
# I was near the other side of this place.
|
390
390
|
literals = [after_, i_pronoun, moved, for_, some, time,
|
391
391
|
comma, i_pronoun, was, near, the, other, side, of, this, place, dot]
|
392
|
-
expect {
|
392
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
393
393
|
|
394
394
|
# Sentence 2-26a definiendum: 'X happens in a moment.'
|
395
395
|
literals = [x_as_noun, happens, in_, a_as_art, moment, dot]
|
396
|
-
expect {
|
396
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
397
397
|
|
398
398
|
# Sentence 2-26a definiens: X happens for one very short time.
|
399
399
|
# There are not parts of this very short time when one part
|
@@ -401,13 +401,13 @@ module Zenlish
|
|
401
401
|
literals = [x_as_noun, happens, for_, one, very, short, time, dot,
|
402
402
|
there, are, not_, parts, of, this, very, short, time, when_,
|
403
403
|
one, part, happens, before_adverb, other, part, dot]
|
404
|
-
expect {
|
404
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
405
405
|
|
406
406
|
# Sentence 2-26b: In a moment, I knew something here was not good.
|
407
407
|
# 'here' is adverb that modifies the 'knew' verb
|
408
408
|
literals = [in_, a_as_art, moment, comma, i_pronoun, knew, something,
|
409
|
-
|
410
|
-
expect {
|
409
|
+
here, was, not_, good, dot]
|
410
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
411
411
|
|
412
412
|
# Sentence 2-Gx: Tony is inside this thing for some time.
|
413
413
|
# Lisa says: "I want to know who is inside this thing.".
|
@@ -415,87 +415,82 @@ module Zenlish
|
|
415
415
|
# Tony says this after Tony hears Lisa.
|
416
416
|
literals = [tony, is, inside, this, thing, for_, some, time, dot,
|
417
417
|
lisa, says, colon, quote, i_pronoun, want, to, know, who, is,
|
418
|
-
inside, this, thing, dot, quote, dot,
|
418
|
+
inside, this, thing, dot, quote, dot, tony, hears, lisa, dot,
|
419
419
|
because, of, this_as_pronoun, comma, tony, says, colon,
|
420
420
|
quote, i_pronoun, am, inside, dot, quote, dot,
|
421
421
|
tony, says, this_as_pronoun, after_, tony, hears, lisa, dot]
|
422
|
-
expect {
|
422
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
423
423
|
end
|
424
424
|
|
425
|
-
it '
|
425
|
+
it 'parses sample sentences from lesson 2-H' do
|
426
426
|
# Sentence 2-27a definiendum: 'X is the body of this person.'
|
427
427
|
literals = [x_as_noun, is, the, body, of, this, person, dot]
|
428
|
-
expect {
|
428
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
429
429
|
|
430
430
|
# Sentence 2-27b "Parts of this person can touch other things.
|
431
431
|
# Parts of this person can touch other parts inside this person.
|
432
432
|
# X is all of these parts of this person."
|
433
433
|
# [One part of the body of this person felt very bad.]
|
434
|
-
literals = [
|
434
|
+
literals = [parts, of, this, person, can, touch, other, things, dot,
|
435
435
|
parts, of, this, person, can, touch, other, parts, inside,
|
436
|
-
|
436
|
+
this, person, dot,
|
437
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
|
438
|
+
one, part, of, the, body, of, this, person, felt, very, bad, dot]
|
439
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
441
440
|
|
442
441
|
# Sentence 2-28a definiendum "X dies."
|
443
442
|
literals = [x_as_noun, dies, dot]
|
444
|
-
expect {
|
443
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
445
444
|
|
446
445
|
# Sentence 2-28b definiens "Something happens to X in a moment.
|
447
446
|
# X is alive before this moment. X is not alive after this moment.
|
448
447
|
# [After this person lived for a long time, this person died."
|
449
|
-
literals = [
|
450
|
-
|
448
|
+
literals = [something, happens, to, x_as_noun, in_, a_as_art,
|
449
|
+
moment, dot,
|
451
450
|
x_as_noun, is, alive, before_adverb, this, moment, dot,
|
452
451
|
x_as_noun, is, not_, alive, after_adverb, this, moment, dot,
|
453
452
|
after_, this, person, lived, for_, a_as_art, long, time, comma,
|
454
|
-
|
455
|
-
|
456
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
453
|
+
this, person, died, dot]
|
454
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
457
455
|
|
458
456
|
# Sentence 2-29a definiendum "You think maybe X is true."
|
459
457
|
literals = [you, think, maybe, x_as_noun, is, true_, dot]
|
460
|
-
expect {
|
458
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
461
459
|
|
462
460
|
# Sentence 2-29b definiens "You think something like X
|
463
461
|
# can be true. You do not know X is true.
|
464
462
|
# You do not know X is not true.
|
465
463
|
# [Maybe some people far from here can see me.]"
|
466
|
-
literals = [
|
464
|
+
literals = [you, do_aux, not_, know, x_as_noun, is, true_, dot,
|
467
465
|
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
|
466
|
+
maybe, some, people, far_from, here_as_noun, can, see, me, dot]
|
467
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
471
468
|
|
472
469
|
# Sentence 2-30a definiendum "J is below K."
|
473
470
|
literals = [j_, is, below, k_, dot]
|
474
|
-
expect {
|
471
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
475
472
|
|
476
473
|
# Sentence 2-30b definiens "K is above J.
|
477
474
|
# [I am touching this thing below me.]
|
478
|
-
literals = [
|
479
|
-
i_pronoun, am, touching, this, thing, below, me, dot
|
480
|
-
|
481
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
475
|
+
literals = [j_, is, below, k_, dot,
|
476
|
+
i_pronoun, am, touching, this, thing, below, me, dot]
|
477
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
482
478
|
|
483
479
|
# Sentence 2-H extra "Someone sees this thing.
|
484
480
|
# The body of this thing is not moving.
|
485
481
|
# Maybe this thing is dead."
|
486
|
-
literals = [
|
487
|
-
the, body, of, this, thing, is_aux, not_, moving, dot
|
488
|
-
|
489
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
482
|
+
literals = [someone, sees, thing, dot,
|
483
|
+
the, body, of, this, thing, is_aux, not_, moving, dot]
|
484
|
+
expect { parser.to_pforest(literals) }.not_to raise_error
|
490
485
|
end
|
491
486
|
=begin
|
492
487
|
TODO
|
493
488
|
|
494
489
|
Lesson 2.C
|
495
490
|
|
496
|
-
|
497
|
-
|
498
|
-
|
491
|
+
Xtra:
|
492
|
+
Tony knows Lisa has something, because Tony sees what Lisa has.
|
493
|
+
Tony thinks about what Lisa has, because Tony want to have the same kind of thing.
|
499
494
|
=end
|
500
495
|
end # context
|
501
496
|
end # describe
|