zenlish 0.1.13 → 0.1.14

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: e6f916af0c3deb8ecbc0f46cf0ed8638d93e7ce33091070ae6549ca2a29d2b58
4
- data.tar.gz: 07b3103e32b1d53afd46492544592d139af39af2730290985c429cc82bcaf34a
3
+ metadata.gz: 01e0c43e4804049c23ed6eca8272d7ad968bd24aa136710317925eef885f3e58
4
+ data.tar.gz: eb9d2697419c830b2e4598ed4ed050d0413f6577237fd975376d61c9d79d7f1b
5
5
  SHA512:
6
- metadata.gz: 52030f24b26543dc6ad52abe9a00ce88407e4e7fb1e6201e9c5533b7f7718e1cb66af8d8281c7a4224c12bd6db7a1825f81b97899f9efaaeef560911671632f1
7
- data.tar.gz: 851109870bf5ecfcc65f0385c88c2aa5546a8cd3bbab59a498b0cae904857d11e0b5d835ad43327bfe923085b97fc79a56113c4a25f1d126f24ec611c555b7d6
6
+ metadata.gz: f36e1611d1e208f3d310c0efc82e584e37552764a3ea465b70cfbc69d88f5f952a53b8720f51191f50eb1540f7dd10088fed4111861dfd997c14c8aab0f7d337
7
+ data.tar.gz: 3801a22a41463933ba58ff4931cee97ffe1d1fc8c34462be16df9e64f2ec6790738d8febacf72c1178adf7bfb7951ebacdb69dc7113a69bbd4f2b259096b9441
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.1.14] - 2019-11-01
4
+ __Zenlish__ can parse all sentences in lesson 1 and 2-A..2-F from
5
+ [Learn These Words First](http://learnthesewordsfirst.com/).
6
+
7
+ ### Added
8
+ - Class `IrregularVerbKnow` to represent the verb `know`.
9
+ - Class `IrregularVerbThink` to represent the verb `think`.
10
+ - Class `PersonalPronoun` to represent the pronouns `I`, `you`.
11
+
12
+ ### Changed
13
+ - Folder structure under `lib` and `spec`.
14
+ - File `zparser_spec.rb`: tests include all sentences from lesson 2-E (136 sentences in total).
15
+ - `ZenlishGrammar`: new production rules for multiple sentence parsing, personal pronouns and dependent clauses without conjunctions.
16
+ - File `dictionary.rb`: new entries in lexicon `I`, `me`, `you`, `here`, `now`.
17
+ - File `README.md` Reshuffled sections, added one code snippet, updated the metrics table
18
+
3
19
  ## [0.1.13] - 2019-10-28
4
20
  __Zenlish__ can parse all sentences in lesson 1 and 2-A..2-E from
5
21
  [Learn These Words First](http://learnthesewordsfirst.com/).
data/README.md CHANGED
@@ -1,139 +1,181 @@
1
- # Zenlish
2
- [![Linux build Status](https://travis-ci.org/famished-tiger/Zenlish.svg?branch=master)](https://travis-ci.org/famished-tiger/Zenlish)
3
- [![Build status](https://ci.appveyor.com/api/projects/status/bef59whiacuv51yn?svg=true)](https://ci.appveyor.com/project/famished-tiger/zenlish)
4
- [![Gem Version](https://badge.fury.io/rb/zenlish.svg)](https://badge.fury.io/rb/zenlish)
5
- [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/famished-tiger/Zenlish/blob/master/LICENSE.txt)
6
- ### What is __Zenlish__ ?
7
-
8
- Zenlish = Zen + English
9
-
10
- __Zenlish__ will be a Controlled Natural Language based on English.
11
- A [Controlled Natural Language](https://en.wikipedia.org/wiki/Controlled_natural_language)
12
- is a subset of a natural language -here English- limited to specific problem domains.
13
-
14
- The goal of this project is to implement a toolkit for a subset of the English language.
15
-
16
-
17
- ### Design of Zenlish language
18
- #### Minimalism
19
- The name of the language is a combination of 'Zen' and 'English'.
20
- It reflects a desire to make Zenlish a simple language:
21
- - The focus is put on a simplified syntax,
22
- - A limited lexicon. Priority on most commonly used words.
23
-
24
-
25
- #### Expressiveness
26
- Zenlish should be rich enough to express ideas, facts in a fluid way (vs. contrived, artificial way).
27
- Litmus test: a Zenlish text should be easy to read to a English reading person.
28
-
29
- ### Zenlish as a library (gem)
30
- Over time, the zenlish gem will contain:
31
- - A tokenizer (tagging, lemmatizer)[TODO]
32
- - A lexicon [STARTED]
33
- - A context-free grammar [STARTED]
34
- - A parser [STARTED]
35
- - Feature unification (for number, gender agreement)[TODO]
36
- - A simplified ontology[TODO]
37
-
38
-
39
- ### What is the purpose of __Zenlish__ ?
40
- With __Zenlish__ it should be possible for a Ruby application to interact with
41
- users with a language that is close enough to English.
42
-
43
- ### Project status
44
-
45
- The project is still in inception. Currently, zenlish is able to parse all
46
- sentences of the first lesson.
47
-
48
- The intent is to deliver gem versions in small increments.
49
-
50
- #### Some project metrics (v. 0.1.13)
51
- |Metric|Value|
52
- |:-:|:-:|
53
- | Number of lemmas in lexicon | 77 |
54
- | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 39 |
55
- | Number of production rules in grammar | 103 |
56
- | Number of lessons covered | 13 |
57
- | Number of sentences in spec files | 118 |
58
-
59
-
60
- ### Roadmap
61
-
62
- Here a tentative roadmap:
63
-
64
- #### A) Ability to parse sentences from [Learn These Words First](http://learnthesewordsfirst.com/)
65
- *STARTED*. 14% complete
66
- This website advocates the idea of a multi-layered dictionary.
67
- At the core, there are about 300 essential words.
68
- The choice of these words is inspired by the semantic primitives of [NSM
69
- (Natural Semantic Metalanguage)](https://en.wikipedia.org/wiki/Natural_semantic_metalanguage).
70
- The essential words are introduced in twelve lessons. Each lesson put the words
71
- in exemplar sentences and pictures.
72
-
73
- The milestone sub-goals are:
74
- - To inject the 300 core words into Zenlish lexicon,
75
- - Zenlish should be able to parse all the example sentences
76
-
77
- #### B) Associate lexical features to terms in lexicon
78
- The sub-goals are:
79
- - To enrich the lexicon entries with lexical and syntactical features.
80
- - Zenlish should be able to derive the declensions of nouns, conjugation of verbs,
81
- - Also Zenlish should detect agreement errors
82
- - Ideally, Zenlish should have a lemmatizer
83
-
84
- #### C) Enrich lexicon entries with semantical features and relationships
85
- The sub-goals are:
86
- - To enrich the lexicon entries with lexical and syntactical features.
87
- - Zenlish should be able to derive the declensions of nouns, conjugation of verbs,
88
- - Also Zenlish should detect agreement errors
89
-
90
- #### D) Build a generic ontology and map Zenlish text to it.
91
- The sub-goals are:
92
- - To have a simplified ontology that covers the concepts covered in the lesson sentences.
93
- - Hopefully Zenlish should be answer to queries related to the lesson sentences.
94
-
95
- #### E) Capability to parse a complete book
96
- A good candidate book is "The Edge of the Sky" by Roberto Trotta (ISBN 978-0-465-04471-9 : hardcover, ISBN 978-0-465-04490-0 : ebook).
97
- Professor Trotta challenged himself by writing a book on Cosmology with the 1000 most used words. More details [here](http://robertotrotta.com/the-edge-of-the-sky/).
98
-
99
- In order to achieve this goal, Zenlish should:
100
- - Incorporate the 1000 words in its lexicon
101
- - Have a grammar that allows the parsing of the sentences in the book.
102
-
103
- #### F) Capability to interpret the meaning of a complete book
104
- Probably, far-fetched. But it will be nice to launch query to Zenlish to check if
105
- it has some understanding of the text it reads (i.e. has a semantic representation).
106
-
107
-
108
-
109
- ## Installation
110
-
111
- Add this line to your application's Gemfile:
112
-
113
- ```ruby
114
- gem 'zenlish'
115
- ```
116
-
117
- And then execute:
118
-
119
- $ bundle
120
-
121
- Or install it yourself as:
122
-
123
- $ gem install zenlish
124
-
125
- ## Usage
126
-
127
- TODO: Write usage instructions here
128
-
129
- ## Contributing
130
-
131
- Bug reports and pull requests are welcome on GitHub at https://github.com/famished-tiger/Zenlish. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
132
-
133
- ## License
134
-
135
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
136
-
137
- ## Code of Conduct
138
-
139
- Everyone interacting in the Zenlish project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/famished-tiger/Zenlish/blob/master/CODE_OF_CONDUCT.md).
1
+ # Zenlish
2
+ [![Linux build Status](https://travis-ci.org/famished-tiger/Zenlish.svg?branch=master)](https://travis-ci.org/famished-tiger/Zenlish)
3
+ [![Build status](https://ci.appveyor.com/api/projects/status/bef59whiacuv51yn?svg=true)](https://ci.appveyor.com/project/famished-tiger/zenlish)
4
+ [![Gem Version](https://badge.fury.io/rb/zenlish.svg)](https://badge.fury.io/rb/zenlish)
5
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/famished-tiger/Zenlish/blob/master/LICENSE.txt)
6
+ ### What is __Zenlish__ ?
7
+
8
+ Zenlish = Zen + English
9
+
10
+ __Zenlish__ will be a Controlled Natural Language based on English.
11
+ A [Controlled Natural Language](https://en.wikipedia.org/wiki/Controlled_natural_language)
12
+ is a subset of a natural language -here English- limited to specific problem domains.
13
+
14
+
15
+ ### What is the purpose of __Zenlish__ ?
16
+ The goal of this project is to implement a toolkit for a subset of the English language.
17
+ With __Zenlish__ it should be possible for a Ruby application to interact with
18
+ users with a language that is close enough to English.
19
+
20
+ ### Project status
21
+
22
+ The project is still in inception. Currently, zenlish is able to parse all
23
+ sentences of the first lesson.
24
+
25
+ The intent is to deliver gem versions in small increments.
26
+
27
+ #### Zenlish as a library (gem)
28
+ Over time, the zenlish gem will contain:
29
+ - A tokenizer (tagging, lemmatizer)[TODO]
30
+ - A lexicon [STARTED]
31
+ - A context-free grammar [STARTED]
32
+ - A parser [STARTED]
33
+ - Feature unification (for number, gender agreement)[TODO]
34
+ - A simplified ontology[TODO]
35
+
36
+
37
+ #### Some project metrics (v. 0.1.14)
38
+ |Metric|Value|
39
+ |:-:|:-:|
40
+ | Number of lemmas in dictionary | 80 |
41
+ | [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 43 |
42
+ | Number of production rules in grammar | 116 |
43
+ | Number of lessons covered | 14 |
44
+ | Number of sentences in spec files | 136 |
45
+
46
+
47
+ ## Installation...
48
+ ### ...with Rubygem
49
+ Install the gem yourself as:
50
+
51
+ $ gem install zenlish
52
+
53
+ ### ...with Bundler
54
+ Add this line to your application's Gemfile:
55
+
56
+ ```ruby
57
+ gem 'zenlish'
58
+ ```
59
+
60
+ And then execute:
61
+
62
+ $ bundle
63
+
64
+
65
+ ### Some code snippets
66
+
67
+ #### Interacting with the dictionary:
68
+ ```ruby
69
+ require 'zenlish'
70
+
71
+ # Retrieving a "word" (more precisely, a lexeme) from the dictionary.
72
+ lexeme = Zenlish::Lang::Dictionary.get_lexeme('move')
73
+
74
+ # What is the Ruby class of a lexeme?
75
+ p lexeme.class # => Zenlish::Lex::Lexeme
76
+
77
+ # What is the word class of verb 'move'?
78
+ p lexeme.wclass.class # => Zenlish::WClasses::RegularVerb
79
+
80
+ # Here is some Zenlish text to analyze:
81
+ some_text = 'one person can move to the same place.'
82
+ p some_text
83
+
84
+ some_text.scan(/(?:\w+)|[\.,:"]/).each do |entry|
85
+ lexeme = Zenlish::Lang::Dictionary.get_lexeme(entry)
86
+ p lexeme.wclass.class
87
+ end
88
+
89
+ # Loop result should be:
90
+ # Zenlish::WClasses::Cardinal
91
+ # Zenlish::WClasses::CommonNoun
92
+ # Zenlish::WClasses::ModalVerbCan
93
+ # Zenlish::WClasses::RegularVerb
94
+ # Zenlish::WClasses::Preposition
95
+ # Zenlish::WClasses::DefiniteArticle
96
+ # Zenlish::WClasses::Adjective
97
+ # Zenlish::WClasses::CommonNoun
98
+ # Rley::Syntax::Terminal
99
+ ```
100
+
101
+ More to come...
102
+
103
+ ## Principles behind the Zenlish language
104
+
105
+
106
+ #### Minimalism
107
+ The name of the language is a combination of 'Zen' and 'English'.
108
+ It reflects a desire to make Zenlish a simple language:
109
+ - The focus is put on a simplified syntax,
110
+ - A limited lexicon. Priority on most commonly used words.
111
+
112
+
113
+ #### Expressiveness
114
+ Zenlish should be rich enough to express ideas, facts in a fluid way (vs. contrived, artificial way).
115
+ Litmus test: a Zenlish text should be easy to read to a English reading person.
116
+
117
+
118
+ ## Roadmap
119
+
120
+ Here a tentative roadmap:
121
+
122
+ #### A) Ability to parse sentences from [Learn These Words First](http://learnthesewordsfirst.com/)
123
+ *STARTED*. 14.5% complete
124
+ This website advocates the idea of a multi-layered dictionary.
125
+ At the core, there are about 300 essential words.
126
+ The choice of these words is inspired by the semantic primitives of [NSM
127
+ (Natural Semantic Metalanguage)](https://en.wikipedia.org/wiki/Natural_semantic_metalanguage).
128
+ The essential words are introduced in twelve lessons. Each lesson put the words
129
+ in exemplar sentences and pictures.
130
+
131
+ The milestone sub-goals are:
132
+ - To inject the 300 core words into Zenlish lexicon,
133
+ - Zenlish should be able to parse all the example sentences
134
+
135
+ #### B) Associate lexical features to terms in lexicon
136
+ The sub-goals are:
137
+ - To enrich the lexicon entries with lexical and syntactical features.
138
+ - Zenlish should be able to derive the declensions of nouns, conjugation of verbs,
139
+ - Also Zenlish should detect agreement errors
140
+ - Ideally, Zenlish should have a lemmatizer
141
+
142
+ #### C) Enrich lexicon entries with semantical features and relationships
143
+ The sub-goals are:
144
+ - To enrich the lexicon entries with lexical and syntactical features.
145
+ - Zenlish should be able to derive the declensions of nouns, conjugation of verbs,
146
+ - Also Zenlish should detect agreement errors
147
+
148
+ #### D) Build a generic ontology and map Zenlish text to it.
149
+ The sub-goals are:
150
+ - To have a simplified ontology that covers the concepts covered in the lesson sentences.
151
+ - Hopefully Zenlish should be answer to queries related to the lesson sentences.
152
+
153
+ #### E) Capability to parse a complete book
154
+ A good candidate book is "The Edge of the Sky" by Roberto Trotta (ISBN 978-0-465-04471-9 : hardcover, ISBN 978-0-465-04490-0 : ebook).
155
+ Professor Trotta challenged himself by writing a book on Cosmology with the 1000 most used words. More details [here](http://robertotrotta.com/the-edge-of-the-sky/).
156
+
157
+ In order to achieve this goal, Zenlish should:
158
+ - Incorporate the 1000 words in its lexicon
159
+ - Have a grammar that allows the parsing of the sentences in the book.
160
+
161
+ #### F) Capability to interpret the meaning of a complete book
162
+ Probably, far-fetched. But it will be nice to launch query to Zenlish to check if
163
+ it has some understanding of the text it reads (i.e. has a semantic representation).
164
+
165
+
166
+
167
+ ## Usage
168
+
169
+ TODO: Write usage instructions here
170
+
171
+ ## Contributing
172
+
173
+ Bug reports and pull requests are welcome on GitHub at https://github.com/famished-tiger/Zenlish. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
174
+
175
+ ## License
176
+
177
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
178
+
179
+ ## Code of Conduct
180
+
181
+ Everyone interacting in the Zenlish project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/famished-tiger/Zenlish/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,109 @@
1
+ unless defined?(Zenlish::Lang::Dictionary)
2
+ module Zenlish
3
+ module Lang
4
+ require_relative '../lex/empty_lexicon_factory'
5
+ require_relative '../lex/lexical_entry'
6
+ require_relative '../lex/lexeme'
7
+
8
+ sandbox = Object.new
9
+ sandbox.extend(Zenlish::Lex::EmptyLexiconFactory)
10
+ Dictionary = sandbox.create_empty_lexicon
11
+
12
+ def self.add_entry(aLemma, aWClassName)
13
+ entry = Zenlish::Lex::LexicalEntry.new(aLemma)
14
+ wclass = Dictionary.name2terminal[aWClassName]
15
+ raise StandardError, "Undefined word class for '#{aLemma}'" unless wclass
16
+ lexeme = Zenlish::Lex::Lexeme.new(wclass, entry).freeze
17
+ Dictionary.add_entry(entry.freeze)
18
+ end
19
+
20
+ # Our minimalistic lexicon
21
+ add_entry('a', 'IndefiniteArticle')
22
+ add_entry('about', 'Preposition')
23
+ add_entry('above', 'Preposition')
24
+ add_entry('alive', 'Adjective')
25
+ add_entry('all', 'IndefiniteQuantifier')
26
+ add_entry('another', 'Adjective')
27
+ add_entry('as', 'ComparativeParticle')
28
+ add_entry('at', 'Preposition')
29
+ add_entry('bad', 'Adjective')
30
+ add_entry('be', 'AuxiliaryBe')
31
+ add_entry('be', 'IrregularVerbBe')
32
+ add_entry('because', 'SubordinatingConjunction')
33
+ add_entry('before', 'Adverb')
34
+ add_entry('before', 'SubordinatingConjunction')
35
+ add_entry('big', 'Adjective')
36
+ add_entry('can', 'ModalVerbCan')
37
+ add_entry('do', 'AuxiliaryDo')
38
+ add_entry('do', 'IrregularVerbDo')
39
+ add_entry('false', 'Adjective')
40
+ add_entry('far', 'Adverb')
41
+ add_entry('feel', 'IrregularVerb')
42
+ add_entry('for', 'Preposition')
43
+ add_entry('from', 'Preposition')
44
+ add_entry('good', 'Adjective')
45
+ add_entry('have', 'IrregularVerbHave')
46
+ add_entry('happen', 'RegularVerb')
47
+ add_entry('hear', 'IrregularVerb')
48
+ add_entry('here', 'Adverb')
49
+ add_entry('I', 'PersonalPronoun')
50
+ add_entry('if', 'SubordinatingConjunction')
51
+ add_entry('in', 'Preposition')
52
+ add_entry('inside', 'Preposition')
53
+ add_entry('kind', 'CommonNoun')
54
+ add_entry('know', 'IrregularVerbKnow')
55
+ add_entry('like', 'Preposition')
56
+ add_entry('living', 'Adjective')
57
+ add_entry('long', 'Adjective')
58
+ add_entry('many', 'IndefiniteQuantifier')
59
+ add_entry('me', 'PersonalPronoun')
60
+ add_entry('more', 'Adjective')
61
+ add_entry('move', 'RegularVerb')
62
+ add_entry('near to', 'Preposition')
63
+ add_entry('now', 'Adverb')
64
+ add_entry('not', 'AdverbNot')
65
+ add_entry('of', 'PrepositionOf')
66
+ add_entry('on', 'Preposition')
67
+ add_entry('one', 'Cardinal')
68
+ add_entry('other', 'Adjective')
69
+ add_entry('part', 'CommonNoun')
70
+ add_entry('people', 'CommonNoun')
71
+ add_entry('person', 'CommonNoun')
72
+ add_entry('place', 'CommonNoun')
73
+ add_entry('same', 'Adjective')
74
+ add_entry('say', 'IrregularVerbSay')
75
+ add_entry('see', 'IrregularVerb')
76
+ add_entry('short', 'Adjective')
77
+ add_entry('side', 'CommonNoun')
78
+ add_entry('small', 'Adjective')
79
+ add_entry('some', 'IndefiniteQuantifier')
80
+ add_entry('something', 'IndefinitePronoun')
81
+ add_entry('than', 'PrepositionThan')
82
+ add_entry('the', 'DefiniteArticle')
83
+ add_entry('then', 'LinkingAdverb')
84
+ add_entry('there', 'AdverbThere')
85
+ add_entry('thing', 'CommonNoun')
86
+ add_entry('think', 'IrregularVerbThink')
87
+ add_entry('this', 'DemonstrativeDeterminer')
88
+ add_entry('this', 'DemonstrativePronoun')
89
+ add_entry('this one', 'DemonstrativePronoun')
90
+ add_entry('time', 'CommonNoun')
91
+ add_entry('to', 'Preposition')
92
+ add_entry('touch', 'RegularVerb')
93
+ add_entry('true', 'Adjective')
94
+ add_entry('two', 'Cardinal')
95
+ add_entry('very', 'DegreeAdverb')
96
+ add_entry('want', 'RegularVerbWant')
97
+ add_entry('what','ConjunctivePronoun')
98
+ add_entry('with','Preposition')
99
+ add_entry('word', 'CommonNoun')
100
+ add_entry('you', 'PersonalPronoun')
101
+
102
+ # Punctuation signs...
103
+ add_entry(':', 'Colon')
104
+ add_entry(',', 'Comma')
105
+ add_entry('.', 'Period')
106
+ add_entry('"', 'Quote')
107
+ end # module
108
+ end # module
109
+ end # defined?
@@ -2,17 +2,25 @@
2
2
  # It is called Zenlish
3
3
 
4
4
  require 'rley' # Load the Rley parsing library
5
- require_relative '../lex/empty_lexicon'
5
+ require_relative 'dictionary'
6
6
 
7
7
  ########################################
8
8
  # Define a grammar for a highly English-like language
9
9
  builder = Rley::Syntax::GrammarBuilder.new do
10
- add_terminals(*$ZenlishLexicon.terminals)
10
+ add_terminals(*Zenlish::Lang::Dictionary.terminals)
11
+
12
+ rule 'zenlish' => 'prose'
13
+
14
+ # Temporary limitation: from 1 to 3 sentences
15
+ rule 'prose' => 'sentence'
16
+ rule 'prose' => 'sentence sentence'
17
+ rule 'prose' => 'sentence sentence sentence'
11
18
 
12
- rule 'language' => 'sentence'
13
19
  rule 'sentence' => 'simple_sentence Period'
14
20
  rule 'sentence' => 'complex_sentence Period'
15
21
  rule 'simple_sentence' => 'declarative_simple_sentence'
22
+
23
+ # Case of dropped ´that´ conjunction
16
24
  rule 'complex_sentence' => 'main_clause subordination_marker dependent_clause'
17
25
  rule 'complex_sentence' => 'main_clause Comma subordination_marker dependent_clause'
18
26
  rule 'complex_sentence' => 'subordination_marker dependent_clause Comma main_clause'
@@ -46,6 +54,10 @@ builder = Rley::Syntax::GrammarBuilder.new do
46
54
  rule 'simple_noun_phrase' => 'determiner nominal'
47
55
  rule 'simple_noun_phrase' => 'numeral nominal'
48
56
  rule 'simple_noun_phrase' => 'determiner numeral nominal'
57
+ rule 'simple_noun_phrase' => 'ProperNoun'
58
+ rule 'simple_noun_phrase' => 'PersonalPronoun'
59
+ rule 'simple_noun_phrase' => 'IndefinitePronoun'
60
+ rule 'simple_noun_phrase' => 'IndefinitePronoun Adjective'
49
61
  rule 'simple_noun_phrase' => 'simple_noun_phrase simple_noun_phrase verb_phrase'
50
62
 
51
63
  # Case: (all|many|some) one of (this|these)
@@ -53,11 +65,6 @@ builder = Rley::Syntax::GrammarBuilder.new do
53
65
 
54
66
  # CGE p.359, 360: <numeral> of + definite noun phrase
55
67
  rule 'simple_noun_phrase' => 'numeral_of noun_phrase'
56
- rule 'simple_noun_phrase' => 'ProperNoun'
57
- # rule 'simple_noun_phrase' => 'DemonstrativePronoun'
58
- rule 'simple_noun_phrase' => 'IndefinitePronoun'
59
- rule 'simple_noun_phrase' => 'IndefinitePronoun Adjective'
60
-
61
68
 
62
69
  rule 'compound_noun_phrase' => 'simple_noun_phrase propositional_phrase'
63
70
  rule 'compound_noun_phrase' => 'simple_noun_phrase comparative_clause'
@@ -79,21 +86,31 @@ builder = Rley::Syntax::GrammarBuilder.new do
79
86
  rule 'verb_phrase' => 'RegularVerb propositional_phrase'
80
87
  rule 'verb_phrase' => 'RegularVerbWant Preposition verb_group'
81
88
  rule 'verb_phrase' => 'RegularVerbWant Preposition verb_group noun_phrase'
89
+ rule 'verb_phrase' => 'RegularVerbWant simple_noun_phrase Preposition verb_group noun_phrase'
82
90
  rule 'verb_phrase' => 'IrregularVerbDo DemonstrativePronoun'
83
91
  rule 'verb_phrase' => 'IrregularVerbDo DemonstrativePronoun propositional_phrase'
84
92
  rule 'verb_phrase' => 'ModalVerbCan verb_group DemonstrativePronoun'
85
93
  rule 'verb_phrase' => 'IrregularVerbBe verb_be_complement'
94
+
95
+ # Cover case where ´that´ conjunction is dropped.
96
+ rule 'verb_phrase' => 'mental_verb dependent_clause'
97
+ rule 'verb_phrase' => 'IrregularVerbSay DemonstrativePronoun Preposition noun_phrase'
98
+ rule 'verb_phrase' => 'IrregularVerbSay Colon affirmative_sentence'
86
99
  rule 'verb_phrase' => 'IrregularVerbSay Colon Quote affirmative_sentence Period Quote'
100
+ rule 'verb_phrase' => 'IrregularVerbSay Preposition noun_phrase Colon Quote affirmative_sentence Period Quote'
101
+ rule 'mental_verb' => 'IrregularVerbKnow'
102
+ rule 'mental_verb' => 'IrregularVerbThink'
87
103
  rule 'verb_complement' => 'noun_phrase'
104
+ rule 'verb_complement' => 'adverb_phrase'
105
+ rule 'verb_complement' => 'noun_phrase adverb_phrase'
106
+
88
107
  # perception verb (hear, see, watch, notice, ...): verb + object + infinitive
89
108
  rule 'verb_complement' => 'simple_noun_phrase lexical_verb'
90
109
  rule 'verb_complement' => 'Adjective propositional_phrase'
91
- rule 'verb_complement' => 'noun_phrase IrregularVerbBe verb_be_complement'
92
- rule 'verb_complement' => 'adverb_phrase'
93
- rule 'verb_complement' => 'noun_phrase adverb_phrase'
94
110
  rule 'verb_be_complement' => 'noun_phrase'
95
111
  rule 'verb_be_complement' => 'adjective_as_complement' # Specific to be as lexical verb
96
112
  rule 'verb_be_complement' => 'propositional_phrase'
113
+ rule 'verb_be_complement' => 'noun_phrase adverb_phrase'
97
114
  rule 'adjective_as_complement' => 'DegreeAdverb Adjective'
98
115
  rule 'adjective_as_complement' => 'Adjective'
99
116
  rule 'adjective_as_complement' => 'Adjective comparative_clause'
@@ -110,6 +127,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
110
127
  rule 'lexical_verb' => 'IrregularVerbBe'
111
128
  rule 'lexical_verb' => 'IrregularVerbDo'
112
129
  rule 'lexical_verb' => 'IrregularVerbHave'
130
+ rule 'lexical_verb' => 'IrregularVerbKnow'
131
+ rule 'lexical_verb' => 'IrregularVerbThink'
113
132
  rule 'lexical_verb' => 'IrregularVerbSay'
114
133
  rule 'numeral' => 'Cardinal'
115
134
  rule 'comparative_clause' => 'comparative_start noun_phrase'
@@ -118,6 +137,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
118
137
  rule 'comparative_start' => 'PrepositionThan'
119
138
  rule 'comparative_start' => 'ComparativeParticle'
120
139
  rule 'adverb_phrase' => 'Adverb'
140
+ rule 'adverb_phrase' => 'Adverb Adverb' # 'here now'
121
141
  rule 'adverb_phrase' => 'Adverb propositional_phrase'
122
142
  rule 'propositional_phrase' => 'preposition propositional_complement'
123
143
  rule 'propositional_phrase' => 'preposition'
@@ -35,9 +35,12 @@ module Zenlish
35
35
  aLexicon.add_terminal(WClasses::IrregularVerbBe.new.freeze)
36
36
  aLexicon.add_terminal(WClasses::IrregularVerbDo.new.freeze)
37
37
  aLexicon.add_terminal(WClasses::IrregularVerbHave.new.freeze)
38
+ aLexicon.add_terminal(WClasses::IrregularVerbKnow.new.freeze)
38
39
  aLexicon.add_terminal(WClasses::IrregularVerbSay.new.freeze)
40
+ aLexicon.add_terminal(WClasses::IrregularVerbThink.new.freeze)
39
41
  aLexicon.add_terminal(WClasses::LinkingAdverb.new.freeze)
40
42
  aLexicon.add_terminal(WClasses::ModalVerbCan.new.freeze)
43
+ aLexicon.add_terminal(WClasses::PersonalPronoun.new.freeze)
41
44
  aLexicon.add_terminal(WClasses::Preposition.new.freeze)
42
45
  aLexicon.add_terminal(WClasses::PrepositionOf.new.freeze)
43
46
  aLexicon.add_terminal(WClasses::PrepositionThan.new.freeze)
@@ -1,17 +1,22 @@
1
1
  module Zenlish
2
2
  module Lex
3
- # TODO: document
3
+ # A word in the abstract sense; an individual, distinct item of a lexicon
4
+ # that belongs to a word class and of which a number of actual word forms
5
+ # may exist. For instance, the word forms: 'hide', 'hides', 'hid', 'hidden'
6
+ # relate to the lexeme for verb 'hide'. Also called 'dictionary word'.
4
7
  class Lexeme
5
8
  # @return Zenlish::WClasses::WordClass
6
9
  attr_reader :wclass
7
-
8
- # @return Zenlish::Lex::LexicalEntry
9
- attr_reader :entry
10
10
 
11
11
  def initialize(aWordClass, anEntry)
12
12
  @wclass = aWordClass
13
- @entry = anEntry
14
- @entry.add_lexeme(self)
13
+ @entry = anEntry.object_id
14
+ anEntry.add_lexeme(self)
15
+ end
16
+
17
+ # @return Zenlish::Lex::LexicalEntry
18
+ def entry
19
+ ObjectSpace._id2ref(@entry)
15
20
  end
16
21
 
17
22
  def lemma
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'zenlish_grammar'
3
+ require_relative '../lang/zenlish_grammar'
4
4
 
5
5
  module Zenlish
6
6
  class ZParser
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.1.13'
2
+ VERSION = '0.1.14'
3
3
  end
@@ -17,7 +17,9 @@ require_relative 'irregular_verb'
17
17
  require_relative 'irregular_verb_be'
18
18
  require_relative 'irregular_verb_do'
19
19
  require_relative 'irregular_verb_have'
20
+ require_relative 'irregular_verb_know'
20
21
  require_relative 'irregular_verb_say'
22
+ require_relative 'irregular_verb_think'
21
23
  require_relative 'definite_article'
22
24
  require_relative 'demonstrative_determiner'
23
25
  require_relative 'conjunctive_pronoun'
@@ -27,6 +29,7 @@ require_relative 'indefinite_pronoun'
27
29
  require_relative 'indefinite_quantifier'
28
30
  require_relative 'linking_adverb'
29
31
  require_relative 'modal_verb_can'
32
+ require_relative 'personal_pronoun'
30
33
  require_relative 'preposition'
31
34
  require_relative 'preposition_of'
32
35
  require_relative 'preposition_than'
@@ -0,0 +1,9 @@
1
+ require_relative 'irregular_verb'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # Irregular verb know
6
+ class IrregularVerbKnow < IrregularVerb
7
+ end # class
8
+ end # module
9
+ end # module
@@ -0,0 +1,9 @@
1
+ require_relative 'irregular_verb'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # Irregular verb know
6
+ class IrregularVerbThink < IrregularVerb
7
+ end # class
8
+ end # module
9
+ end # module
@@ -0,0 +1,12 @@
1
+ require_relative 'pronoun'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # Personal pronouns refer to people or things involved in the text.
6
+ # They change according to person, number, gender and case.
7
+ # Subject forms: I, you, he/she/it, we, you, they
8
+ # Object forms: Me, you, him, her, it, us, you, them
9
+ class PersonalPronoun < Pronoun
10
+ end # class
11
+ end # module
12
+ end # module
data/lib/zenlish.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  # for a Zenlish client.
5
5
 
6
6
  require_relative './zenlish/version'
7
- require_relative './zenlish/wclasses/all_word_classes'
7
+ require_relative './zenlish/lang/dictionary'
8
+ require_relative './zenlish/parser/zparser'
8
9
 
9
10
  # End of file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../spec_helper' # Use the RSpec framework
4
- require_relative '../../../lib/zenlish/parser/zenlish_grammar' # Load the class under test
4
+ require_relative '../../../lib/zenlish/lang/zenlish_grammar' # Load the class under test
5
5
 
6
6
  module Zenlish
7
7
  module Parser
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../spec_helper' # Use the RSpec framework
4
- require_relative '../support/minimal_lexicon'
5
4
  require_relative '../../../lib/zenlish/lex/literal'
5
+ require_relative '../support/minimal_lexicon'
6
6
  require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test
7
7
 
8
8
  module Zenlish
@@ -17,7 +17,7 @@ module Zenlish
17
17
  end # context
18
18
 
19
19
  def get_lexeme(aLemma, aWordClass = nil)
20
- $ZenlishLexicon.get_lexeme(aLemma, aWordClass)
20
+ Zenlish::Lang::Dictionary.get_lexeme(aLemma, aWordClass)
21
21
  end
22
22
 
23
23
  def self.literal2var(aLemma, aLiteral, aSuffix = '')
@@ -46,7 +46,7 @@ module Zenlish
46
46
  literal2var('big', 'big')
47
47
  literal2var('big', 'bigger')
48
48
  literal2var('can', 'can')
49
- literal2var('of', 'of')
49
+ def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
50
50
  def do_ ; Lex::Literal.new('do', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
51
51
  def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
52
52
  def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
@@ -57,28 +57,36 @@ module Zenlish
57
57
  literal2var('for', 'for', '_')
58
58
  literal2var('from', 'from')
59
59
  literal2var('good', 'good')
60
+ literal2var('happen', 'happened')
60
61
  literal2var('happen', 'happens')
61
62
  literal2var('have', 'has')
62
63
  literal2var('have', 'have')
63
64
  literal2var('hear', 'hears')
65
+ literal2var('here', 'here')
66
+ literal2var('I', 'I', '')
64
67
  literal2var('if', 'if', '_')
68
+ def i_pronoun ; Lex::Literal.new('I', get_lexeme('I'), 0) ; end
65
69
  literal2var('in', 'in', '_')
66
70
  literal2var('inside', 'inside')
67
71
  def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
68
72
  def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end
69
73
  literal2var('kind', 'kind')
74
+ literal2var('know', 'know')
70
75
  literal2var('know', 'knows')
71
76
  literal2var('like', 'like')
72
77
  literal2var('Lisa', 'Lisa')
73
78
  literal2var('living', 'living')
74
79
  literal2var('long', 'long')
75
80
  literal2var('many', 'many')
81
+ literal2var('me', 'me')
76
82
  literal2var('more', 'more')
77
83
  literal2var('move', 'move')
78
84
  literal2var('move', 'moved')
79
85
  literal2var('move', 'moves')
80
86
  literal2var('near to', 'near_to')
81
87
  literal2var('not', 'not', '_')
88
+ literal2var('now', 'now')
89
+ literal2var('of', 'of')
82
90
  literal2var('on', 'on')
83
91
  literal2var('one', 'one')
84
92
  literal2var('other', 'other')
@@ -115,11 +123,15 @@ module Zenlish
115
123
  literal2var('true', 'true', '_')
116
124
  literal2var('two', 'two')
117
125
  literal2var('very', 'very')
126
+ literal2var('want', 'want')
118
127
  literal2var('want', 'wants')
119
128
  def was ; Lex::Literal.new('was', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
129
+ def were ; Lex::Literal.new('were', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
120
130
  literal2var('what', 'what')
121
131
  literal2var('with', 'with')
122
132
  literal2var('word', 'words')
133
+ def x_as_noun ; Lex::Literal.new('X', get_lexeme('X'), 0) ; end
134
+ literal2var('you', 'you')
123
135
 
124
136
  def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end
125
137
  def comma ; Lex::Literal.new(',', get_lexeme(','), 0) ; end
@@ -652,6 +664,89 @@ module Zenlish
652
664
  literals = [tony, is, near_to, lisa, because, tony, moved, dot]
653
665
  expect { subject.parse(literals) }.not_to raise_error
654
666
  end
667
+
668
+ it 'should parse sample sentences from lesson 2-F' do
669
+ # Sentence 2-19a: 'Tony says: "I did X.".'
670
+ literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
671
+ expect { subject.parse(literals) }.not_to raise_error
672
+
673
+ # Sentence 2-19a definiendum: 'Tony says: "I did X.".'
674
+ literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot]
675
+ expect { subject.parse(literals) }.not_to raise_error
676
+
677
+ # Sentence 2-19a definiens: 'Tony says something about Tony. Tony says: Tony did X.'
678
+ literals = [tony, says, something, about, tony, dot,
679
+ tony, says, colon, tony, did, x_as_noun, dot]
680
+ expect { subject.parse(literals) }.not_to raise_error
681
+
682
+ # Sentence 2-19a: 'Tony says: "I see Lisa.".'
683
+ literals = [tony, says, colon, quote, i_pronoun, see, lisa, dot, quote, dot]
684
+ expect { subject.parse(literals) }.not_to raise_error
685
+
686
+ # Sentence 2-19b definiendum: 'Lisa says: "X happened to me.".'
687
+ literals = [lisa, says, colon, quote, x_as_noun, happened, to, me, dot, quote, dot]
688
+ expect { subject.parse(literals) }.not_to raise_error
689
+
690
+ # Sentence 2-19b definiens: 'Lisa says something about Lisa. Lisa says: X happened to Lisa.'
691
+ literals = [lisa, says, something, about, lisa, dot,
692
+ lisa, says, colon, x_as_noun, happened, to, lisa, dot]
693
+ expect { subject.parse(literals) }.not_to raise_error
694
+
695
+ # Sentence 2-19c: 'Lisa says: "Tony sees me."'
696
+ literals = [lisa, says, colon, quote, tony, sees, me, dot, quote, dot]
697
+ expect { subject.parse(literals) }.not_to raise_error
698
+
699
+ # Sentence 2-20a definiendum: 'Tony says to Lisa: "I can see you.".'
700
+ literals = [tony, says, to, lisa, colon, quote, i_pronoun, can, see, you, dot, quote, dot]
701
+ expect { subject.parse(literals) }.not_to raise_error
702
+
703
+ # Sentence 2-20a definiens: 'Tony says something about Lisa.
704
+ # Tony says this to Lisa. Tony says: Tony can see Lisa.'
705
+ literals = [tony, says, something, about, lisa, dot,
706
+ tony, says, this_as_pronoun, to, lisa, dot,
707
+ tony, says, colon, tony, can, see, lisa, dot]
708
+ expect { subject.parse(literals) }.not_to raise_error
709
+
710
+ # Sentence 2-20b: "I know you have something good."
711
+ literals = [i_pronoun, know, you, have, something, good, dot]
712
+ expect { subject.parse(literals) }.not_to raise_error
713
+
714
+ # Sentence 2-20c: "I want you to do something good for me."
715
+ literals = [i_pronoun, want, you, to, do_, something, good, for_, me, dot]
716
+ expect { subject.parse(literals) }.not_to raise_error
717
+
718
+ # Sentence 2-21a definiendum: 'Tony says: "X happens here.".'
719
+ literals = [tony, says, colon, quote, x_as_noun, happens, here, dot, quote, dot]
720
+ expect { subject.parse(literals) }.not_to raise_error
721
+
722
+ # Sentence 2-21a definiens: "Tony is in a place. Tony says: X happens in this place."
723
+ literals = [tony, is, in_, a_as_art, place, dot,
724
+ tony, says, colon, x_as_noun, happens, in_, this, place, dot]
725
+ expect { subject.parse(literals) }.not_to raise_error
726
+
727
+ # Sentence 2-21b: "Many people were here at one time."
728
+ literals = [many, people, were, here, at, one, time, dot]
729
+ expect { subject.parse(literals) }.not_to raise_error
730
+
731
+ # Sentence 2-22a definiendum: 'Lisa says: "X happens now.".'
732
+ literals = [lisa, says, colon, quote, x_as_noun, happens, now, dot, quote, dot]
733
+ expect { subject.parse(literals) }.not_to raise_error
734
+
735
+ # Sentence 2-21a definiens: 'Lisa says something at a time.
736
+ # Lisa says: X happens at this same time.'
737
+ literals = [lisa, says, something, at, a_as_art, time, dot,
738
+ lisa, says, colon, x_as_noun, happens, at, this, time, dot]
739
+ expect { subject.parse(literals) }.not_to raise_error
740
+
741
+ # Sentence 2-21b: "There are not many people here now."
742
+ literals = [there, are, not_, many, people, here, now , dot]
743
+ expect { subject.parse(literals) }.not_to raise_error
744
+
745
+ # Sentence 2-Fa: "Lisa says to Tony: "I can see many living things here."."
746
+ literals = [lisa, says, to, tony, colon, quote, i_pronoun,
747
+ can, see, many, living, things, here, dot, quote, dot]
748
+ expect { subject.parse(literals) }.not_to raise_error
749
+ end
655
750
  =begin
656
751
  TODO
657
752
 
@@ -1,134 +1,7 @@
1
- require_relative '../../../lib/zenlish/lex/empty_lexicon'
2
- require_relative '../../../lib/zenlish/lex/lexical_entry'
3
- require_relative '../../../lib/zenlish/lex/lexeme'
4
- require_relative '../../../lib/zenlish/lex/lexicon'
1
+ require_relative '../../../lib/zenlish/lang/dictionary'
5
2
 
3
+ # Add a few words to dictionary for testing purposes...
4
+ Zenlish::Lang::add_entry('Lisa', 'ProperNoun')
5
+ Zenlish::Lang::add_entry('Tony', 'ProperNoun')
6
+ Zenlish::Lang::add_entry('X', 'CommonNoun')
6
7
 
7
-
8
- adjective = $ZenlishLexicon.name2terminal['Adjective']
9
- adverb = $ZenlishLexicon.name2terminal['Adverb']
10
- adverb_not = $ZenlishLexicon.name2terminal['AdverbNot']
11
- adverb_there = $ZenlishLexicon.name2terminal['AdverbThere']
12
- degree_adverb = $ZenlishLexicon.name2terminal['DegreeAdverb']
13
- auxiliary_be = $ZenlishLexicon.name2terminal['AuxiliaryBe']
14
- auxiliary_do = $ZenlishLexicon.name2terminal['AuxiliaryDo']
15
- common_noun = $ZenlishLexicon.name2terminal['CommonNoun']
16
- linking_adverb = $ZenlishLexicon.name2terminal['LinkingAdverb']
17
- proper_noun = $ZenlishLexicon.name2terminal['ProperNoun']
18
- preposition = $ZenlishLexicon.name2terminal['Preposition']
19
- preposition_of = $ZenlishLexicon.name2terminal['PrepositionOf']
20
- preposition_than = $ZenlishLexicon.name2terminal['PrepositionThan']
21
- regular_verb = $ZenlishLexicon.name2terminal['RegularVerb']
22
- regular_verb_want = $ZenlishLexicon.name2terminal['RegularVerbWant']
23
- irregular_verb = $ZenlishLexicon.name2terminal['IrregularVerb']
24
- irregular_verb_be = $ZenlishLexicon.name2terminal['IrregularVerbBe']
25
- irregular_verb_do = $ZenlishLexicon.name2terminal['IrregularVerbDo']
26
- irregular_verb_have = $ZenlishLexicon.name2terminal['IrregularVerbHave']
27
- irregular_verb_say = $ZenlishLexicon.name2terminal['IrregularVerbSay']
28
- indefinite_pronoun = $ZenlishLexicon.name2terminal['IndefinitePronoun']
29
- conjunctive_pronoun = $ZenlishLexicon.name2terminal['ConjunctivePronoun']
30
- demonstrative_pronoun = $ZenlishLexicon.name2terminal['DemonstrativePronoun']
31
- demonstrative_determiner = $ZenlishLexicon.name2terminal['DemonstrativeDeterminer']
32
- definite_article = $ZenlishLexicon.name2terminal['DefiniteArticle']
33
- indefinite_article = $ZenlishLexicon.name2terminal['IndefiniteArticle']
34
- cardinal = $ZenlishLexicon.name2terminal['Cardinal']
35
- comparative_particle = $ZenlishLexicon.name2terminal['ComparativeParticle']
36
- indefinite_quantifier = $ZenlishLexicon.name2terminal['IndefiniteQuantifier']
37
- modal_verb_can = $ZenlishLexicon.name2terminal['ModalVerbCan']
38
- subordinating_conjunction = $ZenlishLexicon.name2terminal['SubordinatingConjunction']
39
-
40
- colon = $ZenlishLexicon.name2terminal['Colon']
41
- comma = $ZenlishLexicon.name2terminal['Comma']
42
- dot = $ZenlishLexicon.name2terminal['Period']
43
- quote = $ZenlishLexicon.name2terminal['Quote']
44
-
45
- def add_entry(aLemma, aWordClass)
46
- entry = Zenlish::Lex::LexicalEntry.new(aLemma)
47
- raise StandardError, "Undefined word class for '#{aLemma}'" unless aWordClass
48
- lexeme = Zenlish::Lex::Lexeme.new(aWordClass, entry).freeze
49
- $ZenlishLexicon.add_entry(entry.freeze)
50
- end
51
-
52
- # Our minimalistic lexicon
53
- add_entry('a', indefinite_article)
54
- add_entry('about', preposition)
55
- add_entry('above', preposition)
56
- add_entry('alive', adjective)
57
- add_entry('all', indefinite_quantifier)
58
- add_entry('another', adjective)
59
- add_entry('as', comparative_particle)
60
- add_entry('at', preposition)
61
- add_entry('bad', adjective)
62
- add_entry('be', auxiliary_be)
63
- add_entry('be', irregular_verb_be)
64
- add_entry('because', subordinating_conjunction)
65
- add_entry('before', adverb)
66
- add_entry('before', subordinating_conjunction)
67
- add_entry('big', adjective)
68
- add_entry('can', modal_verb_can)
69
- add_entry('do', auxiliary_do)
70
- add_entry('do', irregular_verb_do)
71
- add_entry('false', adjective)
72
- add_entry('far', adverb)
73
- add_entry('feel', irregular_verb)
74
- add_entry('for', preposition)
75
- add_entry('from', preposition)
76
- add_entry('good', adjective)
77
- add_entry('have', irregular_verb_have)
78
- add_entry('happen', regular_verb)
79
- add_entry('hear', irregular_verb)
80
- add_entry('if', subordinating_conjunction)
81
- add_entry('in', preposition)
82
- add_entry('inside', preposition)
83
- add_entry('kind', common_noun)
84
- add_entry('know', irregular_verb)
85
- add_entry('like', preposition)
86
- add_entry('Lisa', proper_noun)
87
- add_entry('living', adjective)
88
- add_entry('long', adjective)
89
- add_entry('many', indefinite_quantifier)
90
- add_entry('more', adjective)
91
- add_entry('move', regular_verb)
92
- add_entry('near to', preposition)
93
- add_entry('not', adverb_not)
94
- add_entry('of', preposition_of)
95
- add_entry('on', preposition)
96
- add_entry('one', cardinal)
97
- add_entry('other', adjective)
98
- add_entry('part', common_noun)
99
- add_entry('people', common_noun)
100
- add_entry('person', common_noun)
101
- add_entry('place', common_noun)
102
- add_entry('same', adjective)
103
- add_entry('say', irregular_verb_say)
104
- add_entry('see', irregular_verb)
105
- add_entry('short', adjective)
106
- add_entry('side', common_noun)
107
- add_entry('small', adjective)
108
- add_entry('some', indefinite_quantifier)
109
- add_entry('something', indefinite_pronoun)
110
- add_entry('than', preposition_than)
111
- add_entry('the', definite_article)
112
- add_entry('then', linking_adverb)
113
- add_entry('there', adverb_there)
114
- add_entry('thing', common_noun)
115
- add_entry('think', irregular_verb)
116
- add_entry('this', demonstrative_determiner)
117
- add_entry('this', demonstrative_pronoun)
118
- add_entry('this one', demonstrative_pronoun)
119
- add_entry('time', common_noun)
120
- add_entry('to', preposition)
121
- add_entry('Tony', proper_noun)
122
- add_entry('touch', regular_verb)
123
- add_entry('true', adjective)
124
- add_entry('two', cardinal)
125
- add_entry('very', degree_adverb)
126
- add_entry('want', regular_verb_want)
127
- add_entry('what',conjunctive_pronoun)
128
- add_entry('with',preposition)
129
- add_entry('word', common_noun)
130
-
131
- add_entry(':', colon)
132
- add_entry(',', comma)
133
- add_entry('.', dot)
134
- add_entry('"', quote)
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.13
4
+ version: 0.1.14
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-10-28 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -85,13 +85,13 @@ files:
85
85
  - Rakefile
86
86
  - appveyor.yml
87
87
  - lib/zenlish.rb
88
- - lib/zenlish/lex/empty_lexicon.rb
88
+ - lib/zenlish/lang/dictionary.rb
89
+ - lib/zenlish/lang/zenlish_grammar.rb
89
90
  - lib/zenlish/lex/empty_lexicon_factory.rb
90
91
  - lib/zenlish/lex/lexeme.rb
91
92
  - lib/zenlish/lex/lexical_entry.rb
92
93
  - lib/zenlish/lex/lexicon.rb
93
94
  - lib/zenlish/lex/literal.rb
94
- - lib/zenlish/parser/zenlish_grammar.rb
95
95
  - lib/zenlish/parser/zparser.rb
96
96
  - lib/zenlish/version.rb
97
97
  - lib/zenlish/wclasses/adjective.rb
@@ -120,12 +120,15 @@ files:
120
120
  - lib/zenlish/wclasses/irregular_verb_be.rb
121
121
  - lib/zenlish/wclasses/irregular_verb_do.rb
122
122
  - lib/zenlish/wclasses/irregular_verb_have.rb
123
+ - lib/zenlish/wclasses/irregular_verb_know.rb
123
124
  - lib/zenlish/wclasses/irregular_verb_say.rb
125
+ - lib/zenlish/wclasses/irregular_verb_think.rb
124
126
  - lib/zenlish/wclasses/lexical_verb.rb
125
127
  - lib/zenlish/wclasses/linking_adverb.rb
126
128
  - lib/zenlish/wclasses/modal_verb_can.rb
127
129
  - lib/zenlish/wclasses/noun.rb
128
130
  - lib/zenlish/wclasses/numeral.rb
131
+ - lib/zenlish/wclasses/personal_pronoun.rb
129
132
  - lib/zenlish/wclasses/preposition.rb
130
133
  - lib/zenlish/wclasses/preposition_of.rb
131
134
  - lib/zenlish/wclasses/preposition_than.rb
@@ -138,12 +141,12 @@ files:
138
141
  - lib/zenlish/wclasses/verb.rb
139
142
  - lib/zenlish/wclasses/word_class.rb
140
143
  - spec/spec_helper.rb
144
+ - spec/zenlish/lang/zenlish_grammar_spec.rb
141
145
  - spec/zenlish/lex/empty_lexicon_factory_spec.rb
142
146
  - spec/zenlish/lex/lexeme_spec.rb
143
147
  - spec/zenlish/lex/lexical_entry_spec.rb
144
148
  - spec/zenlish/lex/lexicon_spec.rb
145
149
  - spec/zenlish/lex/literal_spec.rb
146
- - spec/zenlish/parser/zenlish_grammar_spec.rb
147
150
  - spec/zenlish/parser/zparser_spec.rb
148
151
  - spec/zenlish/support/minimal_lexicon.rb
149
152
  - spec/zenlish/wclasses/common_noun_spec.rb
@@ -176,12 +179,12 @@ signing_key:
176
179
  specification_version: 4
177
180
  summary: A toolkit for the Zenlish language (a simplified English language).
178
181
  test_files:
182
+ - spec/zenlish/lang/zenlish_grammar_spec.rb
179
183
  - spec/zenlish/lex/empty_lexicon_factory_spec.rb
180
184
  - spec/zenlish/lex/lexeme_spec.rb
181
185
  - spec/zenlish/lex/lexical_entry_spec.rb
182
186
  - spec/zenlish/lex/lexicon_spec.rb
183
187
  - spec/zenlish/lex/literal_spec.rb
184
- - spec/zenlish/parser/zenlish_grammar_spec.rb
185
188
  - spec/zenlish/parser/zparser_spec.rb
186
189
  - spec/zenlish/wclasses/common_noun_spec.rb
187
190
  - spec/zenlish/wclasses/irregular_verb_spec.rb
@@ -1,7 +0,0 @@
1
- unless defined?($ZenlishLexicon)
2
- require_relative 'empty_lexicon_factory'
3
-
4
- sandbox = Object.new
5
- sandbox.extend(Zenlish::Lex::EmptyLexiconFactory)
6
- $ZenlishLexicon = sandbox.create_empty_lexicon
7
- end