lyracyst 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +22 -22
- data/bin/lyracyst +293 -81
- data/lib/lyracyst.rb +293 -81
- data/lib/lyracyst/rhymebrain.rb +138 -0
- data/lib/lyracyst/version.rb +1 -1
- data/lib/lyracyst/wordnik.rb +326 -0
- metadata +29 -46
- data/lib/lyracyst/define.rb +0 -35
- data/lib/lyracyst/get.rb +0 -21
- data/lib/lyracyst/relate.rb +0 -171
- data/lib/lyracyst/rhyme.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52dc9e24fd2289f6afd97edaa876f8b0c3cc418a
|
4
|
+
data.tar.gz: 00e086cdbf93d6763e57f88e695e6861428681f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b5e8a37901f2f74819ae12eb5273e6b462cbe2db7f8da8b5bcaaf5a7c200c9fd9ce20eb486392f348c8576c009797bb7cfd37fa9ff9de1dd69aa1c435793b4
|
7
|
+
data.tar.gz: 8f18730e1c9ba61d752cd4474cf5a25ce7ae752b79f33f27ffd2c95f98cc5cd6618b32c26857d5830752b38971c4baac728fbc621cbd8ea731cda60d98dbe52b
|
data/LICENSE.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
========
|
3
|
-
|
4
|
-
**Copyright (c) 2014 Drew Prentice**
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
8
|
-
in the Software without restriction, including without limitation the rights
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.**
|
1
|
+
The MIT License (MIT)
|
2
|
+
========
|
3
|
+
|
4
|
+
**Copyright (c) 2014 Drew Prentice**
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.**
|
data/bin/lyracyst
CHANGED
@@ -1,92 +1,304 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
|
+
require 'gli'
|
4
|
+
require './lib/lyracyst/rhymebrain.rb'
|
5
|
+
require './lib/lyracyst/version.rb'
|
6
|
+
require './lib/lyracyst/wordnik.rb'
|
3
7
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
8
|
+
include GLI::App
|
9
|
+
program_desc 'A powerful word search tool that fetches definitions, related words, rhymes, and much more.'
|
10
|
+
config_file '.lyracyst.yml'
|
11
|
+
version Lyracyst::VERSION
|
12
|
+
|
13
|
+
desc 'HTTP adapter'
|
14
|
+
long_desc 'httpclient, curb, em_http, net_http_persistent, excon, rack'
|
15
|
+
default_value :excon
|
16
|
+
arg_name 'http'
|
17
|
+
flag [:h,:http]
|
18
|
+
|
19
|
+
desc 'JSON adapter'
|
20
|
+
long_desc 'oj, yajl, json_gem, json_pure'
|
21
|
+
default_value :json_pure
|
22
|
+
arg_name 'json'
|
23
|
+
flag [:j,:json]
|
24
|
+
|
25
|
+
desc 'XML adapter'
|
26
|
+
long_desc 'ox, libxml, nokogiri, rexml'
|
27
|
+
default_value :rexml
|
28
|
+
arg_name 'xml'
|
29
|
+
flag [:x,:xml]
|
30
|
+
|
31
|
+
desc 'Fetches definitions from Wordnik'
|
32
|
+
arg_name 'word'
|
33
|
+
command :define do |c|
|
34
|
+
c.desc 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
|
35
|
+
c.default_value nil
|
36
|
+
c.arg_name 'part'
|
37
|
+
c.flag [:p,:part]
|
38
|
+
c.desc "Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet"
|
39
|
+
c.default_value 'all'
|
40
|
+
c.arg_name 'defdict'
|
41
|
+
c.flag [:defdict]
|
42
|
+
c.action do |global_options,options,args|
|
43
|
+
# If you have any errors, just raise them
|
44
|
+
# raise "that command made no sense"
|
45
|
+
search = args[0]
|
46
|
+
part = options[:p]
|
47
|
+
params = {limit: 10, increl: false, canon: false, inctags: false}
|
48
|
+
params[:defdict] = options[:defdict]
|
49
|
+
df = Lyracyst::Wordnik.new
|
50
|
+
df.get_def(search, part, params)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Fetches examples from Wordnik'
|
55
|
+
arg_name 'word'
|
56
|
+
command :example do |c|
|
57
|
+
c.desc 'Results to skip'
|
58
|
+
c.default_value 0
|
59
|
+
c.arg_name 'skip'
|
60
|
+
c.flag [:s,:skip]
|
61
|
+
c.desc 'Maximum number of results to return'
|
62
|
+
c.default_value 5
|
63
|
+
c.arg_name 'limit'
|
64
|
+
c.flag [:limit]
|
65
|
+
c.action do |global_options,options,args|
|
66
|
+
search = args[0]
|
67
|
+
skip = options[:s]
|
68
|
+
limit = options[:limit]
|
69
|
+
params = {incdups: false, canon: false}
|
70
|
+
params[:skip] = skip
|
71
|
+
params[:limit] = limit
|
72
|
+
ex = Lyracyst::Wordnik.new
|
73
|
+
ex.get_ex(search, params)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Fetches related words from Wordnik'
|
78
|
+
arg_name 'word'
|
79
|
+
command :relate do |c|
|
80
|
+
c.desc 'Limits the total results per type of relationship type'
|
81
|
+
c.default_value nil
|
82
|
+
c.arg_name 'reltypes'
|
83
|
+
c.flag [:relt]
|
84
|
+
c.desc 'Restrict to the supplied relationship types'
|
85
|
+
c.default_value 10
|
86
|
+
c.arg_name 'rell'
|
87
|
+
c.flag [:rell]
|
88
|
+
c.action do |global_options,options,args|
|
89
|
+
search = args[0]
|
90
|
+
reltypes = options[:relt]
|
91
|
+
rellimit = options[:rell]
|
92
|
+
params = {canon: false}
|
93
|
+
params[:rellimit] = rellimit
|
94
|
+
ex = Lyracyst::Wordnik.new
|
95
|
+
ex.get_rel(search, params, reltypes)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Fetches pronunciations from Wordnik'
|
100
|
+
arg_name 'word'
|
101
|
+
command :pronounce do |c|
|
102
|
+
c.desc 'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
|
103
|
+
c.default_value nil
|
104
|
+
c.arg_name 'source'
|
105
|
+
c.flag [:src]
|
106
|
+
c.desc 'Text pronunciation type'
|
107
|
+
c.long_desc 'ahd, arpabet, gcide-diacritical, IPA'
|
108
|
+
c.default_value nil
|
109
|
+
c.arg_name 'ptype'
|
110
|
+
c.flag [:pt]
|
111
|
+
c.desc 'Maximum number of results to return'
|
112
|
+
c.default_value 5
|
113
|
+
c.arg_name 'limit'
|
114
|
+
c.flag [:limit]
|
115
|
+
c.action do |global_options,options,args|
|
116
|
+
search = args[0]
|
117
|
+
source = options[:src]
|
118
|
+
ptype = options[:pt]
|
119
|
+
limit = options[:limit]
|
120
|
+
params = {canon: false}
|
121
|
+
params[:source] = source
|
122
|
+
params[:limit] = limit
|
123
|
+
pr = Lyracyst::Wordnik.new
|
124
|
+
pr.get_pro(search, params, ptype)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
|
129
|
+
arg_name 'word'
|
130
|
+
command :hyphen do |c|
|
131
|
+
c.desc "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
|
132
|
+
c.default_value nil
|
133
|
+
c.arg_name 'source'
|
134
|
+
c.flag [:src]
|
135
|
+
c.desc 'Maximum number of results to return'
|
136
|
+
c.default_value 5
|
137
|
+
c.arg_name 'limit'
|
138
|
+
c.flag [:limit]
|
139
|
+
c.action do |global_options,options,args|
|
140
|
+
search = args[0]
|
141
|
+
source = options[:src]
|
142
|
+
limit = options[:limit]
|
143
|
+
params = {canon: false}
|
144
|
+
if source != nil then params[:source] = source; end
|
145
|
+
params[:limit] = limit
|
146
|
+
hyph = Lyracyst::Wordnik.new
|
147
|
+
hyph.get_hyph(search, params)
|
42
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
desc 'Fetches bi-gram phrases from Wordnik'
|
152
|
+
arg_name 'word'
|
153
|
+
command :phrase do |c|
|
154
|
+
c.desc 'Maximum number of results to return'
|
155
|
+
c.default_value 10
|
156
|
+
c.arg_name 'limit'
|
157
|
+
c.flag [:limit]
|
158
|
+
c.desc 'Minimum WLMI(weighted mutual info) for the phrase.'
|
159
|
+
c.default_value 13
|
160
|
+
c.arg_name 'wlmi'
|
161
|
+
c.flag [:wlmi]
|
162
|
+
c.action do |global_options,options,args|
|
163
|
+
search = args[0]
|
164
|
+
limit = options[:limit]
|
165
|
+
wlmi = options[:wlmi]
|
166
|
+
params = {canon: false}
|
167
|
+
params[:limit] = limit
|
168
|
+
params[:wlmi] = wlmi
|
169
|
+
phra = Lyracyst::Wordnik.new
|
170
|
+
phra.get_phr(search, params)
|
171
|
+
end
|
172
|
+
end
|
43
173
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
fmt = options.fmt
|
53
|
-
search = args[0]
|
54
|
-
de = Lyracyst::Define.new
|
55
|
-
puts "Getting definitions for [#{search}]"
|
56
|
-
de.define(search, fmt)
|
57
|
-
end
|
174
|
+
desc 'Fetches etymologies from Wordnik'
|
175
|
+
arg_name 'word'
|
176
|
+
command :origin do |c|
|
177
|
+
c.action do |global_options,options,args|
|
178
|
+
search = args[0]
|
179
|
+
params = {canon: false}
|
180
|
+
orig = Lyracyst::Wordnik.new
|
181
|
+
orig.get_et(search, params)
|
58
182
|
end
|
183
|
+
end
|
184
|
+
|
185
|
+
desc 'Fetches rhymes from Rhymebrain'
|
186
|
+
arg_name 'word'
|
187
|
+
command :rhyme do |c|
|
188
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
189
|
+
c.default_value 'en'
|
190
|
+
c.arg_name 'lang'
|
191
|
+
c.flag [:lang]
|
192
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
193
|
+
c.default_value nil
|
194
|
+
c.arg_name 'max'
|
195
|
+
c.flag [:max]
|
196
|
+
c.action do |global_options,options,args|
|
197
|
+
search = args[0]
|
198
|
+
lang = options[:lang]
|
199
|
+
max = options[:max]
|
200
|
+
params = {}
|
201
|
+
params[:lang] = lang
|
202
|
+
params[:max] = max
|
203
|
+
rhym = Lyracyst::Rhymebrain.new
|
204
|
+
rhym.get_rhyme(search, params)
|
205
|
+
end
|
206
|
+
end
|
59
207
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
208
|
+
desc 'Fetches word info from Rhymebrain'
|
209
|
+
arg_name 'word'
|
210
|
+
command :info do |c|
|
211
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
212
|
+
c.default_value 'en'
|
213
|
+
c.arg_name 'lang'
|
214
|
+
c.flag [:lang]
|
215
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
216
|
+
c.default_value nil
|
217
|
+
c.arg_name 'max'
|
218
|
+
c.flag [:max]
|
219
|
+
c.action do |global_options,options,args|
|
220
|
+
search = args[0]
|
221
|
+
lang = options[:lang]
|
222
|
+
max = options[:max]
|
223
|
+
params = {}
|
224
|
+
params[:lang] = lang
|
225
|
+
params[:max] = max
|
226
|
+
info = Lyracyst::Rhymebrain.new
|
227
|
+
info.get_info(search, params)
|
77
228
|
end
|
229
|
+
end
|
78
230
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
231
|
+
desc 'Fetches combined words (portmanteaus) from Rhymebrain'
|
232
|
+
arg_name 'word'
|
233
|
+
command :combine do |c|
|
234
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
235
|
+
c.default_value 'en'
|
236
|
+
c.arg_name 'lang'
|
237
|
+
c.flag [:lang]
|
238
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
239
|
+
c.default_value nil
|
240
|
+
c.arg_name 'max'
|
241
|
+
c.flag [:max]
|
242
|
+
c.action do |global_options,options,args|
|
243
|
+
search = args[0]
|
244
|
+
lang = options[:lang]
|
245
|
+
max = options[:max]
|
246
|
+
params = {}
|
247
|
+
params[:lang] = lang
|
248
|
+
params[:max] = max
|
249
|
+
port = Lyracyst::Rhymebrain.new
|
250
|
+
port.get_port(search, params)
|
91
251
|
end
|
92
252
|
end
|
253
|
+
|
254
|
+
pre do |global,command,options,args|
|
255
|
+
# Pre logic here
|
256
|
+
# Return true to proceed; false to abort and not call the
|
257
|
+
# chosen command
|
258
|
+
# Use skips_pre before a command to skip this block
|
259
|
+
# on that command only
|
260
|
+
wn = Lyracyst::Wordnik.new
|
261
|
+
http = global[:h]
|
262
|
+
json = global[:j]
|
263
|
+
xml = global[:x]
|
264
|
+
if http.class != Symbol then http = http.to_sym; end
|
265
|
+
wn.set_http(http)
|
266
|
+
if json.class != Symbol then json = json.to_sym; end
|
267
|
+
wn.set_json(json)
|
268
|
+
if xml.class != Symbol then xml = xml.to_sym; end
|
269
|
+
wn.set_xml(xml)
|
270
|
+
label = 'Global options'
|
271
|
+
wn.label(label)
|
272
|
+
print "- #{global} "
|
273
|
+
label = 'Command'
|
274
|
+
wn.label(label)
|
275
|
+
print "- #{command.name} "
|
276
|
+
label = 'Command options'
|
277
|
+
wn.label(label)
|
278
|
+
print "- #{options} "
|
279
|
+
label = 'Args'
|
280
|
+
wn.label(label)
|
281
|
+
print "- #{args} "
|
282
|
+
label = 'Bootstrapped'
|
283
|
+
wn.label(label)
|
284
|
+
puts ''
|
285
|
+
true
|
286
|
+
end
|
287
|
+
|
288
|
+
post do |global,command,options,args|
|
289
|
+
# Post logic here
|
290
|
+
# Use skips_post before a command to skip this
|
291
|
+
# block on that command only
|
292
|
+
wn = Lyracyst::Wordnik.new
|
293
|
+
label = 'Shutdown'
|
294
|
+
wn.label(label)
|
295
|
+
puts ''
|
296
|
+
end
|
297
|
+
|
298
|
+
on_error do |exception|
|
299
|
+
# Error logic here
|
300
|
+
# return false to skip default error handling
|
301
|
+
true
|
302
|
+
end
|
303
|
+
|
304
|
+
exit run(ARGV)
|
data/lib/lyracyst.rb
CHANGED
@@ -1,92 +1,304 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
|
+
require 'gli'
|
4
|
+
require 'lyracyst/rhymebrain'
|
5
|
+
require 'lyracyst/version'
|
6
|
+
require 'lyracyst/wordnik'
|
3
7
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
8
|
+
include GLI::App
|
9
|
+
program_desc 'A powerful word search tool that fetches definitions, related words, rhymes, and much more.'
|
10
|
+
config_file '.lyracyst.yml'
|
11
|
+
version Lyracyst::VERSION
|
12
|
+
|
13
|
+
desc 'HTTP adapter'
|
14
|
+
long_desc 'httpclient, curb, em_http, net_http_persistent, excon, rack'
|
15
|
+
default_value :excon
|
16
|
+
arg_name 'http'
|
17
|
+
flag [:h,:http]
|
18
|
+
|
19
|
+
desc 'JSON adapter'
|
20
|
+
long_desc 'oj, yajl, json_gem, json_pure'
|
21
|
+
default_value :json_pure
|
22
|
+
arg_name 'json'
|
23
|
+
flag [:j,:json]
|
24
|
+
|
25
|
+
desc 'XML adapter'
|
26
|
+
long_desc 'ox, libxml, nokogiri, rexml'
|
27
|
+
default_value :rexml
|
28
|
+
arg_name 'xml'
|
29
|
+
flag [:x,:xml]
|
30
|
+
|
31
|
+
desc 'Fetches definitions from Wordnik'
|
32
|
+
arg_name 'word'
|
33
|
+
command :define do |c|
|
34
|
+
c.desc 'Comma-separated list of parts of speech. See http://developer.wordnik.com/docs.html#!/word/getDefinitions_get_2 for list of parts.'
|
35
|
+
c.default_value nil
|
36
|
+
c.arg_name 'part'
|
37
|
+
c.flag [:p,:part]
|
38
|
+
c.desc "Source dictionary to return definitions from. If 'all' is received, results are returned from all sources. If multiple values are received (e.g. 'century,wiktionary'), results are returned from the first specified dictionary that has definitions. If left blank, results are returned from the first dictionary that has definitions. By default, dictionaries are searched in this order: ahd, wiktionary, webster, century, wordnet"
|
39
|
+
c.default_value 'all'
|
40
|
+
c.arg_name 'defdict'
|
41
|
+
c.flag [:defdict]
|
42
|
+
c.action do |global_options,options,args|
|
43
|
+
# If you have any errors, just raise them
|
44
|
+
# raise "that command made no sense"
|
45
|
+
search = args[0]
|
46
|
+
part = options[:p]
|
47
|
+
params = {limit: 10, increl: false, canon: false, inctags: false}
|
48
|
+
params[:defdict] = options[:defdict]
|
49
|
+
df = Lyracyst::Wordnik.new
|
50
|
+
df.get_def(search, part, params)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Fetches examples from Wordnik'
|
55
|
+
arg_name 'word'
|
56
|
+
command :example do |c|
|
57
|
+
c.desc 'Results to skip'
|
58
|
+
c.default_value 0
|
59
|
+
c.arg_name 'skip'
|
60
|
+
c.flag [:s,:skip]
|
61
|
+
c.desc 'Maximum number of results to return'
|
62
|
+
c.default_value 5
|
63
|
+
c.arg_name 'limit'
|
64
|
+
c.flag [:limit]
|
65
|
+
c.action do |global_options,options,args|
|
66
|
+
search = args[0]
|
67
|
+
skip = options[:s]
|
68
|
+
limit = options[:limit]
|
69
|
+
params = {incdups: false, canon: false}
|
70
|
+
params[:skip] = skip
|
71
|
+
params[:limit] = limit
|
72
|
+
ex = Lyracyst::Wordnik.new
|
73
|
+
ex.get_ex(search, params)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Fetches related words from Wordnik'
|
78
|
+
arg_name 'word'
|
79
|
+
command :relate do |c|
|
80
|
+
c.desc 'Limits the total results per type of relationship type'
|
81
|
+
c.default_value nil
|
82
|
+
c.arg_name 'reltypes'
|
83
|
+
c.flag [:relt]
|
84
|
+
c.desc 'Restrict to the supplied relationship types'
|
85
|
+
c.default_value 10
|
86
|
+
c.arg_name 'rell'
|
87
|
+
c.flag [:rell]
|
88
|
+
c.action do |global_options,options,args|
|
89
|
+
search = args[0]
|
90
|
+
reltypes = options[:relt]
|
91
|
+
rellimit = options[:rell]
|
92
|
+
params = {canon: false}
|
93
|
+
params[:rellimit] = rellimit
|
94
|
+
ex = Lyracyst::Wordnik.new
|
95
|
+
ex.get_rel(search, params, reltypes)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Fetches pronunciations from Wordnik'
|
100
|
+
arg_name 'word'
|
101
|
+
command :pronounce do |c|
|
102
|
+
c.desc 'Get from a single dictionary. Valid options: ahd, century, cmu, macmillan, wiktionary, webster, or wordnet'
|
103
|
+
c.default_value nil
|
104
|
+
c.arg_name 'source'
|
105
|
+
c.flag [:src]
|
106
|
+
c.desc 'Text pronunciation type'
|
107
|
+
c.long_desc 'ahd, arpabet, gcide-diacritical, IPA'
|
108
|
+
c.default_value nil
|
109
|
+
c.arg_name 'ptype'
|
110
|
+
c.flag [:pt]
|
111
|
+
c.desc 'Maximum number of results to return'
|
112
|
+
c.default_value 5
|
113
|
+
c.arg_name 'limit'
|
114
|
+
c.flag [:limit]
|
115
|
+
c.action do |global_options,options,args|
|
116
|
+
search = args[0]
|
117
|
+
source = options[:src]
|
118
|
+
ptype = options[:pt]
|
119
|
+
limit = options[:limit]
|
120
|
+
params = {canon: false}
|
121
|
+
params[:source] = source
|
122
|
+
params[:limit] = limit
|
123
|
+
pr = Lyracyst::Wordnik.new
|
124
|
+
pr.get_pro(search, params, ptype)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
desc 'Fetches hyphenation and syllable stresses from Wordnik. Primary stress is red, secondary stress is bright white.'
|
129
|
+
arg_name 'word'
|
130
|
+
command :hyphen do |c|
|
131
|
+
c.desc "Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet."
|
132
|
+
c.default_value nil
|
133
|
+
c.arg_name 'source'
|
134
|
+
c.flag [:src]
|
135
|
+
c.desc 'Maximum number of results to return'
|
136
|
+
c.default_value 5
|
137
|
+
c.arg_name 'limit'
|
138
|
+
c.flag [:limit]
|
139
|
+
c.action do |global_options,options,args|
|
140
|
+
search = args[0]
|
141
|
+
source = options[:src]
|
142
|
+
limit = options[:limit]
|
143
|
+
params = {canon: false}
|
144
|
+
if source != nil then params[:source] = source; end
|
145
|
+
params[:limit] = limit
|
146
|
+
hyph = Lyracyst::Wordnik.new
|
147
|
+
hyph.get_hyph(search, params)
|
42
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
desc 'Fetches bi-gram phrases from Wordnik'
|
152
|
+
arg_name 'word'
|
153
|
+
command :phrase do |c|
|
154
|
+
c.desc 'Maximum number of results to return'
|
155
|
+
c.default_value 10
|
156
|
+
c.arg_name 'limit'
|
157
|
+
c.flag [:limit]
|
158
|
+
c.desc 'Minimum WLMI(weighted mutual info) for the phrase.'
|
159
|
+
c.default_value 13
|
160
|
+
c.arg_name 'wlmi'
|
161
|
+
c.flag [:wlmi]
|
162
|
+
c.action do |global_options,options,args|
|
163
|
+
search = args[0]
|
164
|
+
limit = options[:limit]
|
165
|
+
wlmi = options[:wlmi]
|
166
|
+
params = {canon: false}
|
167
|
+
params[:limit] = limit
|
168
|
+
params[:wlmi] = wlmi
|
169
|
+
phra = Lyracyst::Wordnik.new
|
170
|
+
phra.get_phr(search, params)
|
171
|
+
end
|
172
|
+
end
|
43
173
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
fmt = options.fmt
|
53
|
-
search = args[0]
|
54
|
-
de = Lyracyst::Define.new
|
55
|
-
puts "Getting definitions for [#{search}]"
|
56
|
-
de.define(search, fmt)
|
57
|
-
end
|
174
|
+
desc 'Fetches etymologies from Wordnik'
|
175
|
+
arg_name 'word'
|
176
|
+
command :origin do |c|
|
177
|
+
c.action do |global_options,options,args|
|
178
|
+
search = args[0]
|
179
|
+
params = {canon: false}
|
180
|
+
orig = Lyracyst::Wordnik.new
|
181
|
+
orig.get_et(search, params)
|
58
182
|
end
|
183
|
+
end
|
184
|
+
|
185
|
+
desc 'Fetches rhymes from Rhymebrain'
|
186
|
+
arg_name 'word'
|
187
|
+
command :rhyme do |c|
|
188
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
189
|
+
c.default_value 'en'
|
190
|
+
c.arg_name 'lang'
|
191
|
+
c.flag [:lang]
|
192
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
193
|
+
c.default_value nil
|
194
|
+
c.arg_name 'max'
|
195
|
+
c.flag [:max]
|
196
|
+
c.action do |global_options,options,args|
|
197
|
+
search = args[0]
|
198
|
+
lang = options[:lang]
|
199
|
+
max = options[:max]
|
200
|
+
params = {}
|
201
|
+
params[:lang] = lang
|
202
|
+
params[:max] = max
|
203
|
+
rhym = Lyracyst::Rhymebrain.new
|
204
|
+
rhym.get_rhyme(search, params)
|
205
|
+
end
|
206
|
+
end
|
59
207
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
208
|
+
desc 'Fetches word info from Rhymebrain'
|
209
|
+
arg_name 'word'
|
210
|
+
command :info do |c|
|
211
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
212
|
+
c.default_value 'en'
|
213
|
+
c.arg_name 'lang'
|
214
|
+
c.flag [:lang]
|
215
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
216
|
+
c.default_value nil
|
217
|
+
c.arg_name 'max'
|
218
|
+
c.flag [:max]
|
219
|
+
c.action do |global_options,options,args|
|
220
|
+
search = args[0]
|
221
|
+
lang = options[:lang]
|
222
|
+
max = options[:max]
|
223
|
+
params = {}
|
224
|
+
params[:lang] = lang
|
225
|
+
params[:max] = max
|
226
|
+
info = Lyracyst::Rhymebrain.new
|
227
|
+
info.get_info(search, params)
|
77
228
|
end
|
229
|
+
end
|
78
230
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
231
|
+
desc 'Fetches combined words (portmanteaus) from Rhymebrain'
|
232
|
+
arg_name 'word'
|
233
|
+
command :combine do |c|
|
234
|
+
c.desc 'ISO639-1 language code (optional). Eg. en, de, es, fr, ru'
|
235
|
+
c.default_value 'en'
|
236
|
+
c.arg_name 'lang'
|
237
|
+
c.flag [:lang]
|
238
|
+
c.desc '(optional) The number of results to return. If you do not include this parameter, RhymeBrain will choose how many words to show based on how many good sounding rhymes there are for the word.'
|
239
|
+
c.default_value nil
|
240
|
+
c.arg_name 'max'
|
241
|
+
c.flag [:max]
|
242
|
+
c.action do |global_options,options,args|
|
243
|
+
search = args[0]
|
244
|
+
lang = options[:lang]
|
245
|
+
max = options[:max]
|
246
|
+
params = {}
|
247
|
+
params[:lang] = lang
|
248
|
+
params[:max] = max
|
249
|
+
port = Lyracyst::Rhymebrain.new
|
250
|
+
port.get_port(search, params)
|
91
251
|
end
|
92
252
|
end
|
253
|
+
|
254
|
+
pre do |global,command,options,args|
|
255
|
+
# Pre logic here
|
256
|
+
# Return true to proceed; false to abort and not call the
|
257
|
+
# chosen command
|
258
|
+
# Use skips_pre before a command to skip this block
|
259
|
+
# on that command only
|
260
|
+
wn = Lyracyst::Wordnik.new
|
261
|
+
http = global[:h]
|
262
|
+
json = global[:j]
|
263
|
+
xml = global[:x]
|
264
|
+
if http.class != Symbol then http = http.to_sym; end
|
265
|
+
wn.set_http(http)
|
266
|
+
if json.class != Symbol then json = json.to_sym; end
|
267
|
+
wn.set_json(json)
|
268
|
+
if xml.class != Symbol then xml = xml.to_sym; end
|
269
|
+
wn.set_xml(xml)
|
270
|
+
label = 'Global options'
|
271
|
+
wn.label(label)
|
272
|
+
print "- #{global} "
|
273
|
+
label = 'Command'
|
274
|
+
wn.label(label)
|
275
|
+
print "- #{command.name} "
|
276
|
+
label = 'Command options'
|
277
|
+
wn.label(label)
|
278
|
+
print "- #{options} "
|
279
|
+
label = 'Args'
|
280
|
+
wn.label(label)
|
281
|
+
print "- #{args} "
|
282
|
+
label = 'Bootstrapped'
|
283
|
+
wn.label(label)
|
284
|
+
puts ''
|
285
|
+
true
|
286
|
+
end
|
287
|
+
|
288
|
+
post do |global,command,options,args|
|
289
|
+
# Post logic here
|
290
|
+
# Use skips_post before a command to skip this
|
291
|
+
# block on that command only
|
292
|
+
wn = Lyracyst::Wordnik.new
|
293
|
+
label = 'Shutdown'
|
294
|
+
wn.label(label)
|
295
|
+
puts ''
|
296
|
+
end
|
297
|
+
|
298
|
+
on_error do |exception|
|
299
|
+
# Error logic here
|
300
|
+
# return false to skip default error handling
|
301
|
+
true
|
302
|
+
end
|
303
|
+
|
304
|
+
exit run(ARGV)
|