define-wn 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/define-wn +14 -0
- data/define.gemspec +30 -0
- data/lib/define.rb +46 -0
- data/lib/define/version.rb +3 -0
- metadata +206 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Robie Lutsey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Define-wn
|
2
|
+
|
3
|
+
Looks up the word provided on the command line using WordNet Via www.dict.org. provides a definition and the type of word, I.E., noun, verbe, adjective etc...
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'define-wn'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install define-wn
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
define-wn <word>
|
22
|
+
|
23
|
+
## ToDo
|
24
|
+
|
25
|
+
* tests
|
26
|
+
* add depth to word type. should return array if there are multiple definitions.
|
27
|
+
* allow use of more of the dict.org functionality.
|
28
|
+
* allow use of some of the facny funtionality wordnet allows.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/define-wn
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require './lib/define'
|
4
|
+
module Define
|
5
|
+
|
6
|
+
word = ARGV[0] || "felicity"
|
7
|
+
begin
|
8
|
+
defi = Word_lookup.new(word)
|
9
|
+
puts "The definition is: #{defi.definition}"
|
10
|
+
puts "Word type: #{defi.type}"
|
11
|
+
rescue
|
12
|
+
puts "Sorry. I couldn't find that word."
|
13
|
+
end
|
14
|
+
end
|
data/define.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/define/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Robie Lutsey"]
|
6
|
+
gem.email = ["robie1373@gmail.com"]
|
7
|
+
gem.description = %q{Look up words using Wordnet}
|
8
|
+
gem.summary = %q{Hits the www.dict.org server and uses mechanize to twiddle the form. Amazingly, this produces a definition. Eventually.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "define-wn"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Define::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec"
|
19
|
+
gem.add_development_dependency "guard"
|
20
|
+
gem.add_development_dependency "guard-rspec"
|
21
|
+
gem.add_development_dependency 'rb-fsevent', '~>0.9.1'
|
22
|
+
gem.add_development_dependency 'turn', '~>0.9.6'
|
23
|
+
gem.add_development_dependency 'growl', '~>1.0.3'
|
24
|
+
|
25
|
+
|
26
|
+
gem.add_dependency 'bundler', "~>1.1"
|
27
|
+
gem.add_dependency 'rake', '~>0.9.2'
|
28
|
+
gem.add_dependency 'mechanize', '~>2.5.1'
|
29
|
+
|
30
|
+
end
|
data/lib/define.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require "./lib/define/version"
|
3
|
+
|
4
|
+
module Define
|
5
|
+
|
6
|
+
class Word_lookup
|
7
|
+
def initialize (word)
|
8
|
+
@word = word
|
9
|
+
@full_def = look_up
|
10
|
+
end
|
11
|
+
|
12
|
+
def definition
|
13
|
+
@full_def
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
matchdata = @full_def.match /^\s+(?<word>#{@word})\s+(?<type>\w+)\s+\d:/
|
18
|
+
type = matchdata[:type]
|
19
|
+
case type
|
20
|
+
when "n" then
|
21
|
+
:noun
|
22
|
+
when "adv" then
|
23
|
+
:adverb
|
24
|
+
when "adj" then
|
25
|
+
:adjective
|
26
|
+
when "v" then
|
27
|
+
:verb
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def look_up
|
34
|
+
agent = Mechanize.new
|
35
|
+
|
36
|
+
page = agent.get('http://www.dict.org/bin/Dict')
|
37
|
+
dict_form = page.form('DICT')
|
38
|
+
dict_form.Query = @word
|
39
|
+
dict_form.field_with(:name => 'Database').options[3].select
|
40
|
+
|
41
|
+
page = agent.submit(dict_form, dict_form.buttons.first)
|
42
|
+
page.search("pre")[2].text
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: define-wn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robie Lutsey
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-fsevent
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.1
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: turn
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.9.6
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.6
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: growl
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.0.3
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.3
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: bundler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.1'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.1'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rake
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.9.2
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.9.2
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: mechanize
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.5.1
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.5.1
|
158
|
+
description: Look up words using Wordnet
|
159
|
+
email:
|
160
|
+
- robie1373@gmail.com
|
161
|
+
executables:
|
162
|
+
- define-wn
|
163
|
+
extensions: []
|
164
|
+
extra_rdoc_files: []
|
165
|
+
files:
|
166
|
+
- .gitignore
|
167
|
+
- Gemfile
|
168
|
+
- LICENSE
|
169
|
+
- README.md
|
170
|
+
- Rakefile
|
171
|
+
- bin/define-wn
|
172
|
+
- define.gemspec
|
173
|
+
- lib/define.rb
|
174
|
+
- lib/define/version.rb
|
175
|
+
homepage: ''
|
176
|
+
licenses: []
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
hash: 4246517374910766778
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
192
|
+
requirements:
|
193
|
+
- - ! '>='
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
segments:
|
197
|
+
- 0
|
198
|
+
hash: 4246517374910766778
|
199
|
+
requirements: []
|
200
|
+
rubyforge_project:
|
201
|
+
rubygems_version: 1.8.24
|
202
|
+
signing_key:
|
203
|
+
specification_version: 3
|
204
|
+
summary: Hits the www.dict.org server and uses mechanize to twiddle the form. Amazingly,
|
205
|
+
this produces a definition. Eventually.
|
206
|
+
test_files: []
|