Module: CorpusMethods

Defined in:
lib/wordnik/resource_modules/corpus.rb

Overview

HEY HACKER! THIS IS AN AUTO-GENERATED FILE. So don’t bother editing it. To see how it’s built, take a look at the Rakefile

Instance Method Summary collapse

Instance Method Details

#get_corpus_word_frequencies(*args) ⇒ Object

Gets corpus-level WordFrequency



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/wordnik/resource_modules/corpus.rb', line 167

def get_corpus_word_frequencies(*args)
  http_method = :get
  path = '/corpus/words'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_document_stats(*args) ⇒ Object

Returns document-level stats.



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/wordnik/resource_modules/corpus.rb', line 193

def get_document_stats(*args)
  http_method = :get
  path = '/corpus/documentStats'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_punctuation_factor(body, *args) ⇒ Object

Receives info on phrases which should be captured



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/wordnik/resource_modules/corpus.rb', line 245

def get_punctuation_factor(body, *args)
  http_method = :post
  path = '/corpus/phraseFeedback'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_recent_listed_words(*args) ⇒ Object

Returns recently listed words.



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/wordnik/resource_modules/corpus.rb', line 219

def get_recent_listed_words(*args)
  http_method = :get
  path = '/corpus/recentListedWords'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_recent_views(*args) ⇒ Object

Fetches recent views from the website



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wordnik/resource_modules/corpus.rb', line 8

def get_recent_views(*args)
  http_method = :get
  path = '/corpus/recentViews'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_total_document_count(*args) ⇒ Object

Returns the count of documents in the Corpus.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/wordnik/resource_modules/corpus.rb', line 114

def get_total_document_count(*args)
  http_method = :get
  path = '/corpus/totalDocumentCount'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_total_sentences_count(*args) ⇒ Object

Returns the count of sentences in the Corpus.



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/wordnik/resource_modules/corpus.rb', line 297

def get_total_sentences_count(*args)
  http_method = :get
  path = '/corpus/sentenceCount'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_total_tokens_count(*args) ⇒ Object

Returns the count of tokens in the Corpus.



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/wordnik/resource_modules/corpus.rb', line 271

def get_total_tokens_count(*args)
  http_method = :get
  path = '/corpus/totalWordCount'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#get_word_frequencies(*args) ⇒ Object

Gets Dictionary Statistics data



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wordnik/resource_modules/corpus.rb', line 34

def get_word_frequencies(statsType, object, *args)
  http_method = :get
  path = '/corpus/words/{statsType}/{object}'
  path.sub!('{statsType}', statsType.to_s)
  path.sub!('{object}', object.to_s)

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end

#process_text(body, *args) ⇒ Object

Processes text input. Returns tagged and processed text based on the input string.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/wordnik/resource_modules/corpus.rb', line 141

def process_text(body, *args)
  http_method = :post
  path = '/corpus/processText'

  # Ruby turns all key-value arguments at the end into a single hash
  # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
  # becomes {:limit => 10, :part_of_speech => 'verb'}
  last_arg = args.pop if args.last.is_a?(Hash)
  last_arg = args.pop if args.last.is_a?(Array)
  last_arg ||= {}

  # Look for a kwarg called :request_only, whose presence indicates
  # that we want the request itself back, not the response body
  if last_arg.is_a?(Hash) && last_arg[:request_only].present?
    request_only = true
    last_arg.delete(:request_only)
  end

  params = last_arg
  body ||= {}
  request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
  request_only ? request : request.response.body
end