zenlish 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da2a693d39e0a679adc7d383970efaf1b79dd032507421bc5eace1e89e10489
4
- data.tar.gz: 8a1e5f12dad04d12d1e076884602de1e498de1ff70c9e45d837b5d6d48ab5a11
3
+ metadata.gz: e7dad60dec43b90f6e075fea633061c76d32a1be7e829717a92a6cf839766a3e
4
+ data.tar.gz: c353a68ac3f3388c3b6024232eaafa312efa86b6ccbe0b6bebe8632d9684fbaf
5
5
  SHA512:
6
- metadata.gz: 5e322feebdbe34e135082452fe2b6b6d37befd18d873aadee90b45637aba010b938ce0263357895b2d281d1adf2b4f937a944d6194a873e0cc7bd7182e9cbe7f
7
- data.tar.gz: a8add9612fbb6eb83e2bed4038f9b58f5c7ce86005abb737c3d4733fcd5c40c36529116b7614a26dc58945d7f27b27cc84e54bcb5c65f7bc0fa962a5566cfc73
6
+ metadata.gz: fc526524c86d904177d86aca4cd5c66de3d0e219735e221d04eb8e43b591024e5b651aa6f4390b8b55770f343ecaefc3aa306bd1256ef3f4ab0c37cdb8c24c14
7
+ data.tar.gz: f7ee26281e6d1efa1ab553942015bfc26b703f45344106ac8f731681ef273a5a1052d9e53289af330095a517dfca7879d3e6a1ab4e63506bc60f3fe1e892c9e4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.1.23] - 2019-12-04
4
+ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-E 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-F (308 sentences in total).
9
+ - `ZenlishGrammar`: more rules for negative sentences.
10
+ - File `dictionary.rb`: new entries in lexicon `contain`, `container`, `make`.
11
+ - File `README.md` Updated the metrics table
12
+
3
13
  ## [0.1.22] - 2019-12-03
4
14
  __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-D from
5
15
  [Learn These Words First](http://learnthesewordsfirst.com/).
@@ -7,7 +17,6 @@ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-D from
7
17
  ### Changed
8
18
  - File `zparser_spec.rb`: tests include all sentences from lesson 1, 2, and 3-D (290 sentences in total).
9
19
  - `ZenlishGrammar`: allow coordination of determiners.
10
- - Class `IndefiniteQuantifier` renamed to `Quantifier`
11
20
  - File `dictionary.rb`: new entries in lexicon `become`, `exist`, `someplace`.
12
21
  - File `README.md` Updated the metrics table
13
22
 
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 3-D. The parser is able to cope with syntactical
23
+ sentences from lessons 1-A up to 3-E. 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.
@@ -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.22)
38
+ #### Some project metrics (v. 0.1.23)
39
39
  |Metric|Value|
40
40
  |:-:|:-:|
41
- | Number of lemmas in dictionary | 120 |
42
- | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 58% |
43
- | Number of production rules in grammar | 171 |
44
- | Number of lessons covered | 20 |
45
- | Number of sentences in spec files | 290 |
41
+ | Number of lemmas in dictionary | 126 |
42
+ | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 59% |
43
+ | Number of production rules in grammar | 176 |
44
+ | Number of lessons covered | 21 |
45
+ | Number of sentences in spec files | 308 |
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*. 20.8% complete
124
+ *STARTED*. 21.9% 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
@@ -45,10 +45,14 @@ unless defined?(Zenlish::Lang::Dictionary)
45
45
  add_entry('but', 'Coordinator')
46
46
  add_entry('can', 'ModalVerbCan')
47
47
  add_entry('cause', 'RegularVerb')
48
+ add_entry('contain', 'RegularVerb')
49
+ add_entry('container', 'CommonNoun')
48
50
  add_entry('die', 'RegularVerb')
51
+ add_entry('different', 'Adjective')
49
52
  add_entry('do', 'AuxiliaryDo')
50
53
  add_entry('do', 'IrregularVerbDo')
51
54
  add_entry('each', 'DistributiveDeterminer')
55
+ add_entry('each', 'Pronoun')
52
56
  add_entry('exist', 'RegularVerb')
53
57
  add_entry('false', 'Adjective')
54
58
  add_entry('far', 'Adverb')
@@ -74,6 +78,7 @@ unless defined?(Zenlish::Lang::Dictionary)
74
78
  add_entry('live', 'RegularVerb')
75
79
  add_entry('living', 'Adjective')
76
80
  add_entry('long', 'Adjective')
81
+ add_entry('make', 'IrregularVerb')
77
82
  add_entry('many', 'Quantifier')
78
83
  add_entry('maybe', 'AdverbMaybe')
79
84
  add_entry('me', 'PersonalPronoun')
@@ -100,6 +105,7 @@ unless defined?(Zenlish::Lang::Dictionary)
100
105
  add_entry('person', 'CommonNoun')
101
106
  add_entry('place', 'CommonNoun')
102
107
  add_entry('same', 'Adjective')
108
+ add_entry('same', 'Pronoun')
103
109
  add_entry('say', 'IrregularVerbSay')
104
110
  add_entry('see', 'IrregularVerb')
105
111
  add_entry('short', 'Adjective')
@@ -55,6 +55,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
55
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
+ # something that was not here before.
59
+ rule 'predicative_complement' => 'adverb_phrase_star'
58
60
 
59
61
  #################
60
62
  # Complex sentence
@@ -98,6 +100,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
98
100
  rule 'relative_clause' => 'RelativePronoun tense_phrase'
99
101
  # Sentence 3-Bxa 'Lisa sees a living thing that is very big.
100
102
  rule 'relative_clause' => 'RelativePronoun affirmation'
103
+ # Sentence 3-18b: something that was not here before.
104
+ rule 'relative_clause' => 'RelativePronoun negation'
101
105
  rule 'relative_clause' => 'identifying_clause'
102
106
  rule 'coordinate_clause' => 'Coordinator simple_sentence'
103
107
  # Sentence 3-11b K happens because J happens or because J does something.
@@ -134,6 +138,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
134
138
  rule 'pre_head_np' => 'determiners adjective_phrase_opt'
135
139
  rule 'head_np' => 'CommonNoun'
136
140
  rule 'head_np' => 'ProperNoun'
141
+ rule 'head_np' => 'Pronoun'
137
142
  rule 'head_np' => 'PersonalPronoun'
138
143
  rule 'head_np' => 'DemonstrativePronoun'
139
144
  rule 'head_np' => 'IndefinitePronoun'
@@ -241,6 +246,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
241
246
  ################
242
247
  # ADJVERB PHRASE
243
248
  ################
249
+ rule 'adverb_phrase_star' => 'adverb_phrase_star adverb_phrase'
250
+ rule 'adverb_phrase_star' => []
244
251
  rule 'adverb_phrase_opt' => 'adverb_phrase'
245
252
  rule 'adverb_phrase_opt' => []
246
253
  rule 'adverb_phrase' => 'premodifiers_adv head_adverb'
@@ -50,6 +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::Pronoun.new.freeze)
53
54
  aLexicon.add_terminal(WClasses::Quantifier.new.freeze)
54
55
  aLexicon.add_terminal(WClasses::RegularVerb.new.freeze)
55
56
  aLexicon.add_terminal(WClasses::RegularVerbWant.new.freeze)
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.1.22'
2
+ VERSION = '0.1.23'
3
3
  end
@@ -6,4 +6,4 @@ module Zenlish
6
6
  class FrontingQuantifier < Quantifier
7
7
  end # class
8
8
  end # module
9
- end # module
9
+ end # module
@@ -6,4 +6,4 @@ module Zenlish
6
6
  class Pronoun < WordClass
7
7
  end # class
8
8
  end # module
9
- end # module
9
+ end # module
@@ -7,4 +7,4 @@ module Zenlish
7
7
  class Quantifier < Determiner
8
8
  end # class
9
9
  end # module
10
- end # module
10
+ end # module
@@ -50,6 +50,7 @@ module Zenlish
50
50
  def be_ ; Lex::Literal.new('be', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
51
51
  literal2var('because', 'because')
52
52
  literal2var('become', 'became')
53
+ literal2var('become', 'become')
53
54
  literal2var('become', 'becomes')
54
55
  def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
55
56
  def before_as_adj ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adjective), 0) ; end
@@ -65,15 +66,22 @@ module Zenlish
65
66
  literal2var('cause', 'cause')
66
67
  literal2var('cause', 'caused')
67
68
  literal2var('cause', 'causes')
69
+ literal2var('contain', 'contain')
70
+ literal2var('contain', 'contains')
71
+ literal2var('container', 'container')
72
+ literal2var('container', 'containers')
68
73
  def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
69
74
  literal2var('die', 'die')
70
75
  literal2var('die', 'died')
71
76
  literal2var('die', 'dies')
