zenlish 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +7 -7
- data/lib/zenlish/lang/dictionary.rb +5 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +6 -2
- data/lib/zenlish/lex/empty_lexicon_factory.rb +1 -0
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/all_word_classes.rb +1 -0
- data/lib/zenlish/wclasses/possessive_determiner.rb +11 -0
- data/spec/zenlish/parser/zparser_spec.rb +83 -1
- data/zenlish.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b7091b27c821ece14a4fef18ad5ad23a195ca9d4e9e49738169209e00a6969b
|
4
|
+
data.tar.gz: 48a9f36d5be3895ebe1dce139cf9c69e86acbaa0e1a0d460f36122c13a889d3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b82cda45ccc61c7a4af5a81652b824816604f28387e3f48ff3e673db4914395cf7a288f20b898d3c96e8ae11d94c0f0badb00ced5c202c1baafca60316f3e14
|
7
|
+
data.tar.gz: 529877d53bff5860d03cf1fb349a539b5837f49ac8152557239d7f09ebd2be082c22a6229c921faf357658dab6713b9227aa58f3a5f84f367843939c198a9c17
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## [0.1.19] - 2019-11-28
|
4
|
+
__Zenlish__ can parse all sentences in lesson 1, 2 and 3-A .. 3-B from
|
5
|
+
[Learn These Words First](http://learnthesewordsfirst.com/).
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- Class `PossessiveDeterminer` to represent the posessive determiners `its`, `my`, `their`, `your`.
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- File `zenlish.gemspec`: raise an error if Rley version is < 0.7.06
|
12
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 1, 2, and 3-B (255 sentences in total).
|
13
|
+
- `ZenlishGrammar`: new production rules added (especially for posessive determiners a multiple sentences in direct speech).
|
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.18] - 2019-11-26
|
4
18
|
__Zenlish__ can parse all sentences in lesson 1, 2 and 3-A from
|
5
19
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
@@ -8,7 +22,6 @@ __Zenlish__ can parse all sentences in lesson 1, 2 and 3-A from
|
|
8
22
|
- Class `Coordinator` to represent the coordinating conjunctions `and`, `or`.
|
9
23
|
|
10
24
|
### Changed
|
11
|
-
- Folder structure under `lib` and `spec`.
|
12
25
|
- File `zparser_spec.rb`: tests include all sentences from lesson 1, 2, and 3-A (235 sentences in total).
|
13
26
|
- `ZenlishGrammar`: new production rules added (especially for coordinators).
|
14
27
|
- File `dictionary.rb`: new entries in lexicon `and`, `belong`, `it`, `or`, `that`, `them`, `they`.
|
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-
|
23
|
+
sentences from lessons 1-A up to 3-B. 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 |
|
42
|
-
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) |
|
43
|
-
| Number of production rules in grammar |
|
44
|
-
| Number of lessons covered |
|
45
|
-
| Number of sentences in spec files |
|
41
|
+
| Number of lemmas in dictionary | 111 |
|
42
|
+
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 56% |
|
43
|
+
| Number of production rules in grammar | 151 |
|
44
|
+
| Number of lessons covered | 18 |
|
45
|
+
| Number of sentences in spec files | 255 |
|
46
46
|
|
47
47
|
|
48
48
|
## Installation...
|
@@ -121,7 +121,7 @@ Litmus test: a Zenlish text should be easy to read to a English reading person.
|
|
121
121
|
Here a tentative roadmap:
|
122
122
|
|
123
123
|
#### A) Ability to parse sentences from [Learn These Words First](http://learnthesewordsfirst.com/)
|
124
|
-
*STARTED*.
|
124
|
+
*STARTED*. 18.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
|
@@ -60,6 +60,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
60
60
|
add_entry('in', 'Preposition')
|
61
61
|
add_entry('inside', 'Preposition')
|
62
62
|
add_entry('it', 'PersonalPronoun')
|
63
|
+
add_entry('its', 'PossessiveDeterminer')
|
63
64
|
add_entry('kind', 'CommonNoun')
|
64
65
|
add_entry('know', 'IrregularVerbKnow')
|
65
66
|
add_entry('like', 'Preposition')
|
@@ -74,9 +75,11 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
74
75
|
add_entry('more', 'Adverb')
|
75
76
|
add_entry('move', 'RegularVerb')
|
76
77
|
add_entry('much', 'Adverb')
|
78
|
+
add_entry('my', 'PossessiveDeterminer')
|
77
79
|
add_entry('near', 'Preposition')
|
78
80
|
add_entry('near to', 'Preposition')
|
79
81
|
add_entry('now', 'Adverb')
|
82
|
+
add_entry('now', 'CommonNoun')
|
80
83
|
add_entry('not', 'AdverbNot')
|
81
84
|
add_entry('of', 'PrepositionOf')
|
82
85
|
add_entry('on', 'Preposition')
|
@@ -103,6 +106,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
103
106
|
add_entry('the', 'DefiniteArticle')
|
104
107
|
add_entry('them', 'PersonalPronoun')
|
105
108
|
add_entry('then', 'LinkingAdverb')
|
109
|
+
add_entry('their', 'PossessiveDeterminer')
|
106
110
|
add_entry('there', 'ExistentialThere')
|
107
111
|
add_entry('they', 'PersonalPronoun')
|
108
112
|
add_entry('thing', 'CommonNoun')
|
@@ -124,6 +128,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
124
128
|
add_entry('with','Preposition')
|
125
129
|
add_entry('word', 'CommonNoun')
|
126
130
|
add_entry('you', 'PersonalPronoun')
|
131
|
+
add_entry('your', 'PossessiveDeterminer')
|
127
132
|
|
128
133
|
# Punctuation signs...
|
129
134
|
add_entry(':', 'Colon')
|
@@ -107,8 +107,12 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
107
107
|
rule 'relative_clause_opt' => 'relative_clause'
|
108
108
|
rule 'relative_clause_opt' => []
|
109
109
|
rule 'relative_clause' => 'RelativePronoun tense_phrase'
|
110
|
+
# Sentence 3-Bxa 'Lisa sees a living thing that is very big.
|
111
|
+
rule 'relative_clause' => 'RelativePronoun IrregularVerbBe predicative_complement'
|
110
112
|
rule 'relative_clause' => 'identifying_clause'
|
111
113
|
rule 'coordinate_clause' => 'Coordinator simple_sentence'
|
114
|
+
# Implicit subject. 3-05b: I saw this thing and touched some of its parts.
|
115
|
+
rule 'coordinate_clause' => 'Coordinator verb_phrase'
|
112
116
|
|
113
117
|
|
114
118
|
##############
|
@@ -162,7 +166,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
162
166
|
# Central determiners: article, demonstrative or possessive
|
163
167
|
rule 'central_determiners' => 'article'
|
164
168
|
rule 'central_determiners' => 'demonstrative'
|
165
|
-
|
169
|
+
rule 'central_determiners' => 'PossessiveDeterminer'
|
166
170
|
rule 'central_determiners' => []
|
167
171
|
rule 'article' => 'DefiniteArticle' # 'the'
|
168
172
|
rule 'article' => 'IndefiniteArticle' # 'a/an', .., any, some, that, those,
|
@@ -206,7 +210,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
206
210
|
|
207
211
|
rule 'mental_verb' => 'IrregularVerbKnow'
|
208
212
|
rule 'mental_verb' => 'IrregularVerbThink'
|
209
|
-
rule 'direct_speech' => 'Colon Quote
|
213
|
+
rule 'direct_speech' => 'Colon Quote prose Quote'
|
210
214
|
rule 'direct_speech' => 'Preposition noun_phrase Colon Quote declarative_simple_sentence Period Quote'
|
211
215
|
rule 'direct_speech' => 'Colon declarative_simple_sentence'
|
212
216
|
|
@@ -44,6 +44,7 @@ module Zenlish
|
|
44
44
|
aLexicon.add_terminal(WClasses::LinkingAdverb.new.freeze)
|
45
45
|
aLexicon.add_terminal(WClasses::ModalVerbCan.new.freeze)
|
46
46
|
aLexicon.add_terminal(WClasses::PersonalPronoun.new.freeze)
|
47
|
+
aLexicon.add_terminal(WClasses::PossessiveDeterminer.new.freeze)
|
47
48
|
aLexicon.add_terminal(WClasses::Preposition.new.freeze)
|
48
49
|
aLexicon.add_terminal(WClasses::PrepositionOf.new.freeze)
|
49
50
|
aLexicon.add_terminal(WClasses::PrepositionThan.new.freeze)
|
data/lib/zenlish/version.rb
CHANGED
@@ -33,6 +33,7 @@ require_relative 'indefinite_quantifier'
|
|
33
33
|
require_relative 'linking_adverb'
|
34
34
|
require_relative 'modal_verb_can'
|
35
35
|
require_relative 'personal_pronoun'
|
36
|
+
require_relative 'possessive_determiner'
|
36
37
|
require_relative 'preposition'
|
37
38
|
require_relative 'preposition_of'
|
38
39
|
require_relative 'preposition_than'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'determiner'
|
2
|
+
|
3
|
+
module Zenlish
|
4
|
+
module WClasses
|
5
|
+
# Possessive determiner (aka possessive adjective) is a class of determiner,
|
6
|
+
# that is used to modify nouns to denote possession my, your, her, his, its.
|
7
|
+
# they aren't used with other determiners like the, a/an, or this.
|
8
|
+
class PossessiveDeterminer < Determiner
|
9
|
+
end # class
|
10
|
+
end # module
|
11
|
+
end # module
|
@@ -31,6 +31,7 @@ module Zenlish
|
|
31
31
|
# to variables that themselves return Literal objects.
|
32
32
|
# For instance, next line will create a variable called 'alive'
|
33
33
|
literal2var('a', 'a', '_as_art')
|
34
|
+
literal2var('a', 'an')
|
34
35
|
literal2var('about', 'about')
|
35
36
|
literal2var('above', 'above')
|
36
37
|
def after_adverb ; Lex::Literal.new('after', get_lexeme('after', WClasses::Adverb), 0) ; end
|
@@ -48,6 +49,7 @@ module Zenlish
|
|
48
49
|
literal2var('because', 'because')
|
49
50
|
def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
|
50
51
|
def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end
|
52
|
+
literal2var('belong', 'belong')
|
51
53
|
literal2var('belong', 'belongs')
|
52
54
|
literal2var('below', 'below')
|
53
55
|
literal2var('big', 'big')
|
@@ -85,6 +87,7 @@ module Zenlish
|
|
85
87
|
literal2var('in', 'in', '_')
|
86
88
|
literal2var('inside', 'inside')
|
87
89
|
literal2var('it', 'it', '_')
|
90
|
+
literal2var('its', 'its')
|
88
91
|
literal2var('J', 'j', '_')
|
89
92
|
def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
90
93
|
def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end
|
@@ -109,10 +112,12 @@ module Zenlish
|
|
109
112
|
literal2var('move', 'moving')
|
110
113
|
literal2var('move', 'moves')
|
111
114
|
literal2var('much', 'much')
|
115
|
+
literal2var('my', 'my')
|
112
116
|
literal2var('near', 'near')
|
113
117
|
literal2var('near to', 'near_to')
|
114
118
|
literal2var('not', 'not', '_')
|
115
|
-
|
119
|
+
def now ; Lex::Literal.new('now', get_lexeme('now', WClasses::Adverb), 0) ; end
|
120
|
+
def now_as_noun ; Lex::Literal.new('now', get_lexeme('now', WClasses::CommonNoun), 0) ; end
|
116
121
|
literal2var('of', 'of')
|
117
122
|
literal2var('on', 'on')
|
118
123
|
def one ; Lex::Literal.new('one', get_lexeme('one', WClasses::Cardinal), 0) ; end
|
@@ -139,6 +144,7 @@ module Zenlish
|
|
139
144
|
literal2var('someone', 'someone')
|
140
145
|
literal2var('something', 'something')
|
141
146
|
literal2var('the', 'the')
|
147
|
+
literal2var('their', 'their')
|
142
148
|
literal2var('them', 'them')
|
143
149
|
literal2var('then', 'then', '_')
|
144
150
|
literal2var('they', 'they')
|
@@ -176,6 +182,7 @@ module Zenlish
|
|
176
182
|
literal2var('word', 'words')
|
177
183
|
def x_as_noun ; Lex::Literal.new('X', get_lexeme('X'), 0) ; end
|
178
184
|
literal2var('you', 'you')
|
185
|
+
literal2var('you', 'your')
|
179
186
|
|
180
187
|
def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end
|
181
188
|
def comma ; Lex::Literal.new(',', get_lexeme(','), 0) ; end
|
@@ -1103,8 +1110,83 @@ module Zenlish
|
|
1103
1110
|
]
|
1104
1111
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
1105
1112
|
end
|
1113
|
+
|
1114
|
+
it 'should parse sample sentences from lesson 3-B' do
|
1115
|
+
# Sentence 3-05a definiendum: 'This is its X.'
|
1116
|
+
literals = [this_as_pronoun, is, its, x_as_noun, dot
|
1117
|
+
]
|
1118
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1119
|
+
|
1120
|
+
# Sentence 3-05b definiens: 'This X belongs to it.
|
1121
|
+
# [I saw this thing and touched some of its parts.]
|
1122
|
+
# [These things are their things.] = These things belong to them.
|
1123
|
+
literals = [this, x_as_noun, belongs, to, it_, dot,
|
1124
|
+
i_pronoun, saw, this, thing, and_, touched, some, of, its, parts, dot
|
1125
|
+
]
|
1126
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1127
|
+
|
1128
|
+
# Sentence 3-05c definiendum: 'These things are their things.'
|
1129
|
+
literals = [these, things, are, their, things, dot
|
1130
|
+
]
|
1131
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1132
|
+
|
1133
|
+
# Sentence 3-05d definiens: 'These things belong to them.
|
1134
|
+
literals = [these, things, belong, to, them, dot,
|
1135
|
+
]
|
1136
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1137
|
+
|
1138
|
+
# Sentence 3-06a definiendum: 'This is your X.'
|
1139
|
+
literals = [this_as_pronoun, is, your, x_as_noun, dot,
|
1140
|
+
]
|
1141
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1142
|
+
|
1143
|
+
# Sentence 3-06b definien: 'This X belongs to you.
|
1144
|
+
# [You feel something touching your body.]
|
1145
|
+
literals = [this, x_as_noun, belongs, to, you, dot,
|
1146
|
+
you, feel, something, touching, your, body, dot
|
1147
|
+
]
|
1148
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1149
|
+
|
1150
|
+
# Sentence 3-07a definiendum: 'This is my X.'
|
1151
|
+
literals = [this_as_pronoun, is, my, x_as_noun, dot,
|
1152
|
+
]
|
1153
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1154
|
+
|
1155
|
+
# Sentence 3-07b definiens: 'This X belongs to me.
|
1156
|
+
# [I do not want you to touch my body.]
|
1157
|
+
literals = [this, x_as_noun, belongs, to, me, dot,
|
1158
|
+
i_pronoun, do_aux, not_, want, to, touch, my, body, dot
|
1159
|
+
]
|
1160
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1161
|
+
|
1162
|
+
# Sentence 3-08a definiendum: 'There is an X here.'
|
1163
|
+
literals = [there, is, an, x_as_noun, here, dot,
|
1164
|
+
]
|
1165
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1166
|
+
|
1167
|
+
# Sentence 3-0bb definiens: 'X is some kind of thing.
|
1168
|
+
# There is one of this kind of thing here.
|
1169
|
+
# This is not one that you said something about a short time before now.
|
1170
|
+
# [I did not know there was a person in this place.]
|
1171
|
+
literals = [x_as_noun, is, some, kind, of, thing, dot,
|
1172
|
+
there, is, one, of, this, kind, of, thing, here, dot,
|
1173
|
+
this_as_pronoun, is, not_, one_as_adj, that, you, said, something,
|
1174
|
+
about, a_as_art, short, time, before, now_as_noun, dot
|
1175
|
+
]
|
1176
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1177
|
+
|
1178
|
+
# Sentence 3-Bxa 'Lisa sees a living thing that is very big.
|
1179
|
+
# Lisa says: "I see one living thing. Its body is bigger than my body.", dot
|
1180
|
+
literals = [
|
1181
|
+
lisa, sees, a_as_art, living, thing, that, is, very, big, dot,
|
1182
|
+
lisa, says, colon, quote, i_pronoun, see, one, living, thing, dot,
|
1183
|
+
its, body, is, bigger, than, my, body, dot, quote, dot
|
1184
|
+
]
|
1185
|
+
expect { subject.to_pforest(literals) }.not_to raise_error
|
1186
|
+
end
|
1106
1187
|
=begin
|
1107
1188
|
TODO
|
1189
|
+
|
1108
1190
|
Lesson 2.C
|
1109
1191
|
|
1110
1192
|
Xtra:
|
data/zenlish.gemspec
CHANGED
@@ -54,7 +54,7 @@ Gem::Specification.new do |spec|
|
|
54
54
|
PkgExtending.pkg_documentation(spec)
|
55
55
|
|
56
56
|
# Runtime dependencies
|
57
|
-
spec.add_dependency 'rley', '~> 0.7.
|
57
|
+
spec.add_dependency 'rley', '~> 0.7.06'
|
58
58
|
|
59
59
|
spec.add_development_dependency "bundler", "~> 2.0"
|
60
60
|
spec.add_development_dependency "rake", "~> 12.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenlish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.7.
|
19
|
+
version: 0.7.06
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.7.
|
26
|
+
version: 0.7.06
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/zenlish/wclasses/noun.rb
|
133
133
|
- lib/zenlish/wclasses/numeral.rb
|
134
134
|
- lib/zenlish/wclasses/personal_pronoun.rb
|
135
|
+
- lib/zenlish/wclasses/possessive_determiner.rb
|
135
136
|
- lib/zenlish/wclasses/preposition.rb
|
136
137
|
- lib/zenlish/wclasses/preposition_of.rb
|
137
138
|
- lib/zenlish/wclasses/preposition_than.rb
|