zenlish 0.1.16 → 0.1.17
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 +16 -0
- data/README.md +6 -6
- data/lib/zenlish/lang/dictionary.rb +7 -1
- data/lib/zenlish/lang/zenlish_grammar.rb +58 -38
- data/lib/zenlish/lex/empty_lexicon_factory.rb +2 -0
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/adverb_maybe.rb +10 -0
- data/lib/zenlish/wclasses/all_word_classes.rb +2 -0
- data/lib/zenlish/wclasses/irregular_linking_verb.rb +10 -0
- data/spec/zenlish/parser/zparser_spec.rb +84 -34
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e70c4615014b90304856f70ea963c84b4439765909f4fb6fd3701e73e520a72f
|
4
|
+
data.tar.gz: 36cbbdeb49d2154a20af9521b0177c75ae2c6a2aea1b6edfcc6026eabc5a383b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f963c2562f5554a1b6976cd358f30c77838563774314585864110d733c2b35a5749d379bac40057004c4a848d222fd4e1eb207170b5f346bcea3fd7b4dbcfd40
|
7
|
+
data.tar.gz: 366b4eefe238e059d83d1c5308933c9efc3647cb6697649d02e05c644b17960d6a21cec006d9cee76b4439349fb00c5a484261cee07d18c5a62fa70ce6f30c42
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,24 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## [0.1.17] - 2019-11-25
|
4
|
+
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-H from
|
5
|
+
[Learn These Words First](http://learnthesewordsfirst.com/).
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- Class `AdverbMaybe` to represent the relative pronoun `who`.
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Folder structure under `lib` and `spec`.
|
12
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 2-H (207 sentences in total).
|
13
|
+
- `ZenlishGrammar`: new production rules added (especially for linking/copular verbs).
|
14
|
+
- File `dictionary.rb`: new entries in lexicon `below`, `live`, `maybe`.
|
15
|
+
- File `README.md` Updated the metrics table
|
16
|
+
|
3
17
|
## [0.1.16] - 2019-11-23
|
4
18
|
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-G from
|
5
19
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
20
|
+
|
21
|
+
### Changed
|
6
22
|
- `ZenlishGrammar`: Vast grammar reworking.
|
7
23
|
- File `dictionary.rb`: `there` in lexicon has `ExistentialThere` as word class.
|
8
24
|
- File `dictionary.rb`: new entries for `body`, `one` (as indefinite pronoun), `two` (as indefinite pronoun)
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ users with a language that is close enough to English.
|
|
20
20
|
### Project status
|
21
21
|
|
22
22
|
The project is still in inception. Currently, zenlish is able to parse all
|
23
|
-
sentences from lessons 1-A up to 2-
|
23
|
+
sentences from lessons 1-A up to 2-H. The parser is able to cope with syntactical
|
24
24
|
ambiguities generating parse forests instead of parse trees.
|
25
25
|
|
26
26
|
The intent is to deliver gem versions in small increments.
|
@@ -38,11 +38,11 @@ Over time, the zenlish gem will contain:
|
|
38
38
|
#### Some project metrics (v. 0.1.15)
|
39
39
|
|Metric|Value|
|
40
40
|
|:-:|:-:|
|
41
|
-
| Number of lemmas in dictionary |
|
41
|
+
| Number of lemmas in dictionary | 102 |
|
42
42
|
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 45 |
|
43
|
-
| Number of production rules in grammar |
|
44
|
-
| Number of lessons covered |
|
45
|
-
| Number of sentences in spec files |
|
43
|
+
| Number of production rules in grammar | 137 |
|
44
|
+
| Number of lessons covered | 16 |
|
45
|
+
| Number of sentences in spec files | 207 |
|
46
46
|
|
47
47
|
|
48
48
|
## Installation...
|
@@ -121,7 +121,7 @@ Litmus test: a Zenlish text should be easy to read to a English reading person.
|
|
121
121
|
Here a tentative roadmap:
|
122
122
|
|
123
123
|
#### A) Ability to parse sentences from [Learn These Words First](http://learnthesewordsfirst.com/)
|
124
|
-
*STARTED*.
|
124
|
+
*STARTED*. 16.7% complete
|
125
125
|
This website advocates the idea of a multi-layered dictionary.
|
126
126
|
At the core, there are about 300 essential words.
|
127
127
|
The choice of these words is inspired by the semantic primitives of [NSM
|
@@ -34,14 +34,17 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
34
34
|
add_entry('because', 'SubordinatingConjunction')
|
35
35
|
add_entry('before', 'Adverb')
|
36
36
|
add_entry('before', 'SubordinatingConjunction')
|
37
|
+
add_entry('below', 'Preposition')
|
37
38
|
add_entry('big', 'Adjective')
|
38
39
|
add_entry('body', 'CommonNoun')
|
39
40
|
add_entry('can', 'ModalVerbCan')
|
41
|
+
add_entry('die', 'RegularVerb')
|
40
42
|
add_entry('do', 'AuxiliaryDo')
|
41
43
|
add_entry('do', 'IrregularVerbDo')
|
42
44
|
add_entry('false', 'Adjective')
|
43
45
|
add_entry('far', 'Adverb')
|
44
|
-
add_entry('
|
46
|
+
add_entry('far from', 'Preposition')
|
47
|
+
add_entry('feel', 'IrregularLinkingVerb')
|
45
48
|
add_entry('for', 'Preposition')
|
46
49
|
add_entry('from', 'Preposition')
|
47
50
|
add_entry('good', 'Adjective')
|
@@ -49,6 +52,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
49
52
|
add_entry('happen', 'RegularVerb')
|
50
53
|
add_entry('hear', 'IrregularVerb')
|
51
54
|
add_entry('here', 'Adverb')
|
55
|
+
add_entry('here', 'CommonNoun') # from here (works as a pronoun of a place)
|
52
56
|
add_entry('I', 'PersonalPronoun')
|
53
57
|
add_entry('if', 'SubordinatingConjunction')
|
54
58
|
add_entry('in', 'Preposition')
|
@@ -56,9 +60,11 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
56
60
|
add_entry('kind', 'CommonNoun')
|
57
61
|
add_entry('know', 'IrregularVerbKnow')
|
58
62
|
add_entry('like', 'Preposition')
|
63
|
+
add_entry('live', 'RegularVerb')
|
59
64
|
add_entry('living', 'Adjective')
|
60
65
|
add_entry('long', 'Adjective')
|
61
66
|
add_entry('many', 'IndefiniteQuantifier')
|
67
|
+
add_entry('maybe', 'AdverbMaybe')
|
62
68
|
add_entry('me', 'PersonalPronoun')
|
63
69
|
add_entry('moment', 'CommonNoun')
|
64
70
|
add_entry('more', 'Adjective')
|
@@ -4,6 +4,22 @@
|
|
4
4
|
require 'rley' # Load the Rley parsing library
|
5
5
|
require_relative 'dictionary'
|
6
6
|
|
7
|
+
# Carnie 2012
|
8
|
+
# CP ➝ (C) TP
|
9
|
+
# TP ➝ {NP/CP} (T) VP
|
10
|
+
# VP ➝(AdvP+) V (NP)({NP/CP}) (AdvP+) (PP+) (AdvP+)
|
11
|
+
# NP ➝ (D) (AdjP+) N (PP+) (CP)
|
12
|
+
# PP ➝ P (NP)
|
13
|
+
# AdjP ➝ (AdvP) Adj
|
14
|
+
# AdvP ➝ (AdvP) Adv
|
15
|
+
|
16
|
+
# Slide show on ajective and adverb phrases
|
17
|
+
# https://www.slideshare.net/UtTramTran/advadj-phrase
|
18
|
+
|
19
|
+
# A Lexicalized Tree Adjoining Grammar for English
|
20
|
+
# https://www.cis.upenn.edu/~xtag/tech-report/tech-report.html
|
21
|
+
|
22
|
+
|
7
23
|
########################################
|
8
24
|
# Define a grammar for a highly English-like language
|
9
25
|
builder = Rley::Syntax::GrammarBuilder.new do
|
@@ -20,19 +36,20 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
20
36
|
# Simple sentence
|
21
37
|
#################
|
22
38
|
rule 'simple_sentence' => 'declarative_simple_sentence'
|
39
|
+
rule 'simple_sentence' => 'AdverbMaybe declarative_simple_sentence'
|
23
40
|
rule 'declarative_simple_sentence' => 'affirmative_sentence'
|
24
41
|
rule 'declarative_simple_sentence' => 'existential_sentence'
|
25
42
|
rule 'declarative_simple_sentence' => 'predicative_sentence'
|
26
43
|
rule 'declarative_simple_sentence' => 'negative_sentence'
|
27
44
|
rule 'declarative_simple_sentence' => 'inexistential_sentence'
|
28
|
-
rule 'affirmative_sentence' => '
|
45
|
+
rule 'affirmative_sentence' => 'tense_phrase'
|
29
46
|
rule 'affirmative_sentence' => 'prepositional_phrase Comma simple_sentence'
|
30
47
|
# Case of time adjunct adverbial put in front position
|
31
48
|
rule 'affirmative_sentence' => 'noun_phrase Adverb Comma simple_sentence'
|
32
49
|
|
33
50
|
# there + (auxiliary/raising verb) + be + notional subject.
|
34
51
|
rule 'existential_sentence' => 'ExistentialThere IrregularVerbBe existential_subject'
|
35
|
-
rule 'negative_sentence' => '
|
52
|
+
rule 'negative_sentence' => 'negative_tense_phrase'
|
36
53
|
rule 'negative_sentence' => 'negated_predicate_sentence'
|
37
54
|
rule 'inexistential_sentence' => 'ExistentialThere IrregularVerbBe AdverbNot existential_subject'
|
38
55
|
rule 'existential_subject' => 'noun_phrase adverb_phrase_opt'
|
@@ -44,6 +61,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
44
61
|
rule 'negated_predicate_sentence' => 'conjunctive_prefix IrregularVerbBe AdverbNot predicative_complement'
|
45
62
|
rule 'predicative_complement' => 'noun_phrase'
|
46
63
|
rule 'predicative_complement' => 'adjective_phrase comparative_clause_opt'
|
64
|
+
# 2-28b X is alive before this moment.
|
65
|
+
rule 'predicative_complement' => 'adjective_phrase adverb_phrase noun_phrase'
|
47
66
|
# X is far from the start.
|
48
67
|
rule 'predicative_complement' => 'adverb_phrase_opt prepositional_phrase'
|
49
68
|
|
@@ -67,7 +86,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
67
86
|
rule 'subordination_marker' => 'SubordinatingConjunction PrepositionOf'
|
68
87
|
rule 'dependent_clause' => 'simple_sentence'
|
69
88
|
rule 'dependent_clause' => 'noun_phrase'
|
70
|
-
rule 'infinitive_clause' => 'verb_phrase' # Too
|
89
|
+
rule 'infinitive_clause' => 'verb_phrase' # Too broad
|
71
90
|
rule 'comparative_clause_opt' => 'comparative_clause'
|
72
91
|
rule 'comparative_clause_opt' => []
|
73
92
|
rule 'comparative_clause' => 'comparative_start noun_phrase'
|
@@ -79,30 +98,40 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
79
98
|
rule 'identifying_clause' => 'RelativePronoun verb_phrase'
|
80
99
|
|
81
100
|
|
101
|
+
##############
|
102
|
+
# TENSE PHRASE
|
103
|
+
##############
|
104
|
+
rule 'tense_phrase' => 'noun_phrase tense_opt verb_phrase'
|
105
|
+
rule 'negative_tense_phrase' => 'noun_phrase tense AdverbNot verb_phrase'
|
106
|
+
rule 'tense_opt' => 'tense'
|
107
|
+
rule 'tense_opt' => []
|
108
|
+
rule 'tense' => 'AuxiliaryBe'
|
109
|
+
rule 'tense' => 'AuxiliaryDo'
|
110
|
+
rule 'tense' => 'ModalVerbCan'
|
111
|
+
|
82
112
|
#############
|
83
113
|
# NOUN PHRASE
|
84
114
|
#############
|
85
115
|
rule 'noun_phrase_opt' => 'noun_phrase'
|
86
116
|
rule 'noun_phrase_opt' => []
|
87
|
-
rule 'noun_phrase' => '
|
117
|
+
rule 'noun_phrase' => 'pre_head_np head_np post_head_np'
|
88
118
|
# someone, somebody, something, somewhere; no one, nobody, nothing,
|
89
119
|
# nowhere; anyone, anybody, anything, anywhere; everyone, everybody,
|
90
120
|
# everything, everywhere, the attributive adjective phrase occurs as a postmodifier
|
91
|
-
rule '
|
92
|
-
rule '
|
93
|
-
rule '
|
94
|
-
rule '
|
95
|
-
rule '
|
96
|
-
rule '
|
97
|
-
# rule '
|
98
|
-
rule '
|
121
|
+
rule 'pre_head_np' => 'determiners adjective_phrase_opt'
|
122
|
+
rule 'head_np' => 'CommonNoun'
|
123
|
+
rule 'head_np' => 'ProperNoun'
|
124
|
+
rule 'head_np' => 'PersonalPronoun'
|
125
|
+
rule 'head_np' => 'DemonstrativePronoun'
|
126
|
+
rule 'head_np' => 'IndefinitePronoun'
|
127
|
+
# rule 'head_np' => 'Cardinal' # ... as indefinite pronoun in complement "There were three pies. I ate one."
|
128
|
+
rule 'post_head_np' => 'adjective_phrase_opt prepositional_phrases clause_noun_opt'
|
99
129
|
rule 'clause_noun_opt' => 'clause_noun'
|
100
130
|
rule 'clause_noun_opt' => []
|
101
131
|
rule 'clause_noun' => 'comparative_clause'
|
102
132
|
rule 'clause_noun' => 'dependent_clause'
|
103
133
|
|
104
134
|
|
105
|
-
|
106
135
|
#############
|
107
136
|
# DETERMINERS
|
108
137
|
#############
|
@@ -133,23 +162,24 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
133
162
|
#############
|
134
163
|
# VERB PHRASE
|
135
164
|
#############
|
136
|
-
rule 'verb_phrase' => '
|
137
|
-
|
138
|
-
rule '
|
139
|
-
rule '
|
140
|
-
rule '
|
141
|
-
rule '
|
142
|
-
rule '
|
165
|
+
rule 'verb_phrase' => 'pre_head_vp head_vp post_head_vp'
|
166
|
+
# Rule specific to linking/copular verbs (CEG 288b). Example: I feel very bad.
|
167
|
+
rule 'verb_phrase' => 'pre_head_vp linking_verb adjective_phrase'
|
168
|
+
rule 'pre_head_vp' => 'adverb_phrase_opt'
|
169
|
+
rule 'head_vp' => 'lexical_verb'
|
170
|
+
rule 'head_vp' => 'IrregularVerbSay direct_speech'
|
171
|
+
rule 'head_vp' => 'RegularVerbWant Preposition head_vp post_head_vp'
|
143
172
|
|
144
173
|
# Cover case where ´that´ conjunction is dropped.
|
145
|
-
rule '
|
174
|
+
rule 'head_vp' => 'mental_verb dependent_clause'
|
146
175
|
# ex. 2-23c
|
147
|
-
rule '
|
176
|
+
rule 'head_vp' => 'mental_verb identifying_clause'
|
148
177
|
|
149
|
-
rule '
|
178
|
+
rule 'post_head_vp' => 'noun_phrase_opt adverb_phrase_opt prepositional_phrases adverb_phrase_opt'
|
150
179
|
rule 'lexical_verb' => 'RegularVerb'
|
151
180
|
rule 'lexical_verb' => 'RegularVerbWant'
|
152
181
|
rule 'lexical_verb' => 'IrregularVerb'
|
182
|
+
rule 'lexical_verb' => 'IrregularLinkingVerb'
|
153
183
|
rule 'lexical_verb' => 'IrregularVerbBe'
|
154
184
|
rule 'lexical_verb' => 'IrregularVerbDo'
|
155
185
|
rule 'lexical_verb' => 'IrregularVerbHave'
|
@@ -157,19 +187,15 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
157
187
|
rule 'lexical_verb' => 'IrregularVerbSay'
|
158
188
|
rule 'lexical_verb' => 'IrregularVerbThink'
|
159
189
|
|
190
|
+
|
191
|
+
rule 'linking_verb' => 'IrregularLinkingVerb'
|
192
|
+
|
160
193
|
rule 'mental_verb' => 'IrregularVerbKnow'
|
161
194
|
rule 'mental_verb' => 'IrregularVerbThink'
|
162
195
|
rule 'direct_speech' => 'Colon Quote declarative_simple_sentence Period Quote'
|
163
196
|
rule 'direct_speech' => 'Preposition noun_phrase Colon Quote declarative_simple_sentence Period Quote'
|
164
197
|
rule 'direct_speech' => 'Colon declarative_simple_sentence'
|
165
198
|
|
166
|
-
|
167
|
-
#############
|
168
|
-
# NEGATIVE VERB PHRASE
|
169
|
-
#############
|
170
|
-
rule 'negative_verb_phrase' => 'AuxiliaryDo AdverbNot head_verb post_head_verb'
|
171
|
-
rule 'negative_verb_phrase' => 'ModalVerbCan AdverbNot head_verb post_head_verb'
|
172
|
-
|
173
199
|
##################
|
174
200
|
# ADJECTIVE PHRASE
|
175
201
|
##################
|
@@ -180,6 +206,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
180
206
|
rule 'head_adjective' => 'head_adjective Adjective' # sequence of adjectives (rem: could be comma separated or anded)
|
181
207
|
rule 'head_adjective' => 'Adjective'
|
182
208
|
rule 'postmodifiers_adj' => 'prepositional_phrase' # TODO: multiple prepositional phrases, gerund and to + infinitive
|
209
|
+
# Adverbs such as enough, indeed can post-modify an adjective
|
183
210
|
rule 'postmodifiers_adj' => []
|
184
211
|
|
185
212
|
################
|
@@ -209,7 +236,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
209
236
|
rule 'preposition_object' => 'noun_phrase' # (noun and pronoun)
|
210
237
|
|
211
238
|
# complementation by a verb: gerund -ing form...
|
212
|
-
rule 'preposition_object' => 'noun_phrase_opt lexical_verb
|
239
|
+
rule 'preposition_object' => 'noun_phrase_opt lexical_verb post_head_vp'
|
213
240
|
# preposition_object => "a gerund (a verb form ending in "-ing") that acts as a noun # Example: He beat Lee without overly trying.
|
214
241
|
rule 'preposition_object' => 'conjunctive_prefix' # It's obvious from _what he said_.
|
215
242
|
rule 'preposition_object' => []
|
@@ -218,13 +245,6 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
218
245
|
# REMAINING RULES
|
219
246
|
######################
|
220
247
|
rule 'numeral' => 'Cardinal'
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
######################
|
225
|
-
# DUMMY RULE
|
226
|
-
######################
|
227
|
-
rule 'dummy' => "ConjunctivePronoun RelativePronoun"
|
228
248
|
end
|
229
249
|
|
230
250
|
# And now build the grammar...
|
@@ -17,6 +17,7 @@ module Zenlish
|
|
17
17
|
def add_word_classes(aLexicon)
|
18
18
|
aLexicon.add_terminal(WClasses::Adjective.new.freeze)
|
19
19
|
aLexicon.add_terminal(WClasses::Adverb.new.freeze)
|
20
|
+
aLexicon.add_terminal(WClasses::AdverbMaybe.new.freeze)
|
20
21
|
aLexicon.add_terminal(WClasses::AdverbNot.new.freeze)
|
21
22
|
aLexicon.add_terminal(WClasses::AuxiliaryBe.new.freeze)
|
22
23
|
aLexicon.add_terminal(WClasses::AuxiliaryDo.new.freeze)
|
@@ -31,6 +32,7 @@ module Zenlish
|
|
31
32
|
aLexicon.add_terminal(WClasses::ConjunctivePronoun.new.freeze)
|
32
33
|
aLexicon.add_terminal(WClasses::DemonstrativePronoun.new.freeze)
|
33
34
|
aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
|
35
|
+
aLexicon.add_terminal(WClasses::IrregularLinkingVerb.new.freeze)
|
34
36
|
aLexicon.add_terminal(WClasses::IrregularVerb.new.freeze)
|
35
37
|
aLexicon.add_terminal(WClasses::IrregularVerbBe.new.freeze)
|
36
38
|
aLexicon.add_terminal(WClasses::IrregularVerbDo.new.freeze)
|
data/lib/zenlish/version.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require_relative 'adjective'
|
5
5
|
require_relative 'adverb'
|
6
|
+
require_relative 'adverb_maybe'
|
6
7
|
require_relative 'adverb_not'
|
7
8
|
require_relative 'auxiliary_be'
|
8
9
|
require_relative 'auxiliary_do'
|
@@ -14,6 +15,7 @@ require_relative 'definite_article'
|
|
14
15
|
require_relative 'existential_there'
|
15
16
|
require_relative 'pronoun'
|
16
17
|
require_relative 'proper_noun'
|
18
|
+
require_relative 'irregular_linking_verb'
|
17
19
|
require_relative 'irregular_verb'
|
18
20
|
require_relative 'irregular_verb_be'
|
19
21
|
require_relative 'irregular_verb_do'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'irregular_verb'
|
2
|
+
|
3
|
+
module Zenlish
|
4
|
+
module WClasses
|
5
|
+
# Linking verbs (also known as copulae or copular verbs) describe
|
6
|
+
# the state of being of the subject of the clause.
|
7
|
+
class IrregularLinkingVerb < IrregularVerb
|
8
|
+
end # class
|
9
|
+
end # module
|
10
|
+
end # module
|
@@ -47,18 +47,24 @@ module Zenlish
|
|
47
47
|
literal2var('because', 'because')
|
48
48
|
def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
|
49
49
|
def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end
|
50
|
+
literal2var('below', 'below')
|
50
51
|
literal2var('big', 'big')
|
51
52
|
literal2var('big', 'bigger')
|
52
53
|
literal2var('body', 'body')
|
53
54
|
literal2var('can', 'can')
|
54
55
|
def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
|
56
|
+
literal2var('die', 'died')
|
57
|
+
literal2var('die', 'dies')
|
55
58
|
def do_ ; Lex::Literal.new('do', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
|
59
|
+
def do_aux ; Lex::Literal.new('do', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
|
56
60
|
def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
|
57
61
|
def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
|
58
62
|
literal2var('false', 'false', '_')
|
59
63
|
literal2var('far', 'far')
|
64
|
+
literal2var('far from', 'far_from')
|
60
65
|
literal2var('feel', 'feel')
|
61
66
|
literal2var('feel', 'feels')
|
67
|
+
literal2var('feel', 'felt')
|
62
68
|
literal2var('for', 'for', '_')
|
63
69
|
literal2var('from', 'from')
|
64
70
|
literal2var('good', 'good')
|
@@ -69,7 +75,8 @@ module Zenlish
|
|
69
75
|
literal2var('have', 'has')
|
70
76
|
literal2var('have', 'have')
|
71
77
|
literal2var('hear', 'hears')
|
72
|
-
|
78
|
+
def here ; Lex::Literal.new('here', get_lexeme('here', WClasses::Adverb), 0) ; end
|
79
|
+
def here_as_noun ; Lex::Literal.new('here', get_lexeme('here', WClasses::CommonNoun), 0) ; end
|
73
80
|
def i_pronoun ; Lex::Literal.new('I', get_lexeme('I'), 0) ; end
|
74
81
|
literal2var('if', 'if', '_')
|
75
82
|
literal2var('in', 'in', '_')
|
@@ -84,15 +91,18 @@ module Zenlish
|
|
84
91
|
literal2var('know', 'knows')
|
85
92
|
literal2var('like', 'like')
|
86
93
|
literal2var('Lisa', 'Lisa')
|
94
|
+
literal2var('live', 'lived')
|
87
95
|
literal2var('living', 'living')
|
88
96
|
literal2var('long', 'long')
|
89
97
|
literal2var('many', 'many')
|
98
|
+
literal2var('maybe', 'maybe')
|
90
99
|
literal2var('me', 'me')
|
91
100
|
literal2var('moment', 'moment')
|
92
101
|
def more ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adjective), 0) ; end
|
93
102
|
def more_as_adverb ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adverb), 0) ; end
|
94
103
|
literal2var('move', 'move')
|
95
104
|
literal2var('move', 'moved')
|
105
|
+
literal2var('move', 'moving')
|
96
106
|
literal2var('move', 'moves')
|
97
107
|
literal2var('much', 'much')
|
98
108
|
literal2var('near', 'near')
|
@@ -102,7 +112,7 @@ module Zenlish
|
|
102
112
|
literal2var('of', 'of')
|
103
113
|
literal2var('on', 'on')
|
104
114
|
def one ; Lex::Literal.new('one', get_lexeme('one', WClasses::Cardinal), 0) ; end
|
105
|
-
def one_as_pronoun ; Lex::Literal.new('one', get_lexeme('one', WClasses::IndefinitePronoun), 0) ; end
|
115
|
+
def one_as_pronoun ; Lex::Literal.new('one', get_lexeme('one', WClasses::IndefinitePronoun), 0) ; end
|
106
116
|
literal2var('other', 'other')
|
107
117
|
literal2var('part', 'part')
|
108
118
|
literal2var('part', 'parts')
|
@@ -138,10 +148,11 @@ module Zenlish
|
|
138
148
|
literal2var('time', 'time')
|
139
149
|
literal2var('to', 'to')
|
140
150
|
literal2var('Tony', 'Tony')
|
151
|
+
literal2var('touch', 'touch')
|
141
152
|
literal2var('touch', 'touching')
|
142
153
|
literal2var('true', 'true', '_')
|
143
154
|
def two ; Lex::Literal.new('two', get_lexeme('two', WClasses::Cardinal), 0) ; end
|
144
|
-
def two_as_pronoun ; Lex::Literal.new('two', get_lexeme('two', WClasses::IndefinitePronoun), 0) ; end
|
155
|
+
def two_as_pronoun ; Lex::Literal.new('two', get_lexeme('two', WClasses::IndefinitePronoun), 0) ; end
|
145
156
|
literal2var('very', 'very')
|
146
157
|
literal2var('want', 'want')
|
147
158
|
literal2var('want', 'wants')
|
@@ -212,7 +223,7 @@ module Zenlish
|
|
212
223
|
|
213
224
|
# Sentence 1-04: "Lisa sees the other thing."
|
214
225
|
sentence_literals = [lisa, sees, the, other, thing, dot]
|
215
|
-
expect { subject.to_ptree(sentence_literals) }.not_to raise_error
|
226
|
+
expect { subject.to_ptree(sentence_literals) }.not_to raise_error
|
216
227
|
end
|
217
228
|
|
218
229
|
it 'should parse sample sentences from lesson 1-B' do
|
@@ -248,7 +259,7 @@ module Zenlish
|
|
248
259
|
# same is an adjective of equality comparison
|
249
260
|
# as is part of same ... as combination
|
250
261
|
# it introduces a comparative clause
|
251
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
262
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
252
263
|
end
|
253
264
|
|
254
265
|
it 'should parse sample sentences from lesson 1-C' do
|
@@ -271,7 +282,7 @@ module Zenlish
|
|
271
282
|
# Sentence: "Lisa does not see people inside the other thing."
|
272
283
|
literals = [lisa, does_aux, not_, see, people, inside, the, other, thing, dot]
|
273
284
|
# Ambiguous parse...
|
274
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
285
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
275
286
|
end
|
276
287
|
|
277
288
|
it 'should parse sample sentences from lesson 1-D' do
|
@@ -308,7 +319,7 @@ module Zenlish
|
|
308
319
|
literals = [there, are, more, people, inside, the, other, thing,
|
309
320
|
than, there, are, inside, this, thing, dot]
|
310
321
|
# Ambiguous parse
|
311
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
322
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
312
323
|
end
|
313
324
|
|
314
325
|
it 'should parse sample sentences from lesson 1-E' do
|
@@ -371,7 +382,7 @@ module Zenlish
|
|
371
382
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
372
383
|
|
373
384
|
# Sentence 1-20c: "One of these is not the same kind as the other two."
|
374
|
-
literals = [one, of, these_as_pronoun, is, not_, the, same, kind,
|
385
|
+
literals = [one, of, these_as_pronoun, is, not_, the, same, kind,
|
375
386
|
as, the, other, two_as_pronoun, dot]
|
376
387
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
377
388
|
|
@@ -407,7 +418,7 @@ module Zenlish
|
|
407
418
|
|
408
419
|
# Sentence 1-24: "Tony is near to Lisa."
|
409
420
|
literals = [tony, is, near_to, lisa, dot]
|
410
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
421
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
411
422
|
end
|
412
423
|
|
413
424
|
it 'should parse sample sentences from lesson 1-G' do
|
@@ -454,7 +465,7 @@ module Zenlish
|
|
454
465
|
# Sentence 1-27c: "Tony is touching one side of this thing."
|
455
466
|
literals = [tony, is_aux, touching, one, side, of, this, thing, dot]
|
456
467
|
# Ambiguous parse
|
457
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
468
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
458
469
|
end
|
459
470
|
|
460
471
|
it 'should parse sample sentences from lesson 1-H' do
|
@@ -539,7 +550,7 @@ module Zenlish
|
|
539
550
|
|
540
551
|
# Sentence 2-Ax: "What Tony has is like what Lisa has."
|
541
552
|
literals = [what, tony, has, is, like, what, lisa, has, dot]
|
542
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
553
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
543
554
|
end
|
544
555
|
|
545
556
|
it 'should parse sample sentences from lesson 2-B' do
|
@@ -638,7 +649,7 @@ module Zenlish
|
|
638
649
|
|
639
650
|
# Sentence 2-10e: "Lisa cannot do this."
|
640
651
|
literals = [lisa, can, not_, do_, this_as_pronoun, dot]
|
641
|
-
expect { subject.to_pforest(literals) }.not_to raise_error
|
652
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
642
653
|
end
|
643
654
|
|
644
655
|
it 'should parse sample sentences from lesson 2-D' do
|
@@ -675,7 +686,7 @@ module Zenlish
|
|
675
686
|
# Sentence 2-Dx: "Lisa thinks about something bad happening to this
|
676
687
|
# living thing. Thinking about this feels bad for Lisa."
|
677
688
|
literals = [lisa, thinks, about, something, bad, happening, to, this,
|
678
|
-
living, thing, dot,
|
689
|
+
living, thing, dot,
|
679
690
|
#thinking, about, this_as_pronoun, feels, bad,
|
680
691
|
#for_, lisa, dot
|
681
692
|
]
|
@@ -739,7 +750,7 @@ module Zenlish
|
|
739
750
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
740
751
|
end
|
741
752
|
|
742
|
-
it 'should parse sample sentences from lesson 2-F' do
|
753
|
+
it 'should parse sample sentences from lesson 2-F' do
|
743
754
|
# Sentence 2-19a: 'Tony says: "I did X.".'
|
744
755
|
literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
|
745
756
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
@@ -921,31 +932,70 @@ module Zenlish
|
|
921
932
|
# Sentence 2-27a definiendum: 'X is the body of this person.'
|
922
933
|
literals = [x_as_noun, is, the, body, of, this, person, dot]
|
923
934
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
924
|
-
end
|
925
|
-
=begin
|
926
|
-
TODO
|
927
|
-
Lesson 2-H
|
928
|
-
2-27. body, bodies, the body of, the bodies of.
|
929
|
-
[X is the body of this person.] = Parts of this person can touch other things. Parts of this person can touch other parts inside this person. X is all of these parts of this person.
|
930
|
-
[One part of the body of this person felt very bad.]
|
931
935
|
|
932
|
-
2-
|
933
|
-
|
934
|
-
|
936
|
+
# Sentence 2-27b "Parts of this person can touch other things.
|
937
|
+
# Parts of this person can touch other parts inside this person.
|
938
|
+
# X is all of these parts of this person."
|
939
|
+
# [One part of the body of this person felt very bad.]
|
940
|
+
literals = [ parts, of, this, person, can, touch, other, things, dot,
|
941
|
+
parts, of, this, person, can, touch, other, parts, inside,
|
942
|
+
this, person, dot,
|
943
|
+
x_as_noun, is, all, of, these, parts, of, this, person, dot,
|
944
|
+
one, part, of, the, body, of, this, person, felt, very, bad, dot
|
945
|
+
]
|
946
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
947
|
+
|
948
|
+
# Sentence 2-28a definiendum "X dies."
|
949
|
+
literals = [x_as_noun, dies, dot]
|
950
|
+
expect { subject.to_ptree(literals) }.not_to raise_error
|
935
951
|
|
936
|
-
2-
|
937
|
-
|
938
|
-
[
|
952
|
+
# Sentence 2-28b definiens "Something happens to X in a moment.
|
953
|
+
# X is alive before this moment. X is not alive after this moment.
|
954
|
+
# [After this person lived for a long time, this person died."
|
955
|
+
literals = [ something, happens, to, x_as_noun, in_, a_as_art,
|
956
|
+
moment, dot,
|
957
|
+
x_as_noun, is, alive, before_adverb, this, moment, dot,
|
958
|
+
x_as_noun, is, not_, alive, after_adverb, this, moment, dot,
|
959
|
+
after_, this, person, lived, for_, a_as_art, long, time, comma,
|
960
|
+
this, person, died, dot
|
961
|
+
]
|
962
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
939
963
|
|
940
|
-
2-
|
941
|
-
|
942
|
-
|
964
|
+
# Sentence 2-29a definiendum "You think maybe X is true."
|
965
|
+
literals = [you, think, maybe, x_as_noun, is, true_, dot]
|
966
|
+
expect { subject.to_ptree(literals) }.not_to raise_error
|
967
|
+
|
968
|
+
# Sentence 2-29b definiens "You think something like X
|
969
|
+
# can be true. You do not know X is true.
|
970
|
+
# You do not know X is not true.
|
971
|
+
# [Maybe some people far from here can see me.]"
|
972
|
+
literals = [ you, do_aux, not_, know, x_as_noun, is, true_, dot,
|
973
|
+
you, do_aux, not_, know, x_as_noun, is, not_, true_, dot,
|
974
|
+
maybe, some, people, far_from, here_as_noun, can, see, me, dot
|
975
|
+
]
|
976
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
943
977
|
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
978
|
+
# Sentence 2-30a definiendum "J is below K."
|
979
|
+
literals = [j_, is, below, k_, dot]
|
980
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
981
|
+
|
982
|
+
# Sentence 2-30b definiens "K is above J.
|
983
|
+
# [I am touching this thing below me.]
|
984
|
+
literals = [ j_, is, below, k_, dot,
|
985
|
+
i_pronoun, am, touching, this, thing, below, me, dot
|
986
|
+
]
|
987
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
948
988
|
|
989
|
+
# Sentence 2-H extra "Someone sees this thing.
|
990
|
+
# The body of this thing is not moving.
|
991
|
+
# Maybe this thing is dead."
|
992
|
+
literals = [ someone, sees, thing, dot,
|
993
|
+
the, body, of, this, thing, is_aux, not_, moving, dot
|
994
|
+
]
|
995
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
996
|
+
end
|
997
|
+
=begin
|
998
|
+
TODO
|
949
999
|
Lesson 2.C
|
950
1000
|
|
951
1001
|
Xtra:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenlish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/zenlish/version.rb
|
97
97
|
- lib/zenlish/wclasses/adjective.rb
|
98
98
|
- lib/zenlish/wclasses/adverb.rb
|
99
|
+
- lib/zenlish/wclasses/adverb_maybe.rb
|
99
100
|
- lib/zenlish/wclasses/adverb_not.rb
|
100
101
|
- lib/zenlish/wclasses/all_word_classes.rb
|
101
102
|
- lib/zenlish/wclasses/article.rb
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/zenlish/wclasses/indefinite_article.rb
|
117
118
|
- lib/zenlish/wclasses/indefinite_pronoun.rb
|
118
119
|
- lib/zenlish/wclasses/indefinite_quantifier.rb
|
120
|
+
- lib/zenlish/wclasses/irregular_linking_verb.rb
|
119
121
|
- lib/zenlish/wclasses/irregular_verb.rb
|
120
122
|
- lib/zenlish/wclasses/irregular_verb_be.rb
|
121
123
|
- lib/zenlish/wclasses/irregular_verb_do.rb
|