monkeylearn 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91e4d2970c81beb36426093d55aa94e98a984ddf
4
- data.tar.gz: 8c86ffea933c61b48cfed3f9f5deb9086960c468
3
+ metadata.gz: 2ff330b7689bdc6da28cc2bf6107c5c27bbfe935
4
+ data.tar.gz: 2fce10b6d2503a8298c104a379e8a18a3dbc66dd
5
5
  SHA512:
6
- metadata.gz: 34aa6e3d010ddb33aff0c93fa3f8c802ff8e3a4027db3e8c9d0968c36eabf94c6e17bc5132af5f2ba18b8b42a03407c8fe12862e0c195120e0679f5dca88f4b0
7
- data.tar.gz: 95adddec01b5baba9c2e11bcf6649fc1b22625a4fa29a137aff8127530bc1b862e5323ece229eb9ffccce6f2cbc7280889287e87418477e807eca439fb8f7da5
6
+ metadata.gz: cb4645c0ea5f9b4b9941cd17e748602bbea322885b337150f4a69276db11119cd171d90279c47fdfaea21e117eb7c78f68cc67df412420a4b82f26d8be2cc6cc
7
+ data.tar.gz: 0a261f78ff5283281317face0d28a905c5d5bdd7f74f51bcb828ebf253c091c41eec3a4bebcd212bea422d2083c3c6cf0aa931ac65e96d479ea5afce33672d69
data/README.md CHANGED
@@ -179,9 +179,7 @@ responses = (0...data.length).step(batch_size).collect do |start_idx|
179
179
  rescue ConcurrencyRateLimitError
180
180
  sleep 2
181
181
  rescue PlanRateLimitError => e
182
- match = /([\d]+) seconds/.match(e.detail)
183
- seconds = if match then match[1].to_i else 60 end
184
- sleep seconds
182
+ sleep e.seconds_to_wait
185
183
  end
186
184
  end
187
185
  response
@@ -373,6 +371,27 @@ response = Monkeylearn.classifiers.list(page: 1, per_page: 5)
373
371
 
374
372
  <br>
375
373
 
374
+ #### [Train](https://monkeylearn.com/api/v3/?shell#train)
375
+
376
+
377
+ ```ruby
378
+ Monkeylearn.classifiers.train(model_id)
379
+ ```
380
+
381
+ Parameters:
382
+
383
+ | Parameter |Type | Description |
384
+ |--------------------|-------------------|-----------------------------------------------------------|
385
+ |*model_id* |`String` |Classifier ID. It always starts with `'cl'`, for example, `'cl_oJNMkt2V'`. |
386
+
387
+ Example:
388
+
389
+ ```ruby
390
+ Monkeylearn.classifiers.train('[MODEL_ID]')
391
+ ```
392
+
393
+ <br>
394
+
376
395
  #### [Deploy](https://monkeylearn.com/api/v3/?shell#deploy)
377
396
 
378
397
 
@@ -101,6 +101,10 @@ module Monkeylearn
101
101
  request(:post, build_endpoint(module_id, 'deploy'))
102
102
  end
103
103
 
104
+ def train(module_id)
105
+ request(:post, build_endpoint(module_id, 'train'))
106
+ end
107
+
104
108
  def upload_data(module_id, data)
105
109
  endpoint = build_endpoint(module_id, 'data')
106
110
 
@@ -9,13 +9,11 @@ class MonkeylearnResponseError < MonkeylearnError
9
9
  def initialize(raw_response)
10
10
  @response = raw_response
11
11
 
12
-
13
12
  body = JSON.parse(raw_response.body)
14
13
  @detail = body['detail']
15
14
  @error_code = body['error_code']
16
15
  @status_code = raw_response.status
17
16
 
18
-
19
17
  super "#{@error_code}: #{@detail}"
20
18
  end
21
19
  end
@@ -64,6 +62,14 @@ end
64
62
 
65
63
 
66
64
  class PlanRateLimitError < RateLimitError
65
+ attr_accessor :seconds_to_wait
66
+
67
+ def initialize(raw_response)
68
+ body = JSON.parse(raw_response.body)
69
+ @seconds_to_wait = body['seconds_to_wait'].to_i
70
+
71
+ super raw_response
72
+ end
67
73
  end
68
74
 
69
75
 
@@ -35,7 +35,7 @@ module Monkeylearn
35
35
 
36
36
  def responses=(responses)
37
37
  @responses = responses
38
- @query_limit_remaining = responses[-1].raw_response.headers['X-Query-Limit-Remaining'].to_i
38
+ @query_limit_remaining = @responses[-1].raw_response.headers['X-Query-Limit-Remaining'].to_i
39
39
  @plan_queries_allowed = @responses[-1].plan_queries_allowed
40
40
  @plan_queries_remaining = @responses[-1].plan_queries_remaining
41
41
  @request_queries_used = @responses.inject(0){|sum, r| sum + r.request_queries_used }
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['hello@monkeylearn.com']
11
11
  spec.homepage = 'https://github.com/monkeylearn/monkeylearn-ruby'
12
12
 
13
- spec.version = '3.0.1'
13
+ spec.version = '3.1.0'
14
14
 
15
15
  spec.add_dependency 'faraday', '>= 0.9.2', '<= 0.15.0'
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkeylearn
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Monkeylearn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-01 00:00:00.000000000 Z
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday