zenlish 0.1.17 → 0.1.18

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: e70c4615014b90304856f70ea963c84b4439765909f4fb6fd3701e73e520a72f
4
- data.tar.gz: 36cbbdeb49d2154a20af9521b0177c75ae2c6a2aea1b6edfcc6026eabc5a383b
3
+ metadata.gz: 6ba42d383263196dd063d6da9c26cbdfa0a14ec073846a284e7abd7a5ec7d46c
4
+ data.tar.gz: ea3cd93a8a6f19809e6da1ddff463f5f70d4d7677ec510f350ccc8a858d68244
5
5
  SHA512:
6
- metadata.gz: f963c2562f5554a1b6976cd358f30c77838563774314585864110d733c2b35a5749d379bac40057004c4a848d222fd4e1eb207170b5f346bcea3fd7b4dbcfd40
7
- data.tar.gz: 366b4eefe238e059d83d1c5308933c9efc3647cb6697649d02e05c644b17960d6a21cec006d9cee76b4439349fb00c5a484261cee07d18c5a62fa70ce6f30c42
6
+ metadata.gz: d2e69ae33e38f657d9764a3a1cfe5a1059c9b43d9ea4508922e8381f59ee348921b646c985dd154756f251a2c4008a1facda0cd0ed148b680ecb09ee5c31e978
7
+ data.tar.gz: a441e9e60e7d6c0a7eeee25bbd7580cab3975c57ff44bc29328d810e35fe7f69a1958b03d81a51358169ce4843c927428e50274b955b7dd398837a6d88e50afb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.1.18] - 2019-11-26
4
+ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A from
5
+ [Learn These Words First](http://learnthesewordsfirst.com/).
6
+
7
+ ### Added
8
+ - Class `Coordinator` to represent the coordinating conjunctions `and`, `or`.
9
+
10
+ ### Changed
11
+ - Folder structure under `lib` and `spec`.
12
+ - File `zparser_spec.rb`: tests include all sentences from lesson 1, 2, and 3-A (235 sentences in total).
13
+ - `ZenlishGrammar`: new production rules added (especially for coordinators).
14
+ - File `dictionary.rb`: new entries in lexicon `and`, `belong`, `it`, `or`, `that`, `them`, `they`.
15
+ - File `README.md` Updated the metrics table
16
+
3
17
  ## [0.1.17] - 2019-11-25
4
18
  __Zenlish__ can parse all sentences in lesson 1 and 2-A..2-H from
5
19
  [Learn These Words First](http://learnthesewordsfirst.com/).
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-H. The parser is able to cope with syntactical
23
+ sentences from lessons 1-A up to 3-A. 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 | 102 |
42
- | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 45 |
43
- | Number of production rules in grammar | 137 |
44
- | Number of lessons covered | 16 |
45
- | Number of sentences in spec files | 207 |
41
+ | Number of lemmas in dictionary | 106 |
42
+ | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 53% |
43
+ | Number of production rules in grammar | 148 |
44
+ | Number of lessons covered | 17 |
45
+ | Number of sentences in spec files | 235 |
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*. 16.7% complete
124
+ *STARTED*. 17.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
@@ -21,10 +21,11 @@ unless defined?(Zenlish::Lang::Dictionary)
21
21
  add_entry('a', 'IndefiniteArticle')
22
22
  add_entry('about', 'Preposition')
23
23
  add_entry('above', 'Preposition')
24
- add_entry('after', 'Adverb')
24
+ add_entry('after', 'Adverb')
25
25
  add_entry('after', 'SubordinatingConjunction')
26
26
  add_entry('alive', 'Adjective')
27
27
  add_entry('all', 'IndefiniteQuantifier')
28
+ add_entry('and', 'Coordinator')
28
29
  add_entry('another', 'Adjective')
29
30
  add_entry('as', 'ComparativeParticle')
30
31
  add_entry('at', 'Preposition')
@@ -34,16 +35,17 @@ unless defined?(Zenlish::Lang::Dictionary)
34
35
  add_entry('because', 'SubordinatingConjunction')
35
36
  add_entry('before', 'Adverb')
36
37
  add_entry('before', 'SubordinatingConjunction')
37
- add_entry('below', 'Preposition')
38
+ add_entry('belong', 'RegularVerb')
39
+ add_entry('below', 'Preposition')
38
40
  add_entry('big', 'Adjective')
39
41
  add_entry('body', 'CommonNoun')
40
42
  add_entry('can', 'ModalVerbCan')
41
- add_entry('die', 'RegularVerb')
43
+ add_entry('die', 'RegularVerb')
42
44
  add_entry('do', 'AuxiliaryDo')
43
45
  add_entry('do', 'IrregularVerbDo')
44
46
  add_entry('false', 'Adjective')
45
47
  add_entry('far', 'Adverb')
46
- add_entry('far from', 'Preposition')
48
+ add_entry('far from', 'Preposition')
47
49
  add_entry('feel', 'IrregularLinkingVerb')
48
50
  add_entry('for', 'Preposition')
49
51
  add_entry('from', 'Preposition')
@@ -52,33 +54,36 @@ unless defined?(Zenlish::Lang::Dictionary)
52
54
  add_entry('happen', 'RegularVerb')
53
55
  add_entry('hear', 'IrregularVerb')
54
56
  add_entry('here', 'Adverb')
55
- add_entry('here', 'CommonNoun') # from here (works as a pronoun of a place)
57
+ add_entry('here', 'CommonNoun') # from here (works as a pronoun of a place)
56
58
  add_entry('I', 'PersonalPronoun')
57
59
  add_entry('if', 'SubordinatingConjunction')
58
60
  add_entry('in', 'Preposition')
59
61
  add_entry('inside', 'Preposition')
62
+ add_entry('it', 'PersonalPronoun')
60
63
  add_entry('kind', 'CommonNoun')
61
64
  add_entry('know', 'IrregularVerbKnow')
62
65
  add_entry('like', 'Preposition')
63
- add_entry('live', 'RegularVerb')
66
+ add_entry('live', 'RegularVerb')
64
67
  add_entry('living', 'Adjective')
65
68
  add_entry('long', 'Adjective')
66
69
  add_entry('many', 'IndefiniteQuantifier')
67
- add_entry('maybe', 'AdverbMaybe')
70
+ add_entry('maybe', 'AdverbMaybe')
68
71
  add_entry('me', 'PersonalPronoun')
69
- add_entry('moment', 'CommonNoun')
72
+ add_entry('moment', 'CommonNoun')
70
73
  add_entry('more', 'Adjective')
71
- add_entry('more', 'Adverb')
74
+ add_entry('more', 'Adverb')
72
75
  add_entry('move', 'RegularVerb')
73
- add_entry('much', 'Adverb')
74
- add_entry('near', 'Preposition')
76
+ add_entry('much', 'Adverb')
77
+ add_entry('near', 'Preposition')
75
78
  add_entry('near to', 'Preposition')
76
79
  add_entry('now', 'Adverb')
77
80
  add_entry('not', 'AdverbNot')
78
81
  add_entry('of', 'PrepositionOf')
79
82
  add_entry('on', 'Preposition')
83
+ add_entry('one', 'Adjective')
80
84
  add_entry('one', 'Cardinal')
81
85
  add_entry('one', 'IndefinitePronoun')
86
+ add_entry('or', 'Coordinator')
82
87
  add_entry('other', 'Adjective')
83
88
  add_entry('part', 'CommonNoun')
84
89
  add_entry('people', 'CommonNoun')
@@ -91,12 +96,15 @@ unless defined?(Zenlish::Lang::Dictionary)
91
96
  add_entry('side', 'CommonNoun')
92
97
  add_entry('small', 'Adjective')
93
98
  add_entry('some', 'IndefiniteQuantifier')
94
- add_entry('someone', 'IndefinitePronoun')
99
+ add_entry('someone', 'IndefinitePronoun')
95
100
  add_entry('something', 'IndefinitePronoun')
96
101
  add_entry('than', 'PrepositionThan')
102
+ add_entry('that', 'RelativePronoun')
97
103
  add_entry('the', 'DefiniteArticle')
104
+ add_entry('them', 'PersonalPronoun')
98
105
  add_entry('then', 'LinkingAdverb')
99
106
  add_entry('there', 'ExistentialThere')
107
+ add_entry('they', 'PersonalPronoun')
100
108
  add_entry('thing', 'CommonNoun')
101
109
  add_entry('think', 'IrregularVerbThink')
102
110
  add_entry('this', 'DemonstrativeDeterminer')
@@ -110,9 +118,9 @@ unless defined?(Zenlish::Lang::Dictionary)
110
118
  add_entry('two', 'IndefinitePronoun')
111
119
  add_entry('very', 'DegreeAdverb')
112
120
  add_entry('want', 'RegularVerbWant')
113
- add_entry('what','ConjunctivePronoun')
114
- add_entry('when','SubordinatingConjunction')
115
- add_entry('who','RelativePronoun')
121
+ add_entry('what','ConjunctivePronoun')
122
+ add_entry('when','SubordinatingConjunction')
123
+ add_entry('who','RelativePronoun')
116
124
  add_entry('with','Preposition')
117
125
  add_entry('word', 'CommonNoun')
118
126
  add_entry('you', 'PersonalPronoun')
@@ -61,6 +61,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
61
61
  rule 'negated_predicate_sentence' => 'conjunctive_prefix IrregularVerbBe AdverbNot predicative_complement'
62
62
  rule 'predicative_complement' => 'noun_phrase'
63
63
  rule 'predicative_complement' => 'adjective_phrase comparative_clause_opt'
64
+ # 3-02d J is one that does this.
65
+ rule 'predicative_complement' => 'adjective_phrase relative_clause_opt'
64
66
  # 2-28b X is alive before this moment.
65
67
  rule 'predicative_complement' => 'adjective_phrase adverb_phrase noun_phrase'
66
68
  # X is far from the start.
@@ -71,9 +73,15 @@ builder = Rley::Syntax::GrammarBuilder.new do
71
73
  #################
72
74
  # Case of dropped ´that´ conjunction
73
75
  rule 'complex_sentence' => 'main_clause comma_opt subordinated_clause'
76
+ rule 'complex_sentence' => 'main_clause comma_opt relative_clause'
77
+ rule 'complex_sentence' => 'main_clause comma_opt coordinate_clause'
74
78
  rule 'complex_sentence' => 'subordinated_clause Comma main_clause'
79
+ # 3-03b If J is not true, then K is true.
80
+ rule 'complex_sentence' => 'subordinated_clause Comma LinkingAdverb main_clause'
75
81
  # CGE 287d: verb + direct object + infinitive clause (without to)
76
82
  rule 'complex_sentence' => 'main_clause infinitive_clause'
83
+ # Colon used to introduce an explanatory sentence.
84
+ rule 'complex_sentence' => 'main_clause Colon simple_sentence'
77
85
  rule 'comma_opt' => 'Comma'
78
86
  rule 'comma_opt' => []
79
87
 
@@ -96,25 +104,31 @@ builder = Rley::Syntax::GrammarBuilder.new do
96
104
  rule 'comparative_start' => 'ComparativeParticle'
97
105
  rule 'conjunctive_prefix' => 'ConjunctivePronoun noun_phrase verb_phrase'
98
106
  rule 'identifying_clause' => 'RelativePronoun verb_phrase'
107
+ rule 'relative_clause_opt' => 'relative_clause'
108
+ rule 'relative_clause_opt' => []
109
+ rule 'relative_clause' => 'RelativePronoun tense_phrase'
110
+ rule 'relative_clause' => 'identifying_clause'
111
+ rule 'coordinate_clause' => 'Coordinator simple_sentence'
99
112
 
100
113
 
101
114
  ##############
102
115
  # TENSE PHRASE
103
116
  ##############
104
117
  rule 'tense_phrase' => 'noun_phrase tense_opt verb_phrase'
105
- rule 'negative_tense_phrase' => 'noun_phrase tense AdverbNot verb_phrase'
118
+ rule 'negative_tense_phrase' => 'noun_phrase tense AdverbNot verb_phrase'
106
119
  rule 'tense_opt' => 'tense'
107
120
  rule 'tense_opt' => []
108
121
  rule 'tense' => 'AuxiliaryBe'
109
- rule 'tense' => 'AuxiliaryDo'
122
+ rule 'tense' => 'AuxiliaryDo'
110
123
  rule 'tense' => 'ModalVerbCan'
111
-
124
+
112
125
  #############
113
126
  # NOUN PHRASE
114
127
  #############
115
128
  rule 'noun_phrase_opt' => 'noun_phrase'
116
129
  rule 'noun_phrase_opt' => []
117
130
  rule 'noun_phrase' => 'pre_head_np head_np post_head_np'
131
+ rule 'noun_phrase' => 'noun_phrase Coordinator noun_phrase'
118
132
  # someone, somebody, something, somewhere; no one, nobody, nothing,
119
133
  # nowhere; anyone, anybody, anything, anywhere; everyone, everybody,
120
134
  # everything, everywhere, the attributive adjective phrase occurs as a postmodifier
@@ -123,7 +137,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
123
137
  rule 'head_np' => 'ProperNoun'
124
138
  rule 'head_np' => 'PersonalPronoun'
125
139
  rule 'head_np' => 'DemonstrativePronoun'
126
- rule 'head_np' => 'IndefinitePronoun'
140
+ rule 'head_np' => 'IndefinitePronoun'
127
141
  # rule 'head_np' => 'Cardinal' # ... as indefinite pronoun in complement "There were three pies. I ate one."
128
142
  rule 'post_head_np' => 'adjective_phrase_opt prepositional_phrases clause_noun_opt'
129
143
  rule 'clause_noun_opt' => 'clause_noun'
@@ -164,7 +178,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
164
178
  #############
165
179
  rule 'verb_phrase' => 'pre_head_vp head_vp post_head_vp'
166
180
  # Rule specific to linking/copular verbs (CEG 288b). Example: I feel very bad.
167
- rule 'verb_phrase' => 'pre_head_vp linking_verb adjective_phrase'
181
+ rule 'verb_phrase' => 'pre_head_vp linking_verb adjective_phrase'
168
182
  rule 'pre_head_vp' => 'adverb_phrase_opt'
169
183
  rule 'head_vp' => 'lexical_verb'
170
184
  rule 'head_vp' => 'IrregularVerbSay direct_speech'
@@ -173,13 +187,13 @@ builder = Rley::Syntax::GrammarBuilder.new do
173
187
  # Cover case where ´that´ conjunction is dropped.
174
188
  rule 'head_vp' => 'mental_verb dependent_clause'
175
189
  # ex. 2-23c
176
- rule 'head_vp' => 'mental_verb identifying_clause'
190
+ rule 'head_vp' => 'mental_verb identifying_clause'
177
191
 
178
192
  rule 'post_head_vp' => 'noun_phrase_opt adverb_phrase_opt prepositional_phrases adverb_phrase_opt'
179
193
  rule 'lexical_verb' => 'RegularVerb'
180
194
  rule 'lexical_verb' => 'RegularVerbWant'
181
195
  rule 'lexical_verb' => 'IrregularVerb'
182
- rule 'lexical_verb' => 'IrregularLinkingVerb'
196
+ rule 'lexical_verb' => 'IrregularLinkingVerb'
183
197
  rule 'lexical_verb' => 'IrregularVerbBe'
184
198
  rule 'lexical_verb' => 'IrregularVerbDo'
185
199
  rule 'lexical_verb' => 'IrregularVerbHave'
@@ -17,22 +17,23 @@ 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
+ aLexicon.add_terminal(WClasses::AdverbMaybe.new.freeze)
21
21
  aLexicon.add_terminal(WClasses::AdverbNot.new.freeze)
22
22
  aLexicon.add_terminal(WClasses::AuxiliaryBe.new.freeze)
23
23
  aLexicon.add_terminal(WClasses::AuxiliaryDo.new.freeze)
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::Coordinator.new.freeze)
27
28
  aLexicon.add_terminal(WClasses::DefiniteArticle.new.freeze)
28
- aLexicon.add_terminal(WClasses::ExistentialThere.new.freeze)
29
+ aLexicon.add_terminal(WClasses::ExistentialThere.new.freeze)
29
30
  aLexicon.add_terminal(WClasses::IndefiniteArticle.new.freeze)
30
31
  aLexicon.add_terminal(WClasses::DegreeAdverb.new.freeze)
31
32
  aLexicon.add_terminal(WClasses::DemonstrativeDeterminer.new.freeze)
32
33
  aLexicon.add_terminal(WClasses::ConjunctivePronoun.new.freeze)
33
34
  aLexicon.add_terminal(WClasses::DemonstrativePronoun.new.freeze)
34
35
  aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
35
- aLexicon.add_terminal(WClasses::IrregularLinkingVerb.new.freeze)
36
+ aLexicon.add_terminal(WClasses::IrregularLinkingVerb.new.freeze)
36
37
  aLexicon.add_terminal(WClasses::IrregularVerb.new.freeze)
37
38
  aLexicon.add_terminal(WClasses::IrregularVerbBe.new.freeze)
38
39
  aLexicon.add_terminal(WClasses::IrregularVerbDo.new.freeze)
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.1.17'
2
+ VERSION = '0.1.18'
3
3
  end
@@ -10,6 +10,7 @@ require_relative 'auxiliary_do'
10
10
  require_relative 'cardinal'
11
11
  require_relative 'comparative_particle'
12
12
  require_relative 'common_noun'
13
+ require_relative 'coordinator'
13
14
  require_relative 'degree_adverb'
14
15
  require_relative 'definite_article'
15
16
  require_relative 'existential_there'
@@ -0,0 +1,12 @@
1
+ require_relative 'conjunction'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # A coordinator (aka coordinating conjunction) is a word or phrase that
6
+ # can join words, phrases, and clauses that share some logical relationhip
7
+ # Common coordinators are enumerated in the FANBOYS acronym:
8
+ # For, And, Nor, But, Or, Yet and So.
9
+ class Coordinator < WordClass
10
+ end # class
11
+ end # module
12
+ end # module
@@ -38,6 +38,7 @@ module Zenlish
38
38
  literal2var('alive', 'alive')
39
39
  literal2var('all', 'all')
40
40
  def am ; Lex::Literal.new('am', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
41
+ literal2var('and', 'and', '_')
41
42
  literal2var('another', 'another')
42
43
  def are ; Lex::Literal.new('are', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
43
44
  literal2var('as', 'as')
@@ -47,6 +48,7 @@ module Zenlish
47
48
  literal2var('because', 'because')
48
49
  def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
49
50
  def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end
51
+ literal2var('belong', 'belongs')
50
52
  literal2var('below', 'below')
51
53
  literal2var('big', 'big')
52
54
  literal2var('big', 'bigger')
@@ -74,6 +76,7 @@ module Zenlish
74
76
  literal2var('happen', 'happens')
75
77
  literal2var('have', 'has')
76
78
  literal2var('have', 'have')
79
+ literal2var('hear', 'heard')
77
80
  literal2var('hear', 'hears')
78
81
  def here ; Lex::Literal.new('here', get_lexeme('here', WClasses::Adverb), 0) ; end
79
82
  def here_as_noun ; Lex::Literal.new('here', get_lexeme('here', WClasses::CommonNoun), 0) ; end
@@ -81,6 +84,7 @@ module Zenlish
81
84
  literal2var('if', 'if', '_')
82
85
  literal2var('in', 'in', '_')
83
86
  literal2var('inside', 'inside')
87
+ literal2var('it', 'it', '_')
84
88
  literal2var('J', 'j', '_')
85
89
  def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
86
90
  def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end
@@ -102,7 +106,7 @@ module Zenlish
102
106
  def more_as_adverb ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adverb), 0) ; end
103
107
  literal2var('move', 'move')
104
108
  literal2var('move', 'moved')
105
- literal2var('move', 'moving')
109
+ literal2var('move', 'moving')
106
110
  literal2var('move', 'moves')
107
111
  literal2var('much', 'much')
108
112
  literal2var('near', 'near')
@@ -112,7 +116,9 @@ module Zenlish
112
116
  literal2var('of', 'of')
113
117
  literal2var('on', 'on')
114
118
  def one ; Lex::Literal.new('one', get_lexeme('one', WClasses::Cardinal), 0) ; end
119
+ def one_as_adj ; Lex::Literal.new('one', get_lexeme('one', WClasses::Adjective), 0) ; end
115
120
  def one_as_pronoun ; Lex::Literal.new('one', get_lexeme('one', WClasses::IndefinitePronoun), 0) ; end
121
+ literal2var('or', 'or', '_')
116
122
  literal2var('other', 'other')
117
123
  literal2var('part', 'part')
118
124
  literal2var('part', 'parts')
@@ -120,6 +126,7 @@ module Zenlish
120
126
  literal2var('person', 'person')
121
127
  literal2var('place', 'place')
122
128
  literal2var('same', 'same')
129
+ literal2var('see', 'saw')
123
130
  literal2var('short', 'short')
124
131
  literal2var('side', 'side')
125
132
  literal2var('small', 'small')
@@ -132,8 +139,11 @@ module Zenlish
132
139
  literal2var('someone', 'someone')
133
140
  literal2var('something', 'something')
134
141
  literal2var('the', 'the')
142
+ literal2var('them', 'them')
135
143
  literal2var('then', 'then', '_')
144
+ literal2var('they', 'they')
136
145
  literal2var('than', 'than')
146
+ literal2var('that', 'that')
137
147
  literal2var('there', 'there')
138
148
  literal2var('thing', 'thing')
139
149
  literal2var('thing', 'things')
@@ -149,6 +159,7 @@ module Zenlish
149
159
  literal2var('to', 'to')
150
160
  literal2var('Tony', 'Tony')
151
161
  literal2var('touch', 'touch')
162
+ literal2var('touch', 'touched')
152
163
  literal2var('touch', 'touching')
153
164
  literal2var('true', 'true', '_')
154
165
  def two ; Lex::Literal.new('two', get_lexeme('two', WClasses::Cardinal), 0) ; end
@@ -963,7 +974,7 @@ module Zenlish
963
974
 
964
975
  # Sentence 2-29a definiendum "You think maybe X is true."
965
976
  literals = [you, think, maybe, x_as_noun, is, true_, dot]
966
- expect { subject.to_ptree(literals) }.not_to raise_error
977
+ expect { subject.to_pforest(literals) }.not_to raise_error
967
978
 
968
979
  # Sentence 2-29b definiens "You think something like X
969
980
  # can be true. You do not know X is true.
@@ -978,7 +989,7 @@ module Zenlish
978
989
  # Sentence 2-30a definiendum "J is below K."
979
990
  literals = [j_, is, below, k_, dot]
980
991
  expect { subject.to_pforest(literals) }.not_to raise_error
981
-
992
+
982
993
  # Sentence 2-30b definiens "K is above J.
983
994
  # [I am touching this thing below me.]
984
995
  literals = [ j_, is, below, k_, dot,
@@ -992,7 +1003,105 @@ module Zenlish
992
1003
  literals = [ someone, sees, thing, dot,
993
1004
  the, body, of, this, thing, is_aux, not_, moving, dot
994
1005
  ]
995
- expect { subject.to_pforest(literals) }.not_to raise_error
1006
+ expect { subject.to_pforest(literals) }.not_to raise_error
1007
+ end
1008
+
1009
+ it 'should parse sample sentences from lesson 3-A' do
1010
+ # Sentence 3-01a definiendum: 'J happens to something that does K.'
1011
+ literals = [j_, happens, to, something, that, does, k_, dot]
1012
+ expect { subject.to_pforest(literals) }.not_to raise_error
1013
+
1014
+ # Sentence 3-01b definiens: 'J happens to something.
1015
+ # This same something does K.
1016
+ # [Tony has something that Lisa wants.]'
1017
+ literals = [j_, happens, to, something, dot,
1018
+ this, same, thing, does, k_, dot,
1019
+ tony, has, something, that, lisa, wants, dot
1020
+ ]
1021
+ expect { subject.to_pforest(literals) }.not_to raise_error
1022
+
1023
+ # Sentence 3-02a definiendum: 'J is true, and K is true.'
1024
+ literals = [j_, is, true_, comma, and_, k_, is, true_, dot]
1025
+ expect { subject.to_pforest(literals) }.not_to raise_error
1026
+
1027
+ # Sentence 3-02b definiens: 'These two things are true: J is true.
1028
+ # K is true.'
1029
+ # [Lisa sees Tony, and Tony sees Lisa.]'
1030
+ literals = [these, two, things, are, true_, colon, j_, is, true_, dot,
1031
+ k_, is, true_, dot,
1032
+ lisa, sees, tony, comma, and_, tony, sees, lisa, dot
1033
+ ]
1034
+ expect { subject.to_pforest(literals) }.not_to raise_error
1035
+
1036
+ # Sentence 3-02c definiendum: 'J and K do X.'
1037
+ literals = [j_, and_, k_, do_, x_as_noun, dot]
1038
+ expect { subject.to_pforest(literals) }.not_to raise_error
1039
+
1040
+ # Sentence 3-02d definiens: 'These two things do X.
1041
+ # J is one that does this.
1042
+ # K is another that does this.'
1043
+ # [Tony and Lisa want to see me.]
1044
+ # [I see Tony and Lisa.]'
1045
+ literals = [these, two, things, do_, x_as_noun, dot,
1046
+ j_, is, one_as_adj, that, does, this_as_pronoun, dot,
1047
+ k_, is, another, that, does, this_as_pronoun, dot,
1048
+ tony, and_, lisa, want, to, see, me, dot,
1049
+ i_pronoun, see, tony, and_, lisa, dot
1050
+ ]
1051
+ expect { subject.to_pforest(literals) }.not_to raise_error
1052
+
1053
+ # Sentence 3-03a definiendum: 'J is true, or K is true.'
1054
+ literals = [j_, is, true_, comma, or_, k_, is, true_, dot]
1055
+ expect { subject.to_pforest(literals) }.not_to raise_error
1056
+
1057
+ # Sentence 3-03b definiens: 'If J is not true, then K is true.
1058
+ # [Tony saw me, or Lisa heard me.]
1059
+ literals = [if_, j_, is, not_, true_, comma,
1060
+ then_, k_, is, true_, dot,
1061
+ tony, saw, me, comma, or_, lisa, heard, me, dot
1062
+ ]
1063
+ expect { subject.to_pforest(literals) }.not_to raise_error
1064
+
1065
+ # Sentence 3-03c definiendum: 'J or K does this.'
1066
+ literals = [j_, or_, k_, does, this_as_pronoun, dot]
1067
+ expect { subject.to_pforest(literals) }.not_to raise_error
1068
+
1069
+ # Sentence 3-03d definiendum: 'If J does not do this, then K does this.'
1070
+ literals = [if_, j_, does_aux, not_, do_, this_as_pronoun, comma,
1071
+ then_, k_, does, this_as_pronoun, dot]
1072
+ expect { subject.to_pforest(literals) }.not_to raise_error
1073
+
1074
+ # Sentence 3-03e: '[Lisa or Tony said something.]
1075
+ # [This belongs to Tony or Lisa.]'
1076
+ literals = [lisa, or_, tony, said, something, dot,
1077
+ this_as_pronoun, belongs, to, tony, or_, lisa, dot
1078
+ ]
1079
+ expect { subject.to_pforest(literals) }.not_to raise_error
1080
+
1081
+ # Sentence 3-04a definiendum: 'It does something.'
1082
+ literals = [it_, does, something, dot
1083
+ ]
1084
+ expect { subject.to_pforest(literals) }.not_to raise_error
1085
+
1086
+ # Sentence 3-04b definiens: 'This thing does something.'
1087
+ # [I touched this thing, and it moved.]
1088
+ literals = [this, thing, does, something, dot,
1089
+ i_pronoun, touched, this, thing, comma, and_, it_, moved, dot
1090
+ ]
1091
+ expect { subject.to_pforest(literals) }.not_to raise_error
1092
+
1093
+ # Sentence 3-04c definiendum: 'They do something.'
1094
+ literals = [they, does, something, dot
1095
+ ]
1096
+ expect { subject.to_pforest(literals) }.not_to raise_error
1097
+
1098
+ # Sentence 3-04d definiens: 'These things or people do something.'
1099
+ # [Something happens to them.] = Something happens to these things or people.
1100
+ literals = [ these, things, or_, people, do_, something, dot,
1101
+ something, happens, to, them, dot,
1102
+ something, happens, to, these, things, or_, people, dot
1103
+ ]
1104
+ expect { subject.to_pforest(literals) }.not_to raise_error
996
1105
  end
997
1106
  =begin
998
1107
  TODO
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.17
4
+ version: 0.1.18
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-25 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -108,6 +108,7 @@ files:
108
108
  - lib/zenlish/wclasses/comparative_particle.rb
109
109
  - lib/zenlish/wclasses/conjunction.rb
110
110
  - lib/zenlish/wclasses/conjunctive_pronoun.rb
111
+ - lib/zenlish/wclasses/coordinator.rb
111
112
  - lib/zenlish/wclasses/definite_article.rb
112
113
  - lib/zenlish/wclasses/degree_adverb.rb
113
114
  - lib/zenlish/wclasses/demonstrative_determiner.rb