zenlish 0.1.09 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -2
- data/README.md +6 -6
- data/lib/zenlish/lex/empty_lexicon_factory.rb +1 -0
- data/lib/zenlish/parser/zenlish_grammar.rb +13 -4
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/all_word_classes.rb +1 -0
- data/lib/zenlish/wclasses/irregular_verb_be.rb +1 -1
- data/lib/zenlish/wclasses/irregular_verb_do.rb +9 -0
- data/lib/zenlish/wclasses/irregular_verb_have.rb +1 -1
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +8 -1
- data/spec/zenlish/parser/zparser_spec.rb +49 -5
- data/spec/zenlish/support/minimal_lexicon.rb +6 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f22b9d962fc961e2216a043ef79b1deb793dca96ae528256dd785aa77894baa8
|
4
|
+
data.tar.gz: 246147e969e4606805914f4ea8313c19d6ed7a650b1c592cf2c20fac34374181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c3e2adf7b59659b45cea513a990dd9b14334bfe390f9f6bd4076ddcff299ab2dbf57768fade51257d2916e8a642522de9a3fddb1f73facb15629feb3a3a5a1f
|
7
|
+
data.tar.gz: de4bfa611281c709a6ab176d9cf0b50614eae1b9674f28d85a1a3f16c1367ee4e57ea4ca49ba285c7e3ec9c54452c4c62e808afc9d51a12a686bddc48e0d1c28
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.10] - 2019-10-23
|
4
|
+
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-B from
|
5
|
+
[Learn These Words First](http://learnthesewordsfirst.com/).
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- Class `ConjunctivePronoun` to represent the conjunctive `what`.
|
9
|
+
- Class `IrregularVerbDo` to represent the lexical verb `do`.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 2-B (87 sentences in total).
|
13
|
+
- `ZenlishGrammar`: added support for complex sentence with one dependent clause like: "Something happens to Lisa because Tony does this.".
|
14
|
+
- File `minimal_lexicon.rb`: new entries in lexicon `because`, `do`, `happen`, with.
|
15
|
+
- File `README.md` Updated the metrics table, added AppVeyor badge
|
16
|
+
|
17
|
+
## [0.1.09] - 2019-10-22
|
4
18
|
__Zenlish__ can parse all sentences in lesson 1 and 2-A from
|
5
19
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
6
20
|
|
@@ -10,7 +24,7 @@ __Zenlish__ can parse all sentences in lesson 1 and 2-A from
|
|
10
24
|
- File `.appveyor.yml`
|
11
25
|
|
12
26
|
### Changed
|
13
|
-
- File `zparser_spec.rb`: tests include all sentences from lesson
|
27
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 2-A (77 sentences in total).
|
14
28
|
- `ZenlishGrammar`: added support for sentence like: "This thing is like two of the other things.".
|
15
29
|
- File `minimal_lexicon.rb`: new entries in lexicon `have`, `like`, `part`.
|
16
30
|
- File `README.md` Updated the metrics table, added AppVeyor badge
|
data/README.md
CHANGED
@@ -47,14 +47,14 @@ sentences of the first lesson.
|
|
47
47
|
|
48
48
|
The intent is to deliver gem versions in small increments.
|
49
49
|
|
50
|
-
#### Some project metrics (v. 0.1.
|
50
|
+
#### Some project metrics (v. 0.1.10)
|
51
51
|
|Metric|Value|
|
52
52
|
|:-:|:-:|
|
53
|
-
| Number of lemmas in lexicon |
|
54
|
-
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) |
|
55
|
-
| Number of production rules in grammar |
|
56
|
-
| Number of lessons covered |
|
57
|
-
| Number of sentences in spec files |
|
53
|
+
| Number of lemmas in lexicon | 61 |
|
54
|
+
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 30 |
|
55
|
+
| Number of production rules in grammar | 85 |
|
56
|
+
| Number of lessons covered | 10 |
|
57
|
+
| Number of sentences in spec files | 87 |
|
58
58
|
|
59
59
|
|
60
60
|
### Roadmap
|
@@ -32,6 +32,7 @@ module Zenlish
|
|
32
32
|
aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
|
33
33
|
aLexicon.add_terminal(WClasses::IrregularVerb.new.freeze)
|
34
34
|
aLexicon.add_terminal(WClasses::IrregularVerbBe.new.freeze)
|
35
|
+
aLexicon.add_terminal(WClasses::IrregularVerbDo.new.freeze)
|
35
36
|
aLexicon.add_terminal(WClasses::IrregularVerbHave.new.freeze)
|
36
37
|
aLexicon.add_terminal(WClasses::IrregularVerbSay.new.freeze)
|
37
38
|
aLexicon.add_terminal(WClasses::LinkingAdverb.new.freeze)
|
@@ -11,10 +11,18 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
11
11
|
|
12
12
|
rule 'language' => 'sentence'
|
13
13
|
rule 'sentence' => 'simple_sentence Period'
|
14
|
+
rule 'sentence' => 'complex_sentence Period'
|
14
15
|
rule 'simple_sentence' => 'declarative_simple_sentence'
|
15
|
-
rule '
|
16
|
+
rule 'complex_sentence' => 'main_clause subordination_marker dependent_clause'
|
17
|
+
rule 'complex_sentence' => 'subordination_marker dependent_clause Comma main_clause'
|
18
|
+
rule 'complex_sentence' => 'subordination_marker dependent_clause Comma LinkingAdverb main_clause'
|
19
|
+
rule 'subordination_marker' => 'SubordinatingConjunction'
|
20
|
+
rule 'subordination_marker' => 'SubordinatingConjunction PrepositionOf'
|
16
21
|
rule 'declarative_simple_sentence' => 'affirmative_sentence'
|
17
22
|
rule 'declarative_simple_sentence' => 'negative_sentence'
|
23
|
+
rule 'main_clause' => 'simple_sentence'
|
24
|
+
rule 'dependent_clause' => 'simple_sentence'
|
25
|
+
rule 'dependent_clause' => 'DemonstrativePronoun'
|
18
26
|
rule 'affirmative_sentence' => 'noun_phrase verb_phrase'
|
19
27
|
rule 'affirmative_sentence' => 'AdverbThere IrregularVerbBe verb_be_complement'
|
20
28
|
rule 'affirmative_sentence' => 'numeral_of IrregularVerbBe verb_be_complement'
|
@@ -24,8 +32,6 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
24
32
|
rule 'negative_sentence' => 'AdverbThere negative_verb_phrase'
|
25
33
|
rule 'negative_sentence' => 'numeral_of negative_verb_phrase'
|
26
34
|
rule 'negative_sentence' => 'conjunctive_prefix negative_verb_phrase'
|
27
|
-
rule 'conditional_statement' => 'condition_subordinate Comma LinkingAdverb declarative_simple_sentence'
|
28
|
-
rule 'condition_subordinate' => 'SubordinatingConjunction declarative_simple_sentence'
|
29
35
|
rule 'conjunctive_prefix' => 'ConjunctivePronoun noun_phrase verb_phrase'
|
30
36
|
rule 'noun_phrase' => 'simple_noun_phrase'
|
31
37
|
rule 'noun_phrase' => 'compound_noun_phrase'
|
@@ -59,6 +65,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
59
65
|
rule 'single_determiner' => 'IndefiniteQuantifier'
|
60
66
|
rule 'verb_phrase' => 'verb_group'
|
61
67
|
rule 'verb_phrase' => 'verb_group verb_complement'
|
68
|
+
rule 'verb_phrase' => 'RegularVerb propositional_phrase'
|
69
|
+
rule 'verb_phrase' => 'IrregularVerbDo DemonstrativePronoun'
|
62
70
|
rule 'verb_phrase' => 'IrregularVerbBe verb_be_complement'
|
63
71
|
rule 'verb_phrase' => 'IrregularVerbSay Colon Quote affirmative_sentence Period Quote'
|
64
72
|
rule 'verb_complement' => 'noun_phrase'
|
@@ -77,6 +85,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
77
85
|
rule 'lexical_verb' => 'RegularVerb'
|
78
86
|
rule 'lexical_verb' => 'IrregularVerb'
|
79
87
|
rule 'lexical_verb' => 'IrregularVerbBe'
|
88
|
+
rule 'lexical_verb' => 'IrregularVerbDo'
|
80
89
|
rule 'lexical_verb' => 'IrregularVerbHave'
|
81
90
|
rule 'lexical_verb' => 'IrregularVerbSay'
|
82
91
|
rule 'numeral' => 'Cardinal'
|
@@ -91,7 +100,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
91
100
|
rule 'propositional_phrase' => 'preposition'
|
92
101
|
rule 'propositional_complement' => 'noun_phrase'
|
93
102
|
rule 'preposition' => 'Preposition'
|
94
|
-
rule 'preposition' => 'PrepositionOf'
|
103
|
+
rule 'preposition' => 'PrepositionOf'
|
95
104
|
end
|
96
105
|
|
97
106
|
|
data/lib/zenlish/version.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative 'pronoun'
|
|
15
15
|
require_relative 'proper_noun'
|
16
16
|
require_relative 'irregular_verb'
|
17
17
|
require_relative 'irregular_verb_be'
|
18
|
+
require_relative 'irregular_verb_do'
|
18
19
|
require_relative 'irregular_verb_have'
|
19
20
|
require_relative 'irregular_verb_say'
|
20
21
|
require_relative 'definite_article'
|
@@ -2,7 +2,14 @@ require_relative 'conjunction'
|
|
2
2
|
|
3
3
|
module Zenlish
|
4
4
|
module WClasses
|
5
|
-
#
|
5
|
+
# A subordinating conjunction is a word or phrase that connects a dependent
|
6
|
+
# clause to a main clause. The subordinating conjunction indicates how the
|
7
|
+
# dependent clause adds informative value to the main clause. For instance,
|
8
|
+
# by signaling a cause-and-effect relation, a shift in time or place between
|
9
|
+
# the two clauses.
|
10
|
+
# Common subordinating conjunctions: after, although, as, because, before,
|
11
|
+
# how, if, once, since, than, that, though, till, until, when, where,
|
12
|
+
# whether, while
|
6
13
|
class SubordinatingConjunction < WordClass
|
7
14
|
end # class
|
8
15
|
end # module
|
@@ -36,14 +36,17 @@ module Zenlish
|
|
36
36
|
literal2var('all', 'all')
|
37
37
|
literal2var('another', 'another')
|
38
38
|
def are ; Lex::Literal.new('are', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
39
|
+
literal2var('because', 'because')
|
39
40
|
literal2var('big', 'big')
|
40
41
|
literal2var('big', 'bigger')
|
41
42
|
literal2var('as', 'as')
|
42
43
|
literal2var('of', 'of')
|
43
|
-
|
44
|
+
def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
|
45
|
+
def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
|
44
46
|
literal2var('false', 'false', '_')
|
45
47
|
literal2var('far', 'far')
|
46
48
|
literal2var('from', 'from')
|
49
|
+
literal2var('happen', 'happens')
|
47
50
|
literal2var('have', 'has')
|
48
51
|
literal2var('have', 'have')
|
49
52
|
literal2var('hear', 'hears')
|
@@ -94,6 +97,7 @@ module Zenlish
|
|
94
97
|
literal2var('two', 'two')
|
95
98
|
literal2var('very', 'very')
|
96
99
|
literal2var('what', 'what')
|
100
|
+
literal2var('with', 'with')
|
97
101
|
literal2var('word', 'words')
|
98
102
|
|
99
103
|
def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end
|
@@ -194,7 +198,7 @@ module Zenlish
|
|
194
198
|
expect { subject.parse(literals) }.not_to raise_error
|
195
199
|
|
196
200
|
# Sentence: "Lisa does not see people inside the other thing."
|
197
|
-
literals = [lisa,
|
201
|
+
literals = [lisa, does_aux, not_, see, people, inside, the, other, thing, dot]
|
198
202
|
expect { subject.parse(literals) }.not_to raise_error
|
199
203
|
end
|
200
204
|
|
@@ -441,23 +445,63 @@ module Zenlish
|
|
441
445
|
expect { subject.parse(literals) }.not_to raise_error
|
442
446
|
|
443
447
|
# Sentence 2-02c: "Lisa does not have the same kind of thing as Tony has."
|
444
|
-
literals = [lisa,
|
448
|
+
literals = [lisa, does_aux, not_, have, the, same, kind, of, thing, as, tony, has, dot]
|
445
449
|
expect { subject.parse(literals) }.not_to raise_error
|
446
450
|
|
447
451
|
# Sentence 2-03a: "Lisa is touching part of this thing."
|
448
452
|
literals = [lisa, is_aux, touching, part, of, this, thing, dot]
|
449
453
|
expect { subject.parse(literals) }.not_to raise_error
|
450
|
-
|
454
|
+
|
451
455
|
# Sentence 2-03b: "Tony is touching the other part."
|
452
456
|
literals = [tony, is_aux, touching, the, other, part, dot]
|
457
|
+
expect { subject.parse(literals) }.not_to raise_error
|
458
|
+
|
459
|
+
# Sentence 2-04a: "Lisa does something."
|
460
|
+
literals = [lisa, does, something, dot]
|
461
|
+
expect { subject.parse(literals) }.not_to raise_error
|
462
|
+
|
463
|
+
# Sentence 2-04b: "Lisa does something with this thing."
|
464
|
+
literals = [lisa, does, something, with, this, thing, dot]
|
465
|
+
expect { subject.parse(literals) }.not_to raise_error
|
466
|
+
|
467
|
+
# Sentence 2-04c: "Lisa does something to Tony."
|
468
|
+
literals = [lisa, does, something, to, tony, dot]
|
469
|
+
expect { subject.parse(literals) }.not_to raise_error
|
470
|
+
|
471
|
+
# Sentence 2-04d: "Lisa does something to Tony with this thing."
|
472
|
+
literals = [lisa, does, something, to, tony, with, this, thing, dot]
|
473
|
+
expect { subject.parse(literals) }.not_to raise_error
|
474
|
+
|
475
|
+
# Sentence 2-05a: "Something happens."
|
476
|
+
literals = [something, happens, dot]
|
477
|
+
expect { subject.parse(literals) }.not_to raise_error
|
478
|
+
|
479
|
+
# Sentence 2-05b: "Something happens to Lisa."
|
480
|
+
literals = [something, happens, to, lisa, dot]
|
481
|
+
expect { subject.parse(literals) }.not_to raise_error
|
482
|
+
|
483
|
+
# Sentence 2-06a: "Tony does something."
|
484
|
+
literals = [tony, does, something, dot]
|
485
|
+
expect { subject.parse(literals) }.not_to raise_error
|
486
|
+
|
487
|
+
# Sentence 2-06b: "Something happens to Lisa because of this."
|
488
|
+
literals = [something, happens, to, lisa, because, of, this_as_pronoun, dot]
|
489
|
+
expect { subject.parse(literals) }.not_to raise_error
|
490
|
+
|
491
|
+
# Sentence 2-06c: "Something happens to Lisa because Tony does this."
|
492
|
+
literals = [something, happens, to, lisa, because, tony, does, this_as_pronoun, dot]
|
453
493
|
expect { subject.parse(literals) }.not_to raise_error
|
494
|
+
|
495
|
+
# Sentence 2-06: "Something happens to this living thing."
|
496
|
+
literals = [something, happens, to, this, living, thing, dot]
|
497
|
+
expect { subject.parse(literals) }.not_to raise_error
|
454
498
|
end
|
455
499
|
=begin
|
456
500
|
TODO
|
457
501
|
Lesson 2.A
|
458
502
|
Xtra:
|
459
503
|
What Tony has is like what Lisa has.
|
460
|
-
=end
|
504
|
+
=end
|
461
505
|
end # context
|
462
506
|
end # describe
|
463
507
|
end # module
|
@@ -21,6 +21,7 @@ preposition_than = $ZenlishLexicon.name2terminal['PrepositionThan']
|
|
21
21
|
regular_verb = $ZenlishLexicon.name2terminal['RegularVerb']
|
22
22
|
irregular_verb = $ZenlishLexicon.name2terminal['IrregularVerb']
|
23
23
|
irregular_verb_be = $ZenlishLexicon.name2terminal['IrregularVerbBe']
|
24
|
+
irregular_verb_do = $ZenlishLexicon.name2terminal['IrregularVerbDo']
|
24
25
|
irregular_verb_have = $ZenlishLexicon.name2terminal['IrregularVerbHave']
|
25
26
|
irregular_verb_say = $ZenlishLexicon.name2terminal['IrregularVerbSay']
|
26
27
|
indefinite_pronoun = $ZenlishLexicon.name2terminal['IndefinitePronoun']
|
@@ -54,12 +55,15 @@ add_entry('another', adjective)
|
|
54
55
|
add_entry('as', comparative_particle)
|
55
56
|
add_entry('be', auxiliary_be)
|
56
57
|
add_entry('be', irregular_verb_be)
|
58
|
+
add_entry('because', subordinating_conjunction)
|
57
59
|
add_entry('big', adjective)
|
58
60
|
add_entry('do', auxiliary_do)
|
61
|
+
add_entry('do', irregular_verb_do)
|
59
62
|
add_entry('false', adjective)
|
60
63
|
add_entry('far', adverb)
|
61
64
|
add_entry('from', preposition)
|
62
|
-
add_entry('have', irregular_verb_have)
|
65
|
+
add_entry('have', irregular_verb_have)
|
66
|
+
add_entry('happen', regular_verb)
|
63
67
|
add_entry('hear', irregular_verb)
|
64
68
|
add_entry('if', subordinating_conjunction)
|
65
69
|
add_entry('in', preposition)
|
@@ -102,6 +106,7 @@ add_entry('true', adjective)
|
|
102
106
|
add_entry('two', cardinal)
|
103
107
|
add_entry('very', degree_adverb)
|
104
108
|
add_entry('what',conjunctive_pronoun)
|
109
|
+
add_entry('with',preposition)
|
105
110
|
add_entry('word', common_noun)
|
106
111
|
|
107
112
|
add_entry(':', colon)
|
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.10
|
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-
|
11
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/zenlish/wclasses/indefinite_quantifier.rb
|
118
118
|
- lib/zenlish/wclasses/irregular_verb.rb
|
119
119
|
- lib/zenlish/wclasses/irregular_verb_be.rb
|
120
|
+
- lib/zenlish/wclasses/irregular_verb_do.rb
|
120
121
|
- lib/zenlish/wclasses/irregular_verb_have.rb
|
121
122
|
- lib/zenlish/wclasses/irregular_verb_say.rb
|
122
123
|
- lib/zenlish/wclasses/lexical_verb.rb
|