greetlang 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c231d00cc0d4610e6cf54f419eb3530be3993ecb4745e2b8ce320ea8d9b79d44
4
+ data.tar.gz: a7a3acfa1387c2dd5f6e267db50a1ea32d703f409105e96153117df67de2772d
5
+ SHA512:
6
+ metadata.gz: 3aa412d505fdaad95530e618635311e8c8b015e7250d64f380e8f355865ffe53552012ff721616d21c765b570e87d6952a5d7e1e62e1b7877e988a7c8959f26e
7
+ data.tar.gz: 738ff22d0c0350d067b60fda9f957c6adf761f3384a7d7920bb1cb2fceb8892fddf8850a2db07a03c4ac2bbbb1c815488c0b8e7ba0527b525a3e2d2b0da1cb18
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 gitea@fake.local. 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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in greetlang.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Gitea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Greetlang
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/greetlang`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'greetlang'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install greetlang
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/greetlang. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/greetlang/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the Greetlang project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/greetlang/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "greetlang"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/greetlang.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/greetlang/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "greetlang"
5
+ spec.version = Greetlang::VERSION
6
+ spec.authors = ["LWFlouisa"]
7
+ spec.email = ["lwflouisa@riseup.net"]
8
+
9
+ spec.summary = %q{Greetlang is a smart language that uses Red Davis' Simple Naive Bayes algorithm.}
10
+ spec.description = %q{Longer description coming soon.}
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency 'naive_bayes', '~> 0.0.3'
25
+ end
@@ -0,0 +1,3 @@
1
+ module Greetlang
2
+ VERSION = "0.1.0"
3
+ end
data/lib/greetlang.rb ADDED
@@ -0,0 +1,187 @@
1
+ require "greetlang/version"
2
+
3
+ module Greetlang
4
+ class Error < StandardError; end
5
+
6
+ class Syntax
7
+ def self.irb
8
+
9
+ # bayesian algorithm for detecting greeting type.
10
+ def self.greeting
11
+ require "naive_bayes"
12
+
13
+ a = NaiveBayes.new(:polite, :rude)
14
+
15
+ # Polite greeting
16
+ a.train(:polite, 'Hello', 'word')
17
+ a.train(:polite, 'Hey', 'word')
18
+
19
+ # Rude greeting
20
+ a.train(:rude, 'Hi', 'word')
21
+ a.train(:rude, 'Ahoy', 'word')
22
+ a.train(:rude, 'Yo', 'word')
23
+
24
+ b = $greeting.split(' ')
25
+
26
+ a.classify(*b)
27
+ end
28
+
29
+ # bayesian algorithm for detecting request type.
30
+ def self.request
31
+ require "naive_bayes"
32
+
33
+ a = NaiveBayes.new(:request, :demand)
34
+
35
+ # Requests and demands.
36
+ a.train(:request, 'may', 'word')
37
+ a.train(:request, 'can', 'word')
38
+ a.train(:demand, 'will', 'word')
39
+
40
+ b = $request.split(' ')
41
+
42
+ puts a.classify(*b)
43
+ end
44
+
45
+ # bayesian algorithm for detecting item type.
46
+ def self.item
47
+ require "naive_bayes"
48
+
49
+ a = NaiveBayes.new(:item, :object)
50
+
51
+ # Item and gender
52
+ a.train(:item, 'some apples', 'word')
53
+ a.train(:item, 'some bananas', 'word')
54
+ a.train(:item, 'some oranges', 'word')
55
+ a.train(:item, 'some strawberries', 'word')
56
+ a.train(:item, 'some apricots', 'word')
57
+ a.train(:item, 'some kiwis', 'word')
58
+ a.train(:item, 'many apples', 'word')
59
+ a.train(:item, 'many bananas', 'word')
60
+ a.train(:item, 'many oranges', 'word')
61
+ a.train(:item, 'many strawberries', 'word')
62
+ a.train(:item, 'many apricots', 'word')
63
+ a.train(:item, 'many kiwis', 'word')
64
+ a.train(:item, 'a apple', 'word')
65
+ a.train(:item, 'a banana', 'word')
66
+ a.train(:item, 'a orange', 'word')
67
+ a.train(:item, 'a strawberrie', 'word')
68
+ a.train(:item, 'a apricot', 'word')
69
+ a.train(:item, 'a kiwi', 'word')
70
+ a.train(:item, 'some potatoes', 'word')
71
+ a.train(:item, 'some tomatoes', 'word')
72
+ a.train(:item, 'some eggplants', 'word')
73
+ a.train(:item, 'some onions', 'word')
74
+ a.train(:item, 'some garlic', 'word')
75
+ a.train(:item, 'some peppers', 'word')
76
+ a.train(:item, 'many potatoes', 'word')
77
+ a.train(:item, 'many tomatoes', 'word')
78
+ a.train(:item, 'many eggplants', 'word')
79
+ a.train(:item, 'many onions', 'word')
80
+ a.train(:item, 'many garlic', 'word')
81
+ a.train(:item, 'many peppers', 'word')
82
+ a.train(:item, 'a potatoe', 'word')
83
+ a.train(:item, 'a tomatoe', 'word')
84
+ a.train(:item, 'a eggplant', 'word')
85
+ a.train(:item, 'a onion', 'word')
86
+ a.train(:item, 'a garlic', 'word')
87
+ a.train(:item, 'a pepper', 'word')
88
+
89
+ # Object and gender
90
+ a.train(:object, 'some microphones', 'word')
91
+ a.train(:object, 'some laptops', 'word')
92
+ a.train(:object, 'some mousepads', 'word')
93
+ a.train(:object, 'some consoles', 'word')
94
+ a.train(:object, 'some mugs', 'word')
95
+ a.train(:object, 'some knives', 'word')
96
+ a.train(:object, 'some spatulas', 'word')
97
+ a.train(:object, 'some pans', 'word')
98
+ a.train(:object, 'some pots', 'word')
99
+ a.train(:object, 'many microphones', 'word')
100
+ a.train(:object, 'many laptops', 'word')
101
+ a.train(:object, 'many mousepads', 'word')
102
+ a.train(:object, 'many consoles', 'word')
103
+ a.train(:object, 'many mugs', 'word')
104
+ a.train(:object, 'many knives', 'word')
105
+ a.train(:object, 'many spatulas', 'word')
106
+ a.train(:object, 'many pans', 'word')
107
+ a.train(:object, 'many pots', 'word')
108
+ a.train(:object, 'a microphones', 'word')
109
+ a.train(:object, 'a laptops', 'word')
110
+ a.train(:object, 'a mousepads', 'word')
111
+ a.train(:object, 'a consoles', 'word')
112
+ a.train(:object, 'a mugs', 'word')
113
+ a.train(:object, 'a knives', 'word')
114
+ a.train(:object, 'a spatulas', 'word')
115
+ a.train(:object, 'a pans', 'word')
116
+ a.train(:object, 'a pots', 'word')
117
+
118
+ b = $item.split(' ')
119
+
120
+ puts a.classify(*b)
121
+ end
122
+
123
+ # bayesian algorithm for detecting for_from type.
124
+ def self.for_from
125
+ require "naive_bayes"
126
+
127
+ a = NaiveBayes.new(:spam, :ham)
128
+
129
+ # For or from
130
+ a.train(:for, 'for', 'word')
131
+ a.train(:from, 'from', 'word')
132
+
133
+ b = $for_from.split(' ')
134
+
135
+ puts a.classify(*b)
136
+ end
137
+
138
+ def self.user_location
139
+ require "naive_bayes"
140
+
141
+ a = NaiveBayes.new(:state, :nonstate)
142
+
143
+ # State
144
+ a.train(:state, 'Tennessee', 'word')
145
+ a.train(:state, 'Georgia', 'word')
146
+ a.train(:state, 'Alabama', 'word')
147
+ a.train(:state, 'Kentucky', 'word')
148
+ a.train(:state, 'North Carolina', 'word')
149
+
150
+ # Non State
151
+ a.train(:state, 'Guillotine', 'word')
152
+ a.train(:state, 'Park', 'word')
153
+ a.train(:state, 'Wildlife', 'word')
154
+ a.train(:state, 'Tree', 'word')
155
+
156
+ b = $user_location.split(' ')
157
+
158
+ puts a.classify(*b)
159
+ end
160
+
161
+ # Main interactive shell.
162
+ loop do
163
+ print "Greetlang(main) #{number}> "
164
+ request = gets.chomp
165
+
166
+ if request == "exit"
167
+ puts "Goodbye!"
168
+ abort
169
+ end
170
+
171
+ request = request.split(" ")
172
+
173
+ $greeting = request[0]
174
+ $request = request[1]
175
+ $item = request[2]
176
+ $for_from = request[3]
177
+ $user_location = request[4]
178
+
179
+ Greetlang::Syntax.irb.greeting
180
+ Greetlang::Syntax.irb.request
181
+ Greetlang::Syntax.irb.item
182
+ Greetlang::Syntax.irb.for_from
183
+ Greetlang::Syntax.irb.user_location
184
+ end
185
+ end
186
+ end
187
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: greetlang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - LWFlouisa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: naive_bayes
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.3
27
+ description: Longer description coming soon.
28
+ email:
29
+ - lwflouisa@riseup.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - CODE_OF_CONDUCT.md
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - bin/console
43
+ - bin/setup
44
+ - greetlang.gemspec
45
+ - lib/greetlang.rb
46
+ - lib/greetlang/version.rb
47
+ homepage: ''
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.0.6
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Greetlang is a smart language that uses Red Davis' Simple Naive Bayes algorithm.
70
+ test_files: []