zenlish 0.1.01 → 0.1.02

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f528c0f3df40d32748dde807e2ce52554640228b52595f7509b7f00ca0799f7d
4
- data.tar.gz: 5845c212c6850e767720bf2eef53e8ff4fc0cebf7eac93c77d6fe30ab70c852c
3
+ metadata.gz: 33ea0d4f4ce6b47acec5b160c5f83e8149f23572fdb5a20a254ad1c191b49f3a
4
+ data.tar.gz: b6ebbc91c0e75e3ff55e42e4955e15a63fa16804447a0c5c50c5b9e7761e2410
5
5
  SHA512:
6
- metadata.gz: ecb70f4531e577ecbb15772edc118a3fc0c4b9cd06cc7c62dbe404cc4be2cbe576465d92678fadde229414ee55ad40c068d8a5e76a34ae2726616d450211263c
7
- data.tar.gz: 21854cf7b004a6def164ee239448a8ef0dc9a93ff4c490f9f1e505b52dc16a6080c3323a8aeeafff5ff8741d3a92eac281e891baf533b7f72531e7787b76445b
6
+ metadata.gz: 54332bc6951d015fcb1697efe5f3415e04e34de6e703b460ecedb7a16e4639d999ab007105e8f70b20f992dc31937a2ab5332c50d677aa3e426c7ab646fc5b0c
7
+ data.tar.gz: 0fbd311e26da2a6b024da6cc150f7a86fe0cd40c7736c7a0c7e1b700836aee04bb89a0b3946b42b75e070adc5444889bfdecb9d8236a23dcd2a261ed93c4ce09
data/.travis.yml ADDED
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+ dist: trusty
3
+
4
+ before_install:
5
+ - gem update --system
6
+ - gem install bundler
7
+
8
+ script:
9
+ - bundle exec rake
10
+
11
+ rvm:
12
+ - 2.6.3
13
+ - 2.5.5
14
+ - 2.4.6
15
+ - jruby-9.1.9.0
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
21
+
22
+
23
+ # whitelist
24
+ branches:
25
+ only:
26
+ - master
data/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.1.02] - 2019-10-11
4
+ __Zenlish__ can parse all the sentences in lessons 1-A, 1-B, 1-C from
5
+ [Learn These Words First](http://learnthesewordsfirst.com/).
6
+
7
+ ### Added
8
+ - Class `Adverb` to represent adverb word class.
9
+ - Class `Preposition` to represent the preposition word class.
10
+ - Class `IndefiniteQuantifier` to represent the indefinite quantifier word class (e.g. `many`).
11
+ - File `empty_lexion_factory.rb`: added the `Adverb`, `Preposition` and `IndefiniteQuantifier` as word classes in lexicon.
12
+ - File `minimal_lexicon.rb`: new entries in lexicon `is` (from verb `be`),
13
+ `inside`, `many`, `not`.
14
+ - File `zenlish.gemspec`: now contains `.travis.yml` and `CODE_OF_CONDUCT.md.
15
+
16
+ ### Changed
17
+ - File `README.md` minor editorial changes.
18
+ - File `zparser_spec.rb`: tests include all sentences from lesson 1-C.
19
+ - `ZenlishGrammar`: new rules (i.e. adverb_phrase, preposition_phrase).
20
+
21
+
3
22
  ## [0.1.01] - 2019-10-10
4
23
  __Zenlish__ can parse all the sentences in lessons 1-A, 1-B from [Learn These Words First](http://learnthesewordsfirst.com/).
5
24
 
6
25
  ### Added
7
- - Class `Cardinal` to represent the abstract word class for cardinal and ordinal numbers.
26
+ - Class `Numeral` to represent the abstract word class for cardinal and ordinal numbers.
8
27
  - Class `Cardinal` to represent the word class of cardinal numbers.
9
- - Class `ComparativeArticle` to represent the word class of the `as` in `same as`.
28
+ - Class `ComparativeArticle` to represent the word class of the `as` in `same as`.
10
29
  - File `empty_lexion_factory.rb`: added the `Cardinal` and `ComparativeArticle` as word classes in lexicon.
11
30
  - File `minimal_lexicon.rb`: new entries in lexicon `as` (from same ... as expression),
12
31
  `one`, `two`, `person` , `people.`
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -5,9 +5,12 @@
5
5
 
6
6
  Zenlish = Zen + English
7
7
 
8
+ __Zenlish__ will be a Controlled Natural Language based on English.
9
+ A [Controlled Natural Language](https://en.wikipedia.org/wiki/Controlled_natural_language)
10
+ is a subset of a natural language -here English- limited to specific problem domains.
11
+
12
+ The goal of this project is to implement a toolkit for a subset of the English language.
8
13
 
9
- The goal of this project is to implement a toolkit subset of the English language, called ... Zenlish.
10
- A [Controlled Natural Language]([https://en.wikipedia.org/wiki/Controlled_natural_language) defines a subset of a natural language -English, for instance- with a restricted syntax and restricted semantics.
11
14
 
12
15
  ### Design of Zenlish language
13
16
  #### Minimalism
@@ -17,7 +20,8 @@ It reflects a desire to make Zenlish a simple language:
17
20
  - A limited lexicon. Priority on most commonly used words.
18
21
 
19
22
  #### Expressiveness
20
- Zenlish should be rich enough to express ideas, facts in a fluid way (vs. contrived, artificial way). Litmus test: a Zenlish text should be easy to read to an English speaking person.
23
+ Zenlish should be rich enough to express ideas, facts in a fluid way (vs. contrived, artificial way).
24
+ Litmus test: a Zenlish text should be easy to read to a English reading person.
21
25
 
22
26
  ### Zenlish as a library (gem)
23
27
  Over time, the zenlish gem will contain:
@@ -16,6 +16,7 @@ module Zenlish
16
16
 
17
17
  def add_word_classes(aLexicon)
18
18
  aLexicon.add_terminal(WClasses::Adjective.new.freeze)
19
+ aLexicon.add_terminal(WClasses::Adverb.new.freeze)
19
20
  aLexicon.add_terminal(WClasses::Cardinal.new.freeze)
20
21
  aLexicon.add_terminal(WClasses::CommonNoun.new.freeze)
21
22
  aLexicon.add_terminal(WClasses::ComparativeParticle.new.freeze)
@@ -23,7 +24,9 @@ module Zenlish
23
24
  aLexicon.add_terminal(WClasses::DemonstrativeDeterminer.new.freeze)
24
25
  aLexicon.add_terminal(WClasses::IndefinitePronoun.new.freeze)
25
26
  aLexicon.add_terminal(WClasses::IrregularVerb.new.freeze)
27
+ aLexicon.add_terminal(WClasses::Preposition.new.freeze)
26
28
  aLexicon.add_terminal(WClasses::ProperNoun.new.freeze)
29
+ aLexicon.add_terminal(WClasses::IndefiniteQuantifier.new.freeze)
27
30
  end
28
31
 
29
32
  def add_punctuation(aLexicon)
@@ -14,25 +14,37 @@ builder = Rley::Syntax::GrammarBuilder.new do
14
14
  rule 'sentence' => 'simple_sentence'
15
15
  rule 'simple_sentence' => 'declarative_simple_sentence Period'
16
16
  rule 'declarative_simple_sentence' => 'noun_phrase verb_phrase'
17
- rule 'noun_phrase' => 'noun_bar'
18
- rule 'noun_phrase' => 'determiner noun_bar'
19
- rule 'noun_phrase' => 'numeral noun_bar'
20
- rule 'noun_phrase' => 'determiner numeral noun_bar'
17
+ rule 'noun_phrase' => 'nominal'
18
+ rule 'noun_phrase' => 'determiner nominal'
19
+ rule 'noun_phrase' => 'numeral nominal'
20
+ rule 'noun_phrase' => 'determiner numeral nominal'
21
21
  rule 'noun_phrase' => 'ProperNoun'
22
22
  rule 'noun_phrase' => 'IndefinitePronoun'
23
- rule 'noun_bar' => 'CommonNoun'
24
- rule 'noun_bar' => 'Adjective CommonNoun'
25
- rule 'noun_bar' => 'Adjective CommonNoun comparative_clause'
26
- rule 'determiner' => 'DemonstrativeDeterminer'
27
- rule 'determiner' => 'DefiniteArticle'
28
- rule 'verb_phrase' => 'lexical_verb'
23
+ rule 'nominal' => 'CommonNoun'
24
+ rule 'nominal' => 'Adjective CommonNoun'
25
+ rule 'nominal' => 'Adjective CommonNoun comparative_clause'
26
+ rule 'determiner' => 'determiner single_determiner'
27
+ rule 'determiner' => 'single_determiner'
28
+ rule 'single_determiner' => 'DemonstrativeDeterminer'
29
+ rule 'single_determiner' => 'DefiniteArticle'
30
+ rule 'single_determiner' => 'IndefiniteQuantifier'
31
+ rule 'verb_phrase' => 'lexical_verb'
29
32
  rule 'verb_phrase' => 'lexical_verb noun_phrase'
33
+ rule 'verb_phrase' => 'lexical_verb adverb_phrase'
34
+ rule 'verb_phrase' => 'lexical_verb propositional_phrase'
35
+ rule 'verb_phrase' => 'lexical_verb noun_phrase adverb_phrase'
36
+ rule 'verb_phrase' => 'lexical_verb noun_phrase propositional_phrase'
30
37
  rule 'lexical_verb' => 'IrregularVerb'
31
38
  rule 'numeral' => 'Cardinal'
32
39
  rule 'comparative_clause' => 'comparative_start noun_phrase verb_phrase'
33
40
  rule 'comparative_start' => 'ComparativeParticle'
41
+ rule 'adverb_phrase' => 'Adverb'
42
+ rule 'adverb_phrase' => 'Adverb propositional_phrase'
43
+ rule 'propositional_phrase' => 'Preposition propositional_complement'
44
+ rule 'propositional_complement' => 'noun_phrase'
34
45
  end
35
46
 
47
+
36
48
  # CGE p. 354 The order of determiners: quantifier > article or demonstrative
37
49
  # or possessive > numeral > head
38
50
 
@@ -1,3 +1,3 @@
1
1
  module Zenlish
2
- VERSION = '0.1.01'
2
+ VERSION = '0.1.02'
3
3
  end
@@ -0,0 +1,9 @@
1
+ require_relative 'word_class'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # TODO: document
6
+ class Adverb < WordClass
7
+ end # class
8
+ end # module
9
+ end # module
@@ -2,6 +2,7 @@
2
2
  # Algorithm: load the leaf classes from hierarchy
3
3
 
4
4
  require_relative 'adjective'
5
+ require_relative 'adverb'
5
6
  require_relative 'cardinal'
6
7
  require_relative 'comparative_particle'
7
8
  require_relative 'common_noun'
@@ -10,4 +11,6 @@ require_relative 'proper_noun'
10
11
  require_relative 'irregular_verb'
11
12
  require_relative 'definite_article'
12
13
  require_relative 'demonstrative_determiner'
13
- require_relative 'indefinite_pronoun'
14
+ require_relative 'indefinite_pronoun'
15
+ require_relative 'indefinite_quantifier'
16
+ require_relative 'preposition'
@@ -0,0 +1,10 @@
1
+ require_relative 'adjective'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # TODO: document
6
+ # many
7
+ class IndefiniteQuantifier < Adjective
8
+ end # class
9
+ end # module
10
+ end # module
@@ -0,0 +1,9 @@
1
+ require_relative 'word_class'
2
+
3
+ module Zenlish
4
+ module WClasses
5
+ # TODO: document
6
+ class Preposition < WordClass
7
+ end # class
8
+ end # module
9
+ end # module
@@ -21,7 +21,11 @@ module Zenlish
21
21
  end
22
22
 
23
23
  def as ; Lex::Literal.new('as', get_lexeme('as'), 0) ; end
24
+ def inside ; Lex::Literal.new('inside', get_lexeme('inside'), 0) ; end
25
+ def is ; Lex::Literal.new('is', get_lexeme('be'), 0) ; end
24
26
  def lisa ; Lex::Literal.new('Lisa', get_lexeme('Lisa'), 0) ; end
27
+ def many ; Lex::Literal.new('many', get_lexeme('many'), 0) ; end
28
+ def not_ ; Lex::Literal.new('not', get_lexeme('not'), 0) ; end
25
29
  def one ; Lex::Literal.new('one', get_lexeme('one'), 0) ; end
26
30
  def two ; Lex::Literal.new('two', get_lexeme('two'), 0) ; end
27
31
  def other ; Lex::Literal.new('other', get_lexeme('other'), 0) ; end
@@ -103,9 +107,33 @@ module Zenlish
103
107
  # Sentence 1-08b: "Lisa sees two people."
104
108
  literals = [lisa, sees, two, people, dot]
105
109
  expect { subject.parse(literals) }.not_to raise_error
110
+
111
+ # Sentence 1-05b: "Tony sees the same person as Lisa sees."
112
+ literals = [tony, sees, the, same, person, as, lisa, sees, dot]
113
+ # same is an adjective of equality comparison
114
+ # as is part of same ... as combination
115
+ # it introduces a comparative clause
116
+ expect { subject.parse(literals) }.not_to raise_error
117
+ end
118
+
119
+ it 'should parse sample sentences from lesson 1-C' do
120
+ # Sentence 1-09a: "Tony sees many things."
121
+ literals = [tony, sees, many, things, dot]
122
+ expect { subject.parse(literals) }.not_to raise_error
123
+
124
+ # Sentence 1-09b: "Lisa sees many people."
125
+ literals = [lisa, sees, many, people, dot]
126
+ expect { subject.parse(literals) }.not_to raise_error
127
+
128
+ # Sentence 1-10: "Tony is inside this thing."
129
+ literals = [tony, is, inside, this, thing, dot]
130
+ expect { subject.parse(literals) }.not_to raise_error
131
+
132
+ # Sentence 1-11: "Lisa is not inside this thing."
133
+ literals = [lisa, is, not_, inside, this, thing, dot]
134
+ expect { subject.parse(literals) }.not_to raise_error
106
135
  end
107
136
  end # context
108
137
  end # describe
109
138
  end # module
110
139
  end # module
111
-
@@ -6,13 +6,16 @@ require_relative '../../../lib/zenlish/lex/lexicon'
6
6
 
7
7
  common_noun = $ZenlishLexicon.name2terminal['CommonNoun']
8
8
  adjective = $ZenlishLexicon.name2terminal['Adjective']
9
+ adverb = $ZenlishLexicon.name2terminal['Adverb']
9
10
  proper_noun = $ZenlishLexicon.name2terminal['ProperNoun']
11
+ preposition = $ZenlishLexicon.name2terminal['Preposition']
10
12
  irregular_verb = $ZenlishLexicon.name2terminal['IrregularVerb']
11
13
  indefinite_pronoun = $ZenlishLexicon.name2terminal['IndefinitePronoun']
12
14
  demonstrative_determiner = $ZenlishLexicon.name2terminal['DemonstrativeDeterminer']
13
15
  definite_article = $ZenlishLexicon.name2terminal['DefiniteArticle']
14
16
  cardinal = $ZenlishLexicon.name2terminal['Cardinal']
15
17
  comparative_particle = $ZenlishLexicon.name2terminal['ComparativeParticle']
18
+ indefinite_quantifier = $ZenlishLexicon.name2terminal['IndefiniteQuantifier']
16
19
  dot = $ZenlishLexicon.name2terminal['Period']
17
20
 
18
21
  def add_entry(aLemma, aWordClass)
@@ -24,7 +27,11 @@ end
24
27
 
25
28
  # Our minimalistic lexicon
26
29
  add_entry('as', comparative_particle)
30
+ add_entry('be', irregular_verb)
31
+ add_entry('inside', preposition)
27
32
  add_entry('Lisa', proper_noun)
33
+ add_entry('many', indefinite_quantifier)
34
+ add_entry('not', adverb)
28
35
  add_entry('one', cardinal)
29
36
  add_entry('other', adjective)
30
37
  add_entry('people', common_noun)
data/zenlish.gemspec CHANGED
@@ -8,12 +8,13 @@ module PkgExtending
8
8
  file_list = Dir[
9
9
  '.rubocop.yml',
10
10
  '.rspec',
11
+ '.travis.yml',
11
12
  '.yardopts',
12
13
  'appveyor.yml',
13
- 'cucumber.yml',
14
14
  'Gemfile',
15
15
  'Rakefile',
16
16
  'CHANGELOG.md',
17
+ 'CODE_OF_CONDUCT.md',
17
18
  'LICENSE.txt',
18
19
  'README.md',
19
20
  'zenlish.gemspec',
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.01
4
+ version: 0.1.02
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-10 00:00:00.000000000 Z
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -75,8 +75,10 @@ extra_rdoc_files:
75
75
  - README.md
76
76
  files:
77
77
  - ".rspec"
78
+ - ".travis.yml"
78
79
  - ".yardopts"
79
80
  - CHANGELOG.md
81
+ - CODE_OF_CONDUCT.md
80
82
  - Gemfile
81
83
  - LICENSE.txt
82
84
  - README.md
@@ -92,6 +94,7 @@ files:
92
94
  - lib/zenlish/parser/zparser.rb
93
95
  - lib/zenlish/version.rb
94
96
  - lib/zenlish/wclasses/adjective.rb
97
+ - lib/zenlish/wclasses/adverb.rb
95
98
  - lib/zenlish/wclasses/all_word_classes.rb
96
99
  - lib/zenlish/wclasses/article.rb
97
100
  - lib/zenlish/wclasses/cardinal.rb
@@ -101,10 +104,12 @@ files:
101
104
  - lib/zenlish/wclasses/demonstrative_determiner.rb
102
105
  - lib/zenlish/wclasses/determiner.rb
103
106
  - lib/zenlish/wclasses/indefinite_pronoun.rb
107
+ - lib/zenlish/wclasses/indefinite_quantifier.rb
104
108
  - lib/zenlish/wclasses/irregular_verb.rb
105
109
  - lib/zenlish/wclasses/lexical_verb.rb
106
110
  - lib/zenlish/wclasses/noun.rb
107
111
  - lib/zenlish/wclasses/numeral.rb
112
+ - lib/zenlish/wclasses/preposition.rb
108
113
  - lib/zenlish/wclasses/pronoun.rb
109
114
  - lib/zenlish/wclasses/proper_noun.rb
110
115
  - lib/zenlish/wclasses/test_hierarchy.rb