77
+ literal2var('different', 'different')
72
78
  def do_ ; Lex::Literal.new('do', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
73
79
  def do_aux ; Lex::Literal.new('do', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
74
80
  def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
75
81
  def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
76
82
  literal2var('each', 'each', '_')
83
+ def each_ ; Lex::Literal.new('each', get_lexeme('each', WClasses::DistributiveDeterminer), 0) ; end
84
+ def each_as_pronoun ; Lex::Literal.new('each', get_lexeme('each', WClasses::Pronoun), 0) ; end
77
85
  literal2var('exist', 'exist')
78
86
  literal2var('exist', 'existed')
79
87
  literal2var('exist', 'exists')
@@ -117,6 +125,8 @@ module Zenlish
117
125
  literal2var('live', 'lived')
118
126
  literal2var('living', 'living')
119
127
  literal2var('long', 'long')
128
+ literal2var('make', 'made')
129
+ literal2var('make', 'make')
120
130
  literal2var('many', 'many')
121
131
  literal2var('maybe', 'maybe')
122
132
  literal2var('me', 'me')
@@ -146,7 +156,8 @@ module Zenlish
146
156
  literal2var('people', 'people')
147
157
  literal2var('person', 'person')
148
158
  literal2var('place', 'place')
149
- literal2var('same', 'same')
159
+ def same ; Lex::Literal.new('same', get_lexeme('same', WClasses::Adjective), 0) ; end
160
+ def same_as_pronoun ; Lex::Literal.new('same', get_lexeme('same', WClasses::Pronoun), 0) ; end
150
161
  literal2var('see', 'saw')
151
162
  literal2var('short', 'short')
152
163
  literal2var('side', 'side')
@@ -1347,6 +1358,73 @@ module Zenlish
1347
1358
  ]
1348
1359
  expect { subject.to_pforest(literals) }.not_to raise_error
1349
1360
  end
1361
+
1362
+ it 'should parse sample sentences from lesson 3-E' do
1363
+ # Sentence 3-17a definiendum: 'These things are different.'
1364
+ literals = [things, are, different, dot]
1365
+ expect { subject.to_pforest(literals) }.not_to raise_error
1366
+
1367
+ # Sentence 3-17b definiens: These things are not the same.
1368
+ # [I want this kind of thing, but you want something different.]
1369
+ literals = [ these, things, are, not_, the, same_as_pronoun, dot,
1370
+ i_pronoun, want, this, kind, of, thing, comma,
1371
+ but, you, want, something, different, dot
1372
+ ]
1373
+ expect { subject.to_pforest(literals) }.not_to raise_error
1374
+
1375
+ # Sentence 3-18a definiendum: 'J made K.'
1376
+ literals = [j_, made, k_, dot]
1377
+ expect { subject.to_pforest(literals) }.not_to raise_error
1378
+
1379
+ # Sentence 3-18b definiens: J did something to some things
1380
+ # and caused them to become parts of one different
1381
+ # kind of thing that was not here before.
1382
+ # K is this thing that now exists because of this.
1383
+ # [I used many small things to make this big thing.]
1384
+ # [J made K happen.] = J caused K to happen.
1385
+ literals = [ j_, did, something, to, some, things, and_,
1386
+ caused, them, to, become, parts, of, one, different, kind, of,
1387
+ thing, that, was, not_, here, before_adverb, dot,
1388
+ k_, is, this, thing, that, now, exists, because, of, this_as_pronoun, dot,
1389
+ i_pronoun, used, many, small, things, to, make, this, big, thing, dot,
1390
+ j_, made, k_, happen, dot,
1391
+ j_, caused, k_, to, happen, dot
1392
+ ]
1393
+ expect { subject.to_pforest(literals) }.not_to raise_error
1394
+
1395
+ # Sentence 3-19a definiendum: 'J contains K.'
1396
+ literals = [j_, contains, k_, dot]
1397
+ expect { subject.to_pforest(literals) }.not_to raise_error
1398
+
1399
+ # Sentence 3-19b definiens: K is inside J.
1400
+ # [I made something to contain all these small things.]
1401
+ # [Your body contains many parts.]
1402
+ literals = [ k_, is, inside, j_, dot,
1403
+ i_pronoun, made, something, to, contain, all, these, small, things, dot,
1404
+ your, body, contains, many, parts, dot,
1405
+ ]
1406
+ expect { subject.to_pforest(literals) }.not_to raise_error
1407
+
1408
+ # Sentence 3-20a definiendum: 'X is a container.'
1409
+ literals = [x_as_noun, is, a_as_art, container, dot]
1410
+ expect { subject.to_pforest(literals) }.not_to raise_error
1411
+
1412
+ # Sentence 3-20b definiens: X is something that people make because
1413
+ # they want to use it to contain other things.
1414
+ # [There are two things inside this container.]
1415
+ literals = [ x_as_noun, is, something, that, people, make, because,
1416
+ they, want, to, use, it_, to, contain, other, things, dot,
1417
+ there, are, two, things, inside, this, container, dot
1418
+ ]
1419
+ expect { subject.to_pforest(literals) }.not_to raise_error
1420
+
1421
+ # Sentence 3-Fxtra: Someone made these containers.
1422
+ # Each contains a different kind of animal.
1423
+ literals = [someone, made, these, containers, dot,
1424
+ each_as_pronoun, contains, a_as_art, different, kind, of, animal, dot
1425
+ ]
1426
+ expect { subject.to_pforest(literals) }.not_to raise_error
1427
+ end
1350
1428
  =begin
1351
1429
  TODO
1352
1430
 
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.22
4
+ version: 0.1.23
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-12-02 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley