zenlish 0.1.14 → 0.1.15
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/.rspec +1 -0
- data/CHANGELOG.md +15 -1
- data/README.md +8 -8
- data/lib/zenlish/lang/dictionary.rb +10 -1
- data/lib/zenlish/lang/zenlish_grammar.rb +26 -12
- 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/relative_pronoun.rb +12 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/zenlish/parser/zparser_spec.rb +128 -15
- data/spec/zenlish/support/minimal_lexicon.rb +3 -0
- 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: bae8e629cfa98ad394a1d883934396b1c4241f53e831387d870d51b84c25d863
|
4
|
+
data.tar.gz: c5b3fdb5fb152967aa9fcaf296734336531ff8e855fd94ffbf9fb49f369df239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11dce85cc695db9a7a5a374b4a8caa4b022a6914b7133adfe3b1a632e99619712169aed83f4a162331f13a6338505e0bf15462feae1102a2f9db13a0feb0ed85
|
7
|
+
data.tar.gz: 4fddca277e63fd1e022704999b7500c2dcbf8a2d1fb4c45bc721108d84914097e9b42055c3d930f2fa481503274798a5685931e135aa3832e76f72a4f82ccbbb
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## [0.1.15] - 2019-11-02
|
4
|
+
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-G from
|
5
|
+
[Learn These Words First](http://learnthesewordsfirst.com/).
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- Class `RelativePronoun` to represent the relative pronoun `who`.
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Folder structure under `lib` and `spec`.
|
12
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 2-E (136 sentences in total).
|
13
|
+
- `ZenlishGrammar`: new production rules added.
|
14
|
+
- File `dictionary.rb`: new entries in lexicon `moment`, `much`, `someone`, `when`, `who`.
|
15
|
+
- File `README.md` Updated the metrics table
|
16
|
+
|
3
17
|
## [0.1.14] - 2019-11-01
|
4
18
|
__Zenlish__ can parse all sentences in lesson 1 and 2-A..2-F from
|
5
19
|
[Learn These Words First](http://learnthesewordsfirst.com/).
|
@@ -11,7 +25,7 @@ __Zenlish__ can parse all sentences in lesson 1 and 2-A..2-F from
|
|
11
25
|
|
12
26
|
### Changed
|
13
27
|
- Folder structure under `lib` and `spec`.
|
14
|
-
- File `zparser_spec.rb`: tests include all sentences from lesson 2-E (
|
28
|
+
- File `zparser_spec.rb`: tests include all sentences from lesson 2-E (184 sentences in total).
|
15
29
|
- `ZenlishGrammar`: new production rules for multiple sentence parsing, personal pronouns and dependent clauses without conjunctions.
|
16
30
|
- File `dictionary.rb`: new entries in lexicon `I`, `me`, `you`, `here`, `now`.
|
17
31
|
- File `README.md` Reshuffled sections, added one code snippet, updated the metrics table
|
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
|
23
|
+
sentences from lessons 1-A up to 2-G.
|
24
24
|
|
25
25
|
The intent is to deliver gem versions in small increments.
|
26
26
|
|
@@ -34,14 +34,14 @@ Over time, the zenlish gem will contain:
|
|
34
34
|
- A simplified ontology[TODO]
|
35
35
|
|
36
36
|
|
37
|
-
#### Some project metrics (v. 0.1.
|
37
|
+
#### Some project metrics (v. 0.1.15)
|
38
38
|
|Metric|Value|
|
39
39
|
|:-:|:-:|
|
40
|
-
| Number of lemmas in dictionary |
|
41
|
-
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) |
|
42
|
-
| Number of production rules in grammar |
|
43
|
-
| Number of lessons covered |
|
44
|
-
| Number of sentences in spec files |
|
40
|
+
| Number of lemmas in dictionary | 89 |
|
41
|
+
| [Coverage 100 commonest English words](https://en.wikipedia.org/wiki/Most_common_words_in_English) | 45 |
|
42
|
+
| Number of production rules in grammar | 129 |
|
43
|
+
| Number of lessons covered | 15 |
|
44
|
+
| Number of sentences in spec files | 184 |
|
45
45
|
|
46
46
|
|
47
47
|
## Installation...
|
@@ -120,7 +120,7 @@ Litmus test: a Zenlish text should be easy to read to a English reading person.
|
|
120
120
|
Here a tentative roadmap:
|
121
121
|
|
122
122
|
#### A) Ability to parse sentences from [Learn These Words First](http://learnthesewordsfirst.com/)
|
123
|
-
*STARTED*.
|
123
|
+
*STARTED*. 15.6% complete
|
124
124
|
This website advocates the idea of a multi-layered dictionary.
|
125
125
|
At the core, there are about 300 essential words.
|
126
126
|
The choice of these words is inspired by the semantic primitives of [NSM
|
@@ -21,6 +21,8 @@ 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')
|
25
|
+
add_entry('after', 'SubordinatingConjunction')
|
24
26
|
add_entry('alive', 'Adjective')
|
25
27
|
add_entry('all', 'IndefiniteQuantifier')
|
26
28
|
add_entry('another', 'Adjective')
|
@@ -57,8 +59,12 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
57
59
|
add_entry('long', 'Adjective')
|
58
60
|
add_entry('many', 'IndefiniteQuantifier')
|
59
61
|
add_entry('me', 'PersonalPronoun')
|
62
|
+
add_entry('moment', 'CommonNoun')
|
60
63
|
add_entry('more', 'Adjective')
|
64
|
+
add_entry('more', 'Adverb')
|
61
65
|
add_entry('move', 'RegularVerb')
|
66
|
+
add_entry('much', 'Adverb')
|
67
|
+
add_entry('near', 'Preposition')
|
62
68
|
add_entry('near to', 'Preposition')
|
63
69
|
add_entry('now', 'Adverb')
|
64
70
|
add_entry('not', 'AdverbNot')
|
@@ -77,6 +83,7 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
77
83
|
add_entry('side', 'CommonNoun')
|
78
84
|
add_entry('small', 'Adjective')
|
79
85
|
add_entry('some', 'IndefiniteQuantifier')
|
86
|
+
add_entry('someone', 'IndefinitePronoun')
|
80
87
|
add_entry('something', 'IndefinitePronoun')
|
81
88
|
add_entry('than', 'PrepositionThan')
|
82
89
|
add_entry('the', 'DefiniteArticle')
|
@@ -94,7 +101,9 @@ unless defined?(Zenlish::Lang::Dictionary)
|
|
94
101
|
add_entry('two', 'Cardinal')
|
95
102
|
add_entry('very', 'DegreeAdverb')
|
96
103
|
add_entry('want', 'RegularVerbWant')
|
97
|
-
add_entry('what','ConjunctivePronoun')
|
104
|
+
add_entry('what','ConjunctivePronoun')
|
105
|
+
add_entry('when','SubordinatingConjunction')
|
106
|
+
add_entry('who','RelativePronoun')
|
98
107
|
add_entry('with','Preposition')
|
99
108
|
add_entry('word', 'CommonNoun')
|
100
109
|
add_entry('you', 'PersonalPronoun')
|
@@ -10,26 +10,24 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
10
10
|
add_terminals(*Zenlish::Lang::Dictionary.terminals)
|
11
11
|
|
12
12
|
rule 'zenlish' => 'prose'
|
13
|
-
|
14
|
-
# Temporary limitation: from 1 to 3 sentences
|
15
13
|
rule 'prose' => 'sentence'
|
16
|
-
rule 'prose' => '
|
17
|
-
rule 'prose' => 'sentence sentence sentence'
|
14
|
+
rule 'prose' => 'prose sentence'
|
18
15
|
|
19
16
|
rule 'sentence' => 'simple_sentence Period'
|
20
17
|
rule 'sentence' => 'complex_sentence Period'
|
21
18
|
rule 'simple_sentence' => 'declarative_simple_sentence'
|
22
19
|
|
23
20
|
# Case of dropped ´that´ conjunction
|
24
|
-
rule 'complex_sentence' => 'main_clause
|
25
|
-
rule 'complex_sentence' => 'main_clause Comma
|
26
|
-
rule 'complex_sentence' => '
|
27
|
-
rule 'complex_sentence' => '
|
21
|
+
rule 'complex_sentence' => 'main_clause subordinated_clause'
|
22
|
+
rule 'complex_sentence' => 'main_clause Comma subordinated_clause'
|
23
|
+
rule 'complex_sentence' => 'subordinated_clause Comma main_clause'
|
24
|
+
rule 'complex_sentence' => 'subordinated_clause Comma LinkingAdverb main_clause'
|
28
25
|
rule 'subordination_marker' => 'SubordinatingConjunction'
|
29
26
|
rule 'subordination_marker' => 'SubordinatingConjunction PrepositionOf'
|
30
27
|
rule 'declarative_simple_sentence' => 'affirmative_sentence'
|
31
28
|
rule 'declarative_simple_sentence' => 'negative_sentence'
|
32
29
|
rule 'main_clause' => 'simple_sentence'
|
30
|
+
rule 'subordinated_clause' => 'subordination_marker dependent_clause'
|
33
31
|
rule 'dependent_clause' => 'simple_sentence'
|
34
32
|
rule 'dependent_clause' => 'DemonstrativePronoun'
|
35
33
|
rule 'affirmative_sentence' => 'noun_phrase verb_phrase'
|
@@ -50,6 +48,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
50
48
|
rule 'conjunctive_prefix' => 'ConjunctivePronoun noun_phrase verb_phrase'
|
51
49
|
rule 'noun_phrase' => 'simple_noun_phrase'
|
52
50
|
rule 'noun_phrase' => 'compound_noun_phrase'
|
51
|
+
# TODO: improve treatment of 'one very short time'
|
53
52
|
rule 'simple_noun_phrase' => 'nominal'
|
54
53
|
rule 'simple_noun_phrase' => 'determiner nominal'
|
55
54
|
rule 'simple_noun_phrase' => 'numeral nominal'
|
@@ -58,6 +57,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
58
57
|
rule 'simple_noun_phrase' => 'PersonalPronoun'
|
59
58
|
rule 'simple_noun_phrase' => 'IndefinitePronoun'
|
60
59
|
rule 'simple_noun_phrase' => 'IndefinitePronoun Adjective'
|
60
|
+
rule 'simple_noun_phrase' => 'DemonstrativeDeterminer IndefinitePronoun'
|
61
61
|
rule 'simple_noun_phrase' => 'simple_noun_phrase simple_noun_phrase verb_phrase'
|
62
62
|
|
63
63
|
# Case: (all|many|some) one of (this|these)
|
@@ -75,6 +75,7 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
75
75
|
rule 'subset_of' => 'IndefiniteQuantifier PrepositionOf DemonstrativeDeterminer'
|
76
76
|
rule 'nominal' => 'CommonNoun'
|
77
77
|
rule 'nominal' => 'Adjective CommonNoun'
|
78
|
+
rule 'nominal' => 'DegreeAdverb Adjective CommonNoun'
|
78
79
|
rule 'determiner' => 'determiner single_determiner'
|
79
80
|
rule 'determiner' => 'single_determiner'
|
80
81
|
rule 'single_determiner' => 'DemonstrativeDeterminer'
|
@@ -85,32 +86,41 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
85
86
|
rule 'verb_phrase' => 'verb_group verb_complement'
|
86
87
|
rule 'verb_phrase' => 'RegularVerb propositional_phrase'
|
87
88
|
rule 'verb_phrase' => 'RegularVerbWant Preposition verb_group'
|
89
|
+
rule 'verb_phrase' => 'RegularVerbWant Preposition IrregularVerbKnow identifying_clause'
|
88
90
|
rule 'verb_phrase' => 'RegularVerbWant Preposition verb_group noun_phrase'
|
89
91
|
rule 'verb_phrase' => 'RegularVerbWant simple_noun_phrase Preposition verb_group noun_phrase'
|
90
92
|
rule 'verb_phrase' => 'IrregularVerbDo DemonstrativePronoun'
|
91
93
|
rule 'verb_phrase' => 'IrregularVerbDo DemonstrativePronoun propositional_phrase'
|
92
94
|
rule 'verb_phrase' => 'ModalVerbCan verb_group DemonstrativePronoun'
|
93
95
|
rule 'verb_phrase' => 'IrregularVerbBe verb_be_complement'
|
96
|
+
rule 'verb_phrase' => 'IrregularVerbKnow identifying_clause'
|
94
97
|
|
95
98
|
# Cover case where ´that´ conjunction is dropped.
|
96
99
|
rule 'verb_phrase' => 'mental_verb dependent_clause'
|
100
|
+
rule 'verb_phrase' => 'mental_verb noun_phrase Adverb negative_verb_phrase'
|
97
101
|
rule 'verb_phrase' => 'IrregularVerbSay DemonstrativePronoun Preposition noun_phrase'
|
102
|
+
rule 'verb_phrase' => 'IrregularVerbSay DemonstrativePronoun subordinated_clause'
|
98
103
|
rule 'verb_phrase' => 'IrregularVerbSay Colon affirmative_sentence'
|
99
104
|
rule 'verb_phrase' => 'IrregularVerbSay Colon Quote affirmative_sentence Period Quote'
|
100
105
|
rule 'verb_phrase' => 'IrregularVerbSay Preposition noun_phrase Colon Quote affirmative_sentence Period Quote'
|
101
106
|
rule 'mental_verb' => 'IrregularVerbKnow'
|
102
107
|
rule 'mental_verb' => 'IrregularVerbThink'
|
103
108
|
rule 'verb_complement' => 'noun_phrase'
|
104
|
-
rule 'verb_complement' => 'adverb_phrase'
|
105
109
|
rule 'verb_complement' => 'noun_phrase adverb_phrase'
|
110
|
+
rule 'verb_complement' => 'adverb_phrase'
|
111
|
+
rule 'verb_complement' => 'adverb_phrase nominal'
|
106
112
|
|
107
113
|
# perception verb (hear, see, watch, notice, ...): verb + object + infinitive
|
108
114
|
rule 'verb_complement' => 'simple_noun_phrase lexical_verb'
|
109
115
|
rule 'verb_complement' => 'Adjective propositional_phrase'
|
116
|
+
rule 'verb_complement' => 'Preposition simple_noun_phrase lexical_verb'
|
117
|
+
rule 'verb_complement' => 'Preposition IndefinitePronoun'
|
110
118
|
rule 'verb_be_complement' => 'noun_phrase'
|
111
119
|
rule 'verb_be_complement' => 'adjective_as_complement' # Specific to be as lexical verb
|
112
120
|
rule 'verb_be_complement' => 'propositional_phrase'
|
113
121
|
rule 'verb_be_complement' => 'noun_phrase adverb_phrase'
|
122
|
+
rule 'identifying_clause' => 'RelativePronoun verb_phrase'
|
123
|
+
|
114
124
|
rule 'adjective_as_complement' => 'DegreeAdverb Adjective'
|
115
125
|
rule 'adjective_as_complement' => 'Adjective'
|
116
126
|
rule 'adjective_as_complement' => 'Adjective comparative_clause'
|
@@ -136,12 +146,16 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
136
146
|
rule 'comparative_clause' => 'comparative_start DefiniteArticle Adjective Cardinal'
|
137
147
|
rule 'comparative_start' => 'PrepositionThan'
|
138
148
|
rule 'comparative_start' => 'ComparativeParticle'
|
139
|
-
rule 'adverb_phrase' => '
|
140
|
-
rule 'adverb_phrase' => '
|
141
|
-
rule '
|
149
|
+
rule 'adverb_phrase' => 'adverbial_marker'
|
150
|
+
rule 'adverb_phrase' => 'adverbial_marker propositional_phrase'
|
151
|
+
rule 'adverbial_marker' => 'Adverb'
|
152
|
+
rule 'adverbial_marker' => 'Adverb Adverb' # 'here now', 'much more'
|
142
153
|
rule 'propositional_phrase' => 'preposition propositional_complement'
|
143
154
|
rule 'propositional_phrase' => 'preposition'
|
144
155
|
rule 'propositional_complement' => 'noun_phrase'
|
156
|
+
# rule 'propositional_complement' => 'simple_noun_phrase lexical_verb propositional_phrase'
|
157
|
+
rule 'propositional_complement' => 'conjunctive_prefix'
|
158
|
+
rule 'propositional_complement' => 'DemonstrativePronoun'
|
145
159
|
rule 'preposition' => 'Preposition'
|
146
160
|
rule 'preposition' => 'PrepositionOf'
|
147
161
|
end
|
@@ -46,6 +46,7 @@ module Zenlish
|
|
46
46
|
aLexicon.add_terminal(WClasses::PrepositionThan.new.freeze)
|
47
47
|
aLexicon.add_terminal(WClasses::RegularVerb.new.freeze)
|
48
48
|
aLexicon.add_terminal(WClasses::RegularVerbWant.new.freeze)
|
49
|
+
aLexicon.add_terminal(WClasses::RelativePronoun.new.freeze)
|
49
50
|
aLexicon.add_terminal(WClasses::ProperNoun.new.freeze)
|
50
51
|
aLexicon.add_terminal(WClasses::IndefiniteQuantifier.new.freeze)
|
51
52
|
aLexicon.add_terminal(WClasses::SubordinatingConjunction.new.freeze)
|
data/lib/zenlish/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative 'pronoun'
|
2
|
+
|
3
|
+
module Zenlish
|
4
|
+
module WClasses
|
5
|
+
# A relative pronoun refers to a noun that has already been mentionned,
|
6
|
+
# and gives more information about that noun: who, whom, whose
|
7
|
+
# (for people) and which, what, that for things (and animals).
|
8
|
+
# A relative pronoun introduces a relative clause.
|
9
|
+
class RelativePronoun < Pronoun
|
10
|
+
end # class
|
11
|
+
end # module
|
12
|
+
end # module
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,12 @@ require 'rspec' # Use the RSpec framework
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
# Enable flags like --only-failures and --next-failure
|
7
7
|
config.example_status_persistence_file_path = ".rspec_status"
|
8
|
-
|
8
|
+
|
9
9
|
config.expect_with :rspec do |c|
|
10
|
+
# Disable the `should` syntax
|
10
11
|
c.syntax = :expect
|
11
12
|
end
|
13
|
+
|
14
|
+
# Display stack trace in case of failure
|
15
|
+
config.full_backtrace = true
|
12
16
|
end
|
@@ -33,13 +33,17 @@ module Zenlish
|
|
33
33
|
literal2var('a', 'a', '_as_art')
|
34
34
|
literal2var('about', 'about')
|
35
35
|
literal2var('above', 'above')
|
36
|
+
def after_adverb ; Lex::Literal.new('after', get_lexeme('after', WClasses::Adverb), 0) ; end
|
37
|
+
def after_ ; Lex::Literal.new('after', get_lexeme('after', WClasses::SubordinatingConjunction), 0) ; end
|
36
38
|
literal2var('alive', 'alive')
|
37
39
|
literal2var('all', 'all')
|
40
|
+
def am ; Lex::Literal.new('am', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
38
41
|
literal2var('another', 'another')
|
39
42
|
def are ; Lex::Literal.new('are', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
40
43
|
literal2var('as', 'as')
|
41
44
|
literal2var('at', 'at')
|
42
45
|
literal2var('bad', 'bad')
|
46
|
+
def be_ ; Lex::Literal.new('be', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
43
47
|
literal2var('because', 'because')
|
44
48
|
def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end
|
45
49
|
def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end
|
@@ -57,20 +61,24 @@ module Zenlish
|
|
57
61
|
literal2var('for', 'for', '_')
|
58
62
|
literal2var('from', 'from')
|
59
63
|
literal2var('good', 'good')
|
64
|
+
literal2var('happen', 'happen')
|
60
65
|
literal2var('happen', 'happened')
|
66
|
+
literal2var('happen', 'happening')
|
61
67
|
literal2var('happen', 'happens')
|
62
68
|
literal2var('have', 'has')
|
63
69
|
literal2var('have', 'have')
|
64
70
|
literal2var('hear', 'hears')
|
65
71
|
literal2var('here', 'here')
|
66
|
-
literal2var('I', 'I', '')
|
67
|
-
literal2var('if', 'if', '_')
|
68
72
|
def i_pronoun ; Lex::Literal.new('I', get_lexeme('I'), 0) ; end
|
73
|
+
literal2var('if', 'if', '_')
|
69
74
|
literal2var('in', 'in', '_')
|
70
75
|
literal2var('inside', 'inside')
|
76
|
+
literal2var('J', 'j', '_')
|
71
77
|
def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
72
78
|
def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end
|
79
|
+
literal2var('K', 'k', '_')
|
73
80
|
literal2var('kind', 'kind')
|
81
|
+
literal2var('know', 'knew')
|
74
82
|
literal2var('know', 'know')
|
75
83
|
literal2var('know', 'knows')
|
76
84
|
literal2var('like', 'like')
|
@@ -79,10 +87,14 @@ module Zenlish
|
|
79
87
|
literal2var('long', 'long')
|
80
88
|
literal2var('many', 'many')
|
81
89
|
literal2var('me', 'me')
|
82
|
-
literal2var('
|
90
|
+
literal2var('moment', 'moment')
|
91
|
+
def more ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adjective), 0) ; end
|
92
|
+
def more_as_adverb ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adverb), 0) ; end
|
83
93
|
literal2var('move', 'move')
|
84
94
|
literal2var('move', 'moved')
|
85
95
|
literal2var('move', 'moves')
|
96
|
+
literal2var('much', 'much')
|
97
|
+
literal2var('near', 'near')
|
86
98
|
literal2var('near to', 'near_to')
|
87
99
|
literal2var('not', 'not', '_')
|
88
100
|
literal2var('now', 'now')
|
@@ -91,6 +103,7 @@ module Zenlish
|
|
91
103
|
literal2var('one', 'one')
|
92
104
|
literal2var('other', 'other')
|
93
105
|
literal2var('part', 'part')
|
106
|
+
literal2var('part', 'parts')
|
94
107
|
literal2var('people', 'people')
|
95
108
|
literal2var('person', 'person')
|
96
109
|
literal2var('place', 'place')
|
@@ -100,9 +113,11 @@ module Zenlish
|
|
100
113
|
literal2var('small', 'small')
|
101
114
|
literal2var('small', 'smaller')
|
102
115
|
literal2var('some', 'some')
|
116
|
+
literal2var('say', 'said')
|
103
117
|
literal2var('say', 'says')
|
104
118
|
literal2var('see', 'see')
|
105
119
|
literal2var('see', 'sees')
|
120
|
+
literal2var('someone', 'someone')
|
106
121
|
literal2var('something', 'something')
|
107
122
|
literal2var('the', 'the')
|
108
123
|
literal2var('then', 'then', '_')
|
@@ -110,6 +125,7 @@ module Zenlish
|
|
110
125
|
literal2var('there', 'there')
|
111
126
|
literal2var('thing', 'thing')
|
112
127
|
literal2var('thing', 'things')
|
128
|
+
literal2var('think', 'think')
|
113
129
|
literal2var('think', 'thinks')
|
114
130
|
def these ; Lex::Literal.new('these', get_lexeme('this', WClasses::DemonstrativeDeterminer), 0) ; end
|
115
131
|
def these_as_pronoun ; Lex::Literal.new('these', get_lexeme('this', WClasses::DemonstrativePronoun), 0) ; end
|
@@ -128,6 +144,8 @@ module Zenlish
|
|
128
144
|
def was ; Lex::Literal.new('was', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
129
145
|
def were ; Lex::Literal.new('were', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
|
130
146
|
literal2var('what', 'what')
|
147
|
+
literal2var('when', 'when', '_')
|
148
|
+
literal2var('who', 'who')
|
131
149
|
literal2var('with', 'with')
|
132
150
|
literal2var('word', 'words')
|
133
151
|
def x_as_noun ; Lex::Literal.new('X', get_lexeme('X'), 0) ; end
|
@@ -488,6 +506,10 @@ module Zenlish
|
|
488
506
|
# Sentence 2-03b: "Tony is touching the other part."
|
489
507
|
literals = [tony, is_aux, touching, the, other, part, dot]
|
490
508
|
expect { subject.parse(literals) }.not_to raise_error
|
509
|
+
|
510
|
+
# Sentence 2-Ax: "What Tony has is like what Lisa has."
|
511
|
+
literals = [what, tony, has, is, like, what, lisa, has, dot]
|
512
|
+
expect { subject.parse(literals) }.not_to raise_error
|
491
513
|
end
|
492
514
|
|
493
515
|
it 'should parse sample sentences from lesson 2-B' do
|
@@ -607,6 +629,12 @@ module Zenlish
|
|
607
629
|
# Sentence 2-13b: "This feels bad for Tony."
|
608
630
|
literals = [this_as_pronoun, feels, bad, for_, tony, dot]
|
609
631
|
expect { subject.parse(literals) }.not_to raise_error
|
632
|
+
|
633
|
+
# Sentence 2-Dx: "Lisa thinks about something bad happening to this
|
634
|
+
# living thing. Thinking about this feels bad for Lisa."
|
635
|
+
# literals = [lisa, thinks, about, something, bad, happening, to, this,
|
636
|
+
# living, thing, dot]
|
637
|
+
# expect { subject.parse(literals) }.not_to raise_error
|
610
638
|
end
|
611
639
|
|
612
640
|
it 'should parse sample sentences from lesson 2-E' do
|
@@ -732,13 +760,13 @@ module Zenlish
|
|
732
760
|
literals = [lisa, says, colon, quote, x_as_noun, happens, now, dot, quote, dot]
|
733
761
|
expect { subject.parse(literals) }.not_to raise_error
|
734
762
|
|
735
|
-
# Sentence 2-
|
763
|
+
# Sentence 2-22a definiens: 'Lisa says something at a time.
|
736
764
|
# Lisa says: X happens at this same time.'
|
737
765
|
literals = [lisa, says, something, at, a_as_art, time, dot,
|
738
766
|
lisa, says, colon, x_as_noun, happens, at, this, time, dot]
|
739
767
|
expect { subject.parse(literals) }.not_to raise_error
|
740
768
|
|
741
|
-
# Sentence 2-
|
769
|
+
# Sentence 2-22b: "There are not many people here now."
|
742
770
|
literals = [there, are, not_, many, people, here, now , dot]
|
743
771
|
expect { subject.parse(literals) }.not_to raise_error
|
744
772
|
|
@@ -747,24 +775,109 @@ module Zenlish
|
|
747
775
|
can, see, many, living, things, here, dot, quote, dot]
|
748
776
|
expect { subject.parse(literals) }.not_to raise_error
|
749
777
|
end
|
778
|
+
|
779
|
+
it 'should parse sample sentences from lesson 2-G' do
|
780
|
+
# Sentence 2-23a definiendum: 'Someone does X.'
|
781
|
+
literals = [someone, does, x_as_noun, dot]
|
782
|
+
expect { subject.parse(literals) }.not_to raise_error
|
783
|
+
|
784
|
+
# Sentence 2-23a definiens: 'Something does X. This something can
|
785
|
+
# think like people think. This something can be one person.'
|
786
|
+
literals = [something, does, x_as_noun, dot,
|
787
|
+
this, something, can, think, like, people, think, dot,
|
788
|
+
this, something, can, be_, a_as_art, person, dot]
|
789
|
+
expect { subject.parse(literals) }.not_to raise_error
|
790
|
+
|
791
|
+
# Sentence 2-23b: Someone said something to Tony.
|
792
|
+
literals = [someone, said, something, to, tony, dot]
|
793
|
+
expect { subject.parse(literals) }.not_to raise_error
|
794
|
+
|
795
|
+
# Sentence 2-23c definiendum: 'J knows who did K.'
|
796
|
+
literals = [j_, knows, who, did, k_, dot]
|
797
|
+
expect { subject.parse(literals) }.not_to raise_error
|
798
|
+
|
799
|
+
# Sentence 2-23c definiens: J thinks about someone.
|
800
|
+
# J knows this someone did K.
|
801
|
+
literals = [j_, thinks, about, someone, dot,
|
802
|
+
j_, knows, this, someone, did, k_, dot]
|
803
|
+
expect { subject.parse(literals) }.not_to raise_error
|
804
|
+
|
805
|
+
# Sentence 2-23d: Tony knows who said something.
|
806
|
+
literals = [tony, knows, who, said, something, dot]
|
807
|
+
expect { subject.parse(literals) }.not_to raise_error
|
808
|
+
|
809
|
+
# Sentence 2-24a definiendum: 'J happens after K happens.'
|
810
|
+
literals = [j_, happens, after_, k_, happens, dot]
|
811
|
+
expect { subject.parse(literals) }.not_to raise_error
|
812
|
+
|
813
|
+
# Sentence 2-24a definiens: K happens before J happens.
|
814
|
+
literals = [k_, happens, before, j_, happens, dot]
|
815
|
+
expect { subject.parse(literals) }.not_to raise_error
|
816
|
+
|
817
|
+
# Sentence 2-24b: After you do something for a long time,
|
818
|
+
# you can know much more about this.
|
819
|
+
literals = [after_, you, do_, something, for_, a_as_art, long, time,
|
820
|
+
comma, you, can, know, much, more_as_adverb, about, this_as_pronoun, dot]
|
821
|
+
expect { subject.parse(literals) }.not_to raise_error
|
822
|
+
|
823
|
+
# Sentence 2-25a definiendum: 'X is true for some time.'
|
824
|
+
literals = [x_as_noun, is, true_, for_, some, time, dot]
|
825
|
+
expect { subject.parse(literals) }.not_to raise_error
|
826
|
+
|
827
|
+
# Sentence 2-25a definiens: X is true at a time.
|
828
|
+
# Some parts of this one time happen before other parts.
|
829
|
+
# Some parts of this one time happen after other parts.
|
830
|
+
# X is true at all parts of this one time.
|
831
|
+
literals = [x_as_noun, is, true_, at, a_as_art, time, dot,
|
832
|
+
some, parts, of, this, one, time, happen, before_adverb, other, parts, dot,
|
833
|
+
some, parts, of, this, one, time, happen, after_adverb, other, parts, dot,
|
834
|
+
x_as_noun, is, true_, at, all, parts, of, this, one, time, dot]
|
835
|
+
expect { subject.parse(literals) }.not_to raise_error
|
836
|
+
|
837
|
+
# Sentence 2-25b: After I moved for some time,
|
838
|
+
# I was near the other side of this place.
|
839
|
+
literals = [after_, i_pronoun, moved, for_, some, time,
|
840
|
+
comma, i_pronoun, was, near, the, other, side, of, this, place, dot]
|
841
|
+
expect { subject.parse(literals) }.not_to raise_error
|
842
|
+
|
843
|
+
# Sentence 2-26a definiendum: 'X happens in a moment.'
|
844
|
+
literals = [x_as_noun, happens, in_, a_as_art, moment, dot]
|
845
|
+
expect { subject.parse(literals) }.not_to raise_error
|
846
|
+
|
847
|
+
# Sentence 2-26a definiens: X happens for one very short time.
|
848
|
+
# There are not parts of this very short time when one part
|
849
|
+
# happens before other parts.
|
850
|
+
literals = [x_as_noun, happens, for_, one, very, short, time, dot,
|
851
|
+
there, are, not_, parts, of, this, very, short, time, when_,
|
852
|
+
one, part, happens, before_adverb, other, part, dot]
|
853
|
+
expect { subject.parse(literals) }.not_to raise_error
|
854
|
+
|
855
|
+
# Sentence 2-26b: In a moment, I knew something here was not good.
|
856
|
+
# 'here' is adverb that modifies the 'knew' verb
|
857
|
+
literals = [in_, a_as_art, moment, comma, i_pronoun, knew, something,
|
858
|
+
here, was, not_, good, dot ]
|
859
|
+
expect { subject.parse(literals) }.not_to raise_error
|
860
|
+
|
861
|
+
# Sentence 2-Gx: Tony is inside this thing for some time.
|
862
|
+
# Lisa says: "I want to know who is inside this thing.".
|
863
|
+
# Tony hears Lisa. Because of this, Tony says: "I am inside.".
|
864
|
+
# Tony says this after Tony hears Lisa.
|
865
|
+
literals = [tony, is, inside, this, thing, for_, some, time, dot,
|
866
|
+
lisa, says, colon, quote, i_pronoun, want, to, know, who, is,
|
867
|
+
inside, this, thing, dot, quote, dot, tony, hears, lisa, dot,
|
868
|
+
because, of, this_as_pronoun, comma, tony, says, colon,
|
869
|
+
quote, i_pronoun, am, inside, dot, quote, dot,
|
870
|
+
tony, says, this_as_pronoun, after_, tony, hears, lisa, dot]
|
871
|
+
expect { subject.parse(literals) }.not_to raise_error
|
872
|
+
end
|
750
873
|
=begin
|
751
874
|
TODO
|
752
875
|
|
753
|
-
Lesson 2.A
|
754
|
-
Xtra:
|
755
|
-
What Tony has is like what Lisa has.
|
756
|
-
|
757
876
|
Lesson 2.C
|
758
877
|
|
759
878
|
Xtra:
|
760
879
|
Tony knows Lisa has something, because Tony sees what Lisa has.
|
761
880
|
Tony thinks about what Lisa has, because Tony want to have the same kind of thing.
|
762
|
-
|
763
|
-
Lesson 2.D
|
764
|
-
|
765
|
-
extra
|
766
|
-
Lisa thinks about something bad happening to this living thing.
|
767
|
-
Thinking about this feels bad for Lisa
|
768
881
|
=end
|
769
882
|
end # context
|
770
883
|
end # describe
|
@@ -1,7 +1,10 @@
|
|
1
1
|
require_relative '../../../lib/zenlish/lang/dictionary'
|
2
2
|
|
3
3
|
# Add a few words to dictionary for testing purposes...
|
4
|
+
Zenlish::Lang::add_entry('J', 'ProperNoun')
|
5
|
+
Zenlish::Lang::add_entry('K', 'IndefinitePronoun')
|
4
6
|
Zenlish::Lang::add_entry('Lisa', 'ProperNoun')
|
5
7
|
Zenlish::Lang::add_entry('Tony', 'ProperNoun')
|
6
8
|
Zenlish::Lang::add_entry('X', 'CommonNoun')
|
7
9
|
|
10
|
+
|
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.15
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/zenlish/wclasses/proper_noun.rb
|
137
137
|
- lib/zenlish/wclasses/regular_verb.rb
|
138
138
|
- lib/zenlish/wclasses/regular_verb_want.rb
|
139
|
+
- lib/zenlish/wclasses/relative_pronoun.rb
|
139
140
|
- lib/zenlish/wclasses/subordinating_conjunction.rb
|
140
141
|
- lib/zenlish/wclasses/test_hierarchy.rb
|
141
142
|
- lib/zenlish/wclasses/verb.rb
|