zenlish 0.1.21 → 0.1.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cae52bb88888ca9313517a2f37546bff739bf498f943e08daa456c75a3af10b7
4
- data.tar.gz: e74feb8df8d191deba3d9dd95359eac3f723a1c864778ca35984bdc6a597f81d
3
+ metadata.gz: 4da2a693d39e0a679adc7d383970efaf1b79dd032507421bc5eace1e89e10489
4
+ data.tar.gz: 8a1e5f12dad04d12d1e076884602de1e498de1ff70c9e45d837b5d6d48ab5a11
5
5
  SHA512:
6
- metadata.gz: ef5dc8c9180d8dda4a834c863a5068c9a0ea86e42109e185f3599c71962e55b14a8bd04b868badcd1ae1f04f089d0636112dfa370d6cf2994d3fabf086b465e4
7
- data.tar.gz: b2a408ef938db169d6c06d9606c4734f31ccdd1893507a676e6bead05e46c9cdee5adfd7c5de088d046a9dc7eb1f7c25fb3330dfb59dd81486180109b7c7e19a
6
+ metadata.gz: 5e322feebdbe34e135082452fe2b6b6d37befd18d873aadee90b45637aba010b938ce0263357895b2d281d1adf2b4f937a944d6194a873e0cc7bd7182e9cbe7f
7
+ data.tar.gz: a8add9612fbb6eb83e2bed4038f9b58f5c7ce86005abb737c3d4733fcd5c40c36529116b7614a26dc58945d7f27b27cc84e54bcb5c65f7bc0fa962a5566cfc73
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.1.22] - 2019-12-03
4
+ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-D from
5
+ [Learn These Words First](http://learnthesewordsfirst.com/).
6
+
7
+ ### Changed
8
+ - File `zparser_spec.rb`: tests include all sentences from lesson 1, 2, and 3-D (290 sentences in total).
9
+ - `ZenlishGrammar`: allow coordination of determiners.
10
+ - Class `IndefiniteQuantifier` renamed to `Quantifier`
11
+ - File `dictionary.rb`: new entries in lexicon `become`, `exist`, `someplace`.
12
+ - File `README.md` Updated the metrics table
13
+
3
14
  ## [0.1.21] - 2019-12-02
4
15
  __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-C from
5
16
  [Learn These Words First](http://learnthesewordsfirst.com/).
data/README.md CHANGED
@@ -35,14 +35,14 @@ Over time, the zenlish gem will contain:
35
35
  - A simplified ontology[TODO]
36
36
 
37
37
 
38
- #### Some project metrics (v. 0.1.21)
38
+ #### Some project metrics (v. 0.1.22)
39
39
  |Metric|Value|
40
40
  |:-:|:-:|
41
- | Number of lemmas in dictionary | 117 |
41
+ | Number of lemmas in dictionary | 120 |
42
42
  | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 58% |
43
- | Number of production rules in grammar | 170 |
44
- | Number of lessons covered | 19 |
45
- | Number of sentences in spec files | 277 |
43
+ | Number of production rules in grammar | 171 |
44
+ | Number of lessons covered | 20 |
45
+ | Number of sentences in spec files | 290 |
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*. 19.8% complete
124
+ *STARTED*. 20.8% 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,6 +34,7 @@ unless defined?(Zenlish::Lang::Dictionary)
34
34
  add_entry('be', 'AuxiliaryBe')
35
35
  add_entry('be', 'IrregularVerbBe')
36
36
  add_entry('because', 'SubordinatingConjunction')
37
+ add_entry('become', 'IrregularLinkingVerb')
37
38
  add_entry('before', 'Adverb')
38
39
  add_entry('before', 'Adjective')
39
40
  add_entry('before', 'SubordinatingConjunction')
@@ -48,6 +49,7 @@ unless defined?(Zenlish::Lang::Dictionary)
48
49
  add_entry('do', 'AuxiliaryDo')
49
50
  add_entry('do', 'IrregularVerbDo')
50
51
  add_entry('each', 'DistributiveDeterminer')
52
+ add_entry('exist', 'RegularVerb')
51
53
  add_entry('false', 'Adjective')
52
54
  add_entry('far', 'Adverb')
53
55
  add_entry('far from', 'Preposition')
@@ -105,6 +107,7 @@ unless defined?(Zenlish::Lang::Dictionary)
105
107
  add_entry('small', 'Adjective')
106
108
  add_entry('some', 'Quantifier')
107
109
  add_entry('someone', 'IndefinitePronoun')
110
+ add_entry('someplace', 'Adverb')
108
111
  add_entry('something', 'IndefinitePronoun')
109
112
  add_entry('than', 'PrepositionThan')
110
113
  add_entry('that', 'RelativePronoun')
@@ -52,7 +52,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
52
52
  # 3-02d J is one that does this.
53
53
  rule 'predicative_complement' => 'adjective_phrase relative_clause_opt'
54
54
  # 2-28b X is alive before this moment.
55
- rule 'predicative_complement' => 'adjective_phrase adverb_phrase noun_phrase'
55
+ rule 'predicative_complement' => 'adjective_phrase adverb_phrase noun_phrase_opt'
56
56
  # X is far from the start.
57
57
  rule 'predicative_complement' => 'adverb_phrase_opt prepositional_phrase'
58
58
 
@@ -70,7 +70,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
70
70
  # CGE 287d: verb + direct object + infinitive clause (without to)
71
71
  rule 'complex_sentence' => 'main_clause infinitive_clause'
72
72
  # Colon used to introduce an explanatory sentence.
73
- rule 'complex_sentence' => 'main_clause Colon simple_sentence'
73
+ rule 'complex_sentence' => 'main_clause Colon sentence'
74
74
  rule 'comma_opt' => 'Comma'
75
75
  rule 'comma_opt' => []
76
76
 
@@ -148,31 +148,33 @@ builder = Rley::Syntax::GrammarBuilder.new do
148
148
  # DETERMINERS
149
149
  #############
150
150
  rule 'determiners' => 'predeterminer_opt central_determiner_opt postdeterminers'
151
- rule 'determiners' => 'partitive_determiner PrepositionOf main_determiner_opt postdeterminers'
151
+ rule 'determiners' => 'partitive_determiner PrepositionOf main_determiner_opt postdeterminers'
152
152
 
153
153
  # Pre-determiner
154
154
  rule 'predeterminer_opt' => 'predeterminer'
155
155
  rule 'predeterminer_opt' => []
156
156
  rule 'predeterminer' => 'FrontingQuantifier' # all, both
157
157
  # FOR_LATER 'predeterminer' => 'multipler' # twice, thrice, n times
158
- # FOR_LATER 'predeterminer' => 'fraction' # half, third, ...
159
- # FOR_LATER 'predeterminer' => 'intensifier' # what (exclamative), such, quite, rather
158
+ # FOR_LATER 'predeterminer' => 'fraction' # half, third, ...
159
+ # FOR_LATER 'predeterminer' => 'intensifier' # what (exclamative), such, quite, rather
160
160
 
161
161
  # Central determiners: article, demonstrative or possessive
162
162
  rule 'central_determiner_opt' => 'main_determiner'
163
163
  rule 'central_determiner_opt' => 'DistributiveDeterminer' # each, every, either, neither
164
- # FOR_LATER 'central_determiner_opt' => 'InterrogativeDeterminer' # what, which, whose
164
+ # FOR_LATER 'central_determiner_opt' => 'InterrogativeDeterminer' # what, which, whose
165
165
  rule 'central_determiner_opt' => []
166
166
  rule 'main_determiner_opt' => 'main_determiner'
167
- rule 'main_determiner_opt' => []
167
+ rule 'main_determiner_opt' => []
168
168
  rule 'main_determiner' => 'article'
169
169
  rule 'main_determiner' => 'DemonstrativeDeterminer' # 'this', .., that, these, those
170
- rule 'main_determiner' => 'PossessiveDeterminer' # my, your, his, her, its, our, their
170
+ rule 'main_determiner' => 'PossessiveDeterminer' # my, your, his, her, its, our, their
171
171
  rule 'article' => 'DefiniteArticle' # 'the'
172
172
  rule 'article' => 'IndefiniteArticle' # 'a/an', .., any, some, that, those,
173
173
 
174
174
  # Post-determiners
175
175
  # FOR_LATER 'postdeterminers' => 'ordinal_opt cardinal_opt other_quantifiers'
176
+ # Example 3-14b: There are two or more things.
177
+ rule 'postdeterminers' => 'postdeterminers Coordinator postdeterminers'
176
178
  rule 'postdeterminers' => 'cardinal_opt other_quantifiers'
177
179
  rule 'postdeterminers' => []
178
180
  rule 'other_quantifiers' => 'other_quantifiers Quantifier'
@@ -181,9 +183,9 @@ builder = Rley::Syntax::GrammarBuilder.new do
181
183
  rule 'partitive_determiner' => 'predeterminer'
182
184
  rule 'partitive_determiner' => 'DistributiveDeterminer'
183
185
  # FOR_LATER 'partitive_determiner' => 'Ordinal'
184
- # FOR_LATER 'partitive_determiner' => 'GeneralOrdinal'
186
+ # FOR_LATER 'partitive_determiner' => 'GeneralOrdinal'
185
187
  rule 'partitive_determiner' => 'Cardinal'
186
- rule 'partitive_determiner' => 'Quantifier'
188
+ rule 'partitive_determiner' => 'Quantifier'
187
189
 
188
190
  #############
189
191
  # VERB PHRASE
@@ -221,7 +223,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
221
223
  rule 'mental_verb' => 'IrregularVerbThink'
222
224
  rule 'direct_speech' => 'Colon Quote prose Quote'
223
225
  rule 'direct_speech' => 'Preposition noun_phrase Colon Quote declarative_simple_sentence Period Quote'
224
- rule 'direct_speech' => 'Colon declarative_simple_sentence'
226
+ rule 'direct_speech' => 'Colon sentence'
225
227
 
226
228
  ##################
227
229
  # ADJECTIVE PHRASE
@@ -24,17 +24,17 @@ module Zenlish
24
24
  aLexicon.add_terminal(WClasses::Cardinal.new.freeze)
25
25
  aLexicon.add_terminal(WClasses::CommonNoun.new.freeze)
26
26
  aLexicon.add_terminal(WClasses::ComparativeParticle.new.freeze)
27
- aLexicon.add_terminal(WClasses::ConjunctivePronoun.new.freeze)
27
+ aLexicon.add_terminal(WClasses::ConjunctivePronoun.new.freeze)
28
28
  aLexicon.add_terminal(WClasses::Coordinator.new.freeze)
29
29
  aLexicon.add_terminal(WClasses::DefiniteArticle.new.freeze)
30
30
  aLexicon.add_terminal(WClasses::DegreeAdverb.new.freeze)
31
31
  aLexicon.add_terminal(WClasses::DemonstrativeDeterminer.new.freeze)
32
32
  aLexicon.add_terminal(WClasses::DemonstrativePronoun.new.freeze)
33
- aLexicon.add_terminal(WClasses::DistributiveDeterminer.new.freeze)
33
+ aLexicon.add_terminal(WClasses::DistributiveDeterminer.new.freeze)
34
34
  aLexicon.add_terminal(WClasses::ExistentialThere.new.freeze)
35
- aLexicon.add_terminal(WClasses::FrontingQuantifier.new.freeze)
36
- aLexicon.add_terminal(WClasses::IndefiniteArticle.new.freeze)
37
- aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
35
+ aLexicon.add_terminal(WClasses::FrontingQuantifier.new.freeze)
36
+ aLexicon.add_terminal(WClasses::IndefiniteArticle.new.freeze)
37
+ aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
38
38
  aLexicon.add_terminal(WClasses::IrregularLinkingVerb.new.freeze)
39
39
  aLexicon.add_terminal(WClasses::IrregularVerb.new.freeze)
40
40
  aLexicon.add_terminal(WClasses::IrregularVerbBe.new.freeze)
@@ -50,7 +50,7 @@ module Zenlish
50
50
  aLexicon.add_terminal(WClasses::Preposition.new.freeze)
51
51
  aLexicon.add_terminal(WClasses::PrepositionOf.new.freeze)
52
52
  aLexicon.add_terminal(WClasses::PrepositionThan.new.freeze)
53
- aLexicon.add_terminal(WClasses::Quantifier.new.freeze)
53
+ aLexicon.add_terminal(WClasses::Quantifier.new.freeze)
54
54
  aLexicon.add_terminal(WClasses::RegularVerb.new.freeze)
55
55
  aLexicon.add_terminal(WClasses::RegularVerbWant.new.freeze)
56
56
  aLexicon.add_terminal(WClasses::RelativePronoun.new.freeze)
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.1.21'
2
+ VERSION = '0.1.22'
3
3
  end
@@ -41,6 +41,7 @@ module Zenlish
41
41
  def am ; Lex::Literal.new('am', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
42
42
  literal2var('and', 'and', '_')
43
43
  literal2var('animal', 'animal')
44
+ literal2var('animal', 'animals')
44
45
  literal2var('another', 'another')
45
46
  def are ; Lex::Literal.new('are', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
46
47
  literal2var('as', 'as')
@@ -48,6 +49,8 @@ module Zenlish
48
49
  literal2var('bad', 'bad')
49
50
  def be_ ; Lex::Literal.new('be', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
50
51
  literal2var('because', 'because')
52
+ literal2var('become', 'became')
53
+ literal2var('become', 'becomes')
51
54
  def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
52
55
  def before_as_adj ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adjective), 0) ; end
53
56
  def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end
@@ -59,7 +62,7 @@ module Zenlish
59
62
  literal2var('body', 'body')
60
63
  literal2var('but', 'but')
61
64
  literal2var('can', 'can')
62
- literal2var('cause', 'cause')
65
+ literal2var('cause', 'cause')
63
66
  literal2var('cause', 'caused')
64
67
  literal2var('cause', 'causes')
65
68
  def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
@@ -70,7 +73,10 @@ module Zenlish
70
73
  def do_aux ; Lex::Literal.new('do', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
71
74
  def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
72
75
  def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
73
- literal2var('each', 'each', '_')
76
+ literal2var('each', 'each', '_')
77
+ literal2var('exist', 'exist')
78
+ literal2var('exist', 'existed')
79
+ literal2var('exist', 'exists')
74
80
  literal2var('false', 'false', '_')
75
81
  literal2var('far', 'far')
76
82
  literal2var('far from', 'far_from')
@@ -153,6 +159,7 @@ module Zenlish
153
159
  literal2var('see', 'see')
154
160
  literal2var('see', 'sees')
155
161
  literal2var('someone', 'someone')
162
+ literal2var('someplace', 'someplace')
156
163
  literal2var('something', 'something')
157
164
  literal2var('the', 'the')
158
165
  literal2var('their', 'their')
@@ -181,8 +188,8 @@ module Zenlish
181
188
  literal2var('true', 'true', '_')
182
189
  def two ; Lex::Literal.new('two', get_lexeme('two', WClasses::Cardinal), 0) ; end
183
190
  def two_as_pronoun ; Lex::Literal.new('two', get_lexeme('two', WClasses::IndefinitePronoun), 0) ; end
184
- literal2var('use', 'use')
185
- literal2var('use', 'used')
191
+ literal2var('use', 'use')
192
+ literal2var('use', 'used')
186
193
  literal2var('very', 'very')
187
194
  literal2var('want', 'want')
188
195
  literal2var('want', 'wants')
@@ -1266,47 +1273,82 @@ module Zenlish
1266
1273
  ]
1267
1274
  expect { subject.to_pforest(literals) }.not_to raise_error
1268
1275
  end
1269
-
1276
+
1270
1277
  it 'should parse sample sentences from lesson 3-D' do
1271
1278
  # Sentence 3-13a definiendum: 'You use this thing.'
1272
1279
  literals = [you, use, this, thing, dot]
1273
- expect { subject.to_pforest(literals) }.not_to raise_error
1280
+ expect { subject.to_pforest(literals) }.not_to raise_error
1274
1281
 
1275
- # Sentence 3-13b definiens: You do something with this thing
1282
+ # Sentence 3-13b definiens: You do something with this thing
1276
1283
  # because you think this can cause something to happen that you want.
1277
1284
  # [I used something big to cause people far from here to see me.]
1278
1285
  literals = [ you, do_, something, with, this, thing, because, you,
1279
- think, this_as_pronoun, can, cause, something, to, happen,
1286
+ think, this_as_pronoun, can, cause, something, to, happen,
1280
1287
  that, you, want, dot,
1281
- i_pronoun, used, something, big, to, cause, people, far, from,
1288
+ i_pronoun, used, something, big, to, cause, people, far, from,
1282
1289
  here_as_noun, to, see, me, dot
1283
1290
  ]
1284
1291
  expect { subject.to_pforest(literals) }.not_to raise_error
1285
1292
 
1286
1293
  # Sentence 3-14a definiendum: 'You know X about each of these things.'
1287
1294
  literals = [you, know, x_as_noun, about, each_, of, these, things, dot]
1288
- expect { subject.to_pforest(literals) }.not_to raise_error
1295
+ expect { subject.to_pforest(literals) }.not_to raise_error
1296
+
1297
+ # Sentence 3-14b definiens: There are two or more things.
1298
+ # You think about all these things like this:
1299
+ # If something is one of these things, then you know X about it.
1300
+ # [Each person here said something to me.]
1301
+ # because you think this can cause something to happen that you want.
1302
+ # [I used something big to cause people far from here to see me.]
1303
+ literals = [ there, are, two, or_, more, things, dot,
1304
+ you, think, about, all, these, things, like, this_as_pronoun, colon,
1305
+ if_, something, is, one, of, these, things, comma,
1306
+ then_, you, know, x_as_noun, about, it_, dot,
1307
+ each_, person, here, said, something, to, me, dot
1308
+ ]
1309
+ expect { subject.to_pforest(literals) }.not_to raise_error
1310
+
1311
+ # Sentence 3-15a definiendum: 'Someplace an X exists.'
1312
+ literals = [someplace, an, x_as_noun, exists, dot]
1313
+ expect { subject.to_pforest(literals) }.not_to raise_error
1314
+
1315
+ # Sentence 3-15b definiens: Someplace there is an X,
1316
+ # or someplace an X is alive.
1317
+ # [This kind of thing did not exist before this time.]
1318
+ literals = [ someplace, there, is, an, x_as_noun, comma,
1319
+ or_, someplace, an, x_as_noun, is, alive, dot,
1320
+ this, kind, of, thing, did, not_, exist, before, this, time, dot]
1321
+ expect { subject.to_pforest(literals) }.not_to raise_error
1322
+
1323
+ # Sentence 3-16a definiendum: 'J became K.'
1324
+ literals = [j_, became, k_, dot]
1325
+ expect { subject.to_pforest(literals) }.not_to raise_error
1326
+
1327
+ # Sentence 3-16b definiens: Something happened to J for some time.
1328
+ # After this happened, K is something true you can know about J.
1329
+ # But before this happened, K was not true.
1330
+ # [These two animals were small before, but they became big.]
1331
+ literals = [ something, happened, to, j_, for_, some, time, dot,
1332
+ after_, this_as_pronoun, happened, comma, k_, is, something, true_,
1333
+ you, can, know, about, j_, dot,
1334
+ these, two, animals, were, small, before_adverb, comma,
1335
+ but, they, became, big, dot
1336
+ ]
1337
+ expect { subject.to_pforest(literals) }.not_to raise_error
1338
+
1339
+ # Sentence 3-Dx: There are some animals here.
1340
+ # Each of these animals was small when it existed a short time.
1341
+ # After a long time, each of these animals became big.
1342
+ literals = [there, are, some, animal, here, dot,
1343
+ each_, of, these, animals, was, small, when_, it_,
1344
+ existed, a_as_art, short, time, dot,
1345
+ after_, a_as_art, long, time, comma, each_, of, these, animals,
1346
+ became, big, dot
1347
+ ]
1348
+ expect { subject.to_pforest(literals) }.not_to raise_error
1289
1349
  end
1290
1350
  =begin
1291
1351
  TODO
1292
- 3-14. each, each of.
1293
- [You know X about each of these things.] = There are two or more things. You think about all these things like this: If something is one of these things, then you know X about it.
1294
- [Each person here said something to me.]
1295
-
1296
- 3-15. exist, exists, to exist, existing, existed.
1297
- [Someplace an X exists.] = Someplace there is an X, or someplace an X is alive.
1298
- [This kind of thing did not exist before this time.]
1299
-
1300
- 3-16. become, becomes, to become, becoming, became.
1301
- [J became K.] = Something happened to J for some time. After this happened, K is something true you can know about J. But before this happened, K was not true.
1302
- [These two animals were small before, but they became big.]
1303
-
1304
- There are some animals here.
1305
- Each of these animals was small when it existed a short time.
1306
- After a long time, each of these animals __________.
1307
- became big
1308
- became small
1309
- used many words
1310
1352
 
1311
1353
  Lesson 2.C
1312
1354
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenlish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef