bronto-gem 0.0.1

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
+ SHA1:
3
+ metadata.gz: bde8e04b8b31e977efd94ce49f7ab9309785f312
4
+ data.tar.gz: d9bf9243e86bf95932e4560ac836c115b1e9634d
5
+ SHA512:
6
+ metadata.gz: 876d76d9b53e830f4e907139453adce2347e4a753effd6e77ec94abd3e6b5ff89c2e0aa658a9b6bccf02e73bfbf40541f098160d0c434c92c7a39a96979cbcae
7
+ data.tar.gz: 8edfcbbbe74caf139e174f2029c5f85066951941177bfc66061446acc84a74f370444c5ee872ced727d9c06e304a087c7ceeb7e6541277679e0b45f62b6c80e6
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bronto-gem.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org>
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # BrontoGem
2
+
3
+ A thesaurus gem.
4
+
5
+ ## Installation (pending)
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'bronto-gem'
11
+ ````
12
+
13
+ And then execute:
14
+
15
+ ```sh
16
+ $ bundle
17
+ ```
18
+
19
+
20
+ Or install it yourself as:
21
+
22
+ ```sh
23
+ $ gem install bronto-gem
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'bronto-gem'
30
+
31
+ synonyms = BrontoGem.lookup("fish") #=>
32
+
33
+ {
34
+ verb: {
35
+ syn: ["angle", "catch", "grab", "look for", "search", "seek", "take hold of"]
36
+ },
37
+ noun: {
38
+ syn: [
39
+ "aquatic vertebrate",
40
+ "food",
41
+ "individual",
42
+ "mortal",
43
+ "person",
44
+ "pisces",
45
+ "pisces the fishes",
46
+ "solid food",
47
+ "somebody",
48
+ "someone",
49
+ "soul"]
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it ( https://github.com/adelevie/bronto-gem/fork )
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create a new Pull Request
61
+
62
+ ## License
63
+
64
+ See `LICENSE.txt`
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bronto/bronto-gem/version'
5
+ require 'bronto/bronto-gem/lookup'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "bronto-gem"
9
+ spec.version = BrontoGem::VERSION
10
+ spec.authors = ["Alan deLevie"]
11
+ spec.email = ["alan.delevie@gsa.gov"]
12
+ spec.summary = %q{Thesaurus gem}
13
+ spec.description = %q{Thesaurus gem}
14
+ spec.homepage = ""
15
+ spec.license = "Public Domain. See LICENSE.txt"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "wordnet"
23
+ spec.add_dependency "wordnet-defaultdb"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "pry-rescue"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "simplecov"
30
+ end
@@ -0,0 +1,36 @@
1
+ require 'wordnet'
2
+ require 'wordnet-defaultdb'
3
+
4
+ $lex = WordNet::Lexicon.new
5
+
6
+ module BrontoGem
7
+ def self.lookup(word)
8
+ query = word.downcase
9
+ synsets = $lex.lookup_synsets(query)
10
+
11
+ words = []
12
+
13
+ synsets.each do |synset|
14
+ synset.words.map {|word| words << [word.lemma, synset.part_of_speech.to_sym] unless word.lemma == query}
15
+
16
+ synset.hypernyms.each do |hypernym|
17
+ hypernym.words.map {|word| words << [word.lemma, synset.part_of_speech.to_sym] unless word.lemma == query}
18
+ end
19
+ end
20
+
21
+ synonyms = words.sort_by {|word| word.first }.uniq!
22
+
23
+ return nil if synonyms.nil? # check out early if nothing is found
24
+
25
+ hash = {}
26
+
27
+ if synonyms
28
+ synonyms.each do |synonym|
29
+ hash[synonym.last] = {syn: [] } unless hash.member?(synonym.last)
30
+ hash[synonym.last][:syn] << synonym.first
31
+ end
32
+ end
33
+
34
+ hash
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module BrontoGem
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrontoGem do
4
+
5
+ context 'when a word is entered' do
6
+ before do
7
+ @response = BrontoGem.lookup("fish")
8
+ end
9
+
10
+ it 'returns a hash of synoyms grouped by part of speech' do
11
+ fish_response = {
12
+ verb: {
13
+ syn: ["angle", "catch", "grab", "look for", "search", "seek", "take hold of"]
14
+ },
15
+ noun: {
16
+ syn: [
17
+ "aquatic vertebrate",
18
+ "food",
19
+ "individual",
20
+ "mortal",
21
+ "person",
22
+ "pisces",
23
+ "pisces the fishes",
24
+ "solid food",
25
+ "somebody",
26
+ "someone",
27
+ "soul"]
28
+ }
29
+ }
30
+
31
+ expect(@response).to eq fish_response
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,2 @@
1
+ RSpec.configure do |c|
2
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bronto-gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alan deLevie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: wordnet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: wordnet-defaultdb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-rescue
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Thesaurus gem
112
+ email:
113
+ - alan.delevie@gsa.gov
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".ruby-version"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - bronto-gem.gemspec
125
+ - lib/bronto/bronto-gem/lookup.rb
126
+ - lib/bronto/bronto-gem/version.rb
127
+ - spec/lookup_spec.rb
128
+ - spec/spec_helper.rb
129
+ homepage: ''
130
+ licenses:
131
+ - Public Domain. See LICENSE.txt
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.2.2
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Thesaurus gem
153
+ test_files:
154
+ - spec/lookup_spec.rb
155
+ - spec/spec_helper.rb