scaleapi 0.3.0 → 0.5.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 +4 -4
- data/README.md +0 -51
- data/lib/scale.rb +10 -0
- data/lib/scale/api/task_list.rb +5 -1
- data/lib/scale/api/tasks/categorization.rb +4 -3
- data/lib/scale/api/tasks/image_recognition.rb +4 -2
- data/lib/scale/api/tasks/lineannotation.rb +5 -2
- data/lib/scale/api/tasks/phone_call.rb +3 -15
- data/lib/scale/api/tasks/pointannotation.rb +30 -0
- data/lib/scale/api/tasks/polygonannotation.rb +4 -2
- data/lib/scale/api/tasks/segmentannotation.rb +27 -0
- data/lib/scale/api/tasks/transcription.rb +7 -4
- data/scaleapi-ruby.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21cd5e56a610ea9d0e324922d6b350a5e70496a
|
4
|
+
data.tar.gz: 3ffb5f6a80df8d13ce5251db9668f6d6d652c2bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f14677d50a682ee2bf7e95c076d9f0a698a797e711621b3249b6a7446be0832deb0d6fa993482d829a9e791ce13bfe03a63e0a1e8e0d0307a313d1cc98da9833
|
7
|
+
data.tar.gz: 3b47e584e202f6895a2417d6ac6f490fb20403a6c0c9e5c255a17c9f287301a21f584e6f215546df4692baeb7c46711038bb2dff9ec10a606992982f8585aff1
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@ This is the official Scale API RubyGem (`scaleapi`).
|
|
5
5
|
|
6
6
|
[Scale](https://www.scaleapi.com) is an API for Human Intelligence. Businesses like Alphabet (Google), Uber, Proctor & Gamble, Houzz, and many more use us to power tasks such as:
|
7
7
|
- Draw bounding boxes and label parts of images (to train ML algorithms for self-driving cars)
|
8
|
-
- Place phone calls
|
9
8
|
- Transcribe documents, images, and webpages
|
10
9
|
- Scrape websites
|
11
10
|
- Triage support tickets
|
@@ -239,55 +238,6 @@ This will also return a `Scale::Api::Tasks::ImageRecognition` object.
|
|
239
238
|
|
240
239
|
[Read more about creating image recognition tasks](https://docs.scaleapi.com/#create-image-recognition-task)
|
241
240
|
|
242
|
-
### Phone Call Tasks
|
243
|
-
|
244
|
-
You can use this to have real people call other people! Isn't that cool?
|
245
|
-
|
246
|
-
To create a [phone call task](https://docs.scaleapi.com/#create-phone-call-task), run the following:
|
247
|
-
```ruby
|
248
|
-
require 'scale'
|
249
|
-
scale = Scale.new(api_key: 'SCALE_API_KEY')
|
250
|
-
|
251
|
-
scale.create_phone_call_task({
|
252
|
-
callback_url: 'http://www.example.com/callback',
|
253
|
-
instruction: 'Call this person and follow the script provided, recording responses',
|
254
|
-
phone_number: '5055006865',
|
255
|
-
entity_name: 'Alexandr Wang',
|
256
|
-
script: 'Hello ! Are you happy today? (pause) One more thing - what is your email address?',
|
257
|
-
fields: {
|
258
|
-
email: 'Email Address',
|
259
|
-
},
|
260
|
-
choices: ['He is happy', 'He is not happy']
|
261
|
-
})
|
262
|
-
```
|
263
|
-
Upon success, this will return a `Scale::Api::Tasks::PhoneCall` object. If it fails, it will raise one of the [errors](#user-content-errors).
|
264
|
-
|
265
|
-
Note: `create_phone_call_task` is also aliased to `create_phonecall_task`, to help avoid confusion.
|
266
|
-
|
267
|
-
Alternatively, you can also create a task this way
|
268
|
-
```ruby
|
269
|
-
require 'scale'
|
270
|
-
scale = Scale.new(api_key: 'SCALE_API_KEY')
|
271
|
-
|
272
|
-
scale.tasks.create({
|
273
|
-
type: 'phonecall',
|
274
|
-
callback_url: 'http://www.example.com/callback',
|
275
|
-
instruction: 'Call this person and follow the script provided, recording responses',
|
276
|
-
phone_number: '5055006865',
|
277
|
-
entity_name: 'Alexandr Wang',
|
278
|
-
script: 'Hello ! Are you happy today? (pause) One more thing - what is your email address?',
|
279
|
-
fields: {
|
280
|
-
email: 'Email Address',
|
281
|
-
},
|
282
|
-
choices: ['He is happy', 'He is not happy']
|
283
|
-
})
|
284
|
-
```
|
285
|
-
|
286
|
-
This will also return a `Scale::Api::Tasks::PhoneCall` object.
|
287
|
-
|
288
|
-
[Read more about creating phone call tasks](https://docs.scaleapi.com/#create-phone-call-task)
|
289
|
-
|
290
|
-
|
291
241
|
### Transcription Tasks
|
292
242
|
|
293
243
|
To create a [transcription task](https://docs.scaleapi.com/#create-transcription-task), run the following:
|
@@ -482,7 +432,6 @@ All tasks return a task object for their `type`. Currently, this gem supports th
|
|
482
432
|
- `comparison` (`Scale::Api::Tasks::Comparison`)
|
483
433
|
- `datacollection` (`Scale::Api::Tasks::Datacollection`)
|
484
434
|
- `annotation` (`Scale::Api::Tasks::ImageRecognition`)
|
485
|
-
- `phonecall` (`Scale::Api::Tasks::PhoneCall`)
|
486
435
|
- `transcription` (`Scale::Api::Tasks::Transcription`)
|
487
436
|
- `audiotranscription` (`Scale::Api::Tasks::AudioTranscription`)
|
488
437
|
|
data/lib/scale.rb
CHANGED
@@ -68,6 +68,14 @@ class Scale
|
|
68
68
|
Api::Tasks::AudioTranscription.create(args.merge(client: client))
|
69
69
|
end
|
70
70
|
|
71
|
+
def create_pointannotation_task(args = {})
|
72
|
+
Api::Tasks::Pointannotation.create(args.merge(client: client))
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_segmentannotation_task(args = {})
|
76
|
+
Api::Tasks::Segmentannotation.create(args.merge(client: client))
|
77
|
+
end
|
78
|
+
|
71
79
|
def build_callback(params, callback_key: nil)
|
72
80
|
callback = Api::Callback.new(params, callback_key: callback_key, client: client)
|
73
81
|
|
@@ -101,4 +109,6 @@ require 'scale/api/tasks/polygonannotation'
|
|
101
109
|
require 'scale/api/tasks/lineannotation'
|
102
110
|
require 'scale/api/tasks/phone_call'
|
103
111
|
require 'scale/api/tasks/transcription'
|
112
|
+
require 'scale/api/tasks/pointannotation'
|
113
|
+
require 'scale/api/tasks/segmentannotaiton'
|
104
114
|
require 'scale/api/task_list'
|
data/lib/scale/api/task_list.rb
CHANGED
@@ -8,6 +8,8 @@ require 'scale/api/tasks/polygonannotation'
|
|
8
8
|
require 'scale/api/tasks/lineannotation'
|
9
9
|
require 'scale/api/tasks/phone_call'
|
10
10
|
require 'scale/api/tasks/transcription'
|
11
|
+
require 'scale/api/tasks/segmentannotation'
|
12
|
+
require 'scale/api/tasks/pointannotation'
|
11
13
|
|
12
14
|
class Scale
|
13
15
|
class Api
|
@@ -25,7 +27,9 @@ class Scale
|
|
25
27
|
'polygonannotation' => ::Scale::Api::Tasks::Polygonannotation,
|
26
28
|
'lineannotation' => ::Scale::Api::Tasks::Lineannotation,
|
27
29
|
'phonecall' => ::Scale::Api::Tasks::PhoneCall,
|
28
|
-
'transcription' => ::Scale::Api::Tasks::Transcription
|
30
|
+
'transcription' => ::Scale::Api::Tasks::Transcription,
|
31
|
+
'pointannotation' => ::Scale::Api::Tasks::Pointannotation,
|
32
|
+
'segmentannotation' => ::Scale::Api::Tasks::Segmentannotation
|
29
33
|
}.freeze
|
30
34
|
|
31
35
|
def initialize(client: nil, docs: [], limit: 99, offset: 0, has_more: false, params: {})
|
@@ -7,7 +7,7 @@ class Scale
|
|
7
7
|
class Categorization < BaseTask
|
8
8
|
CREATE_PATH = 'task/categorize'.freeze
|
9
9
|
|
10
|
-
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, categories: [], urgency: 'day', category_ids: {}, allow_multiple: false, metadata: {}, client: nil)
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, categories: [], layers: nil, urgency: 'day', category_ids: {}, allow_multiple: false, metadata: {}, client: nil)
|
11
11
|
body = {
|
12
12
|
callback_url: callback_url,
|
13
13
|
instruction: instruction,
|
@@ -17,7 +17,8 @@ class Scale
|
|
17
17
|
urgency: urgency,
|
18
18
|
category_ids: category_ids,
|
19
19
|
allow_multiple: allow_multiple,
|
20
|
-
metadata: metadata
|
20
|
+
metadata: metadata,
|
21
|
+
layers: layers
|
21
22
|
}
|
22
23
|
|
23
24
|
body.delete(:category_ids) if category_ids.keys.count.zero?
|
@@ -29,4 +30,4 @@ class Scale
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
end
|
33
|
+
end
|
@@ -7,7 +7,7 @@ class Scale
|
|
7
7
|
class ImageRecognition < Scale::Api::Tasks::BaseTask
|
8
8
|
CREATE_PATH = 'task/annotation'.freeze
|
9
9
|
|
10
|
-
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, min_width: nil, min_height: nil, examples: [], urgency: 'day', metadata: {}, client: nil)
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, min_width: nil, min_height: nil, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
|
11
11
|
response = client.post(CREATE_PATH, {
|
12
12
|
callback_url: callback_url,
|
13
13
|
instruction: instruction,
|
@@ -19,7 +19,9 @@ class Scale
|
|
19
19
|
min_height: min_height,
|
20
20
|
examples: examples,
|
21
21
|
urgency: urgency,
|
22
|
-
metadata: metadata
|
22
|
+
metadata: metadata,
|
23
|
+
layers: layers,
|
24
|
+
annotation_attributes: annotation_attributes
|
23
25
|
})
|
24
26
|
|
25
27
|
ImageRecognition.new(JSON.parse(response.body))
|
@@ -7,7 +7,7 @@ class Scale
|
|
7
7
|
class Lineannotation < Scale::Api::Tasks::BaseTask
|
8
8
|
CREATE_PATH = 'task/lineannotation'.freeze
|
9
9
|
|
10
|
-
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, examples: [], urgency: 'day', metadata: {}, client: nil)
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', splines: false, annotation_attributes: nil, metadata: {}, client: nil)
|
11
11
|
response = client.post(CREATE_PATH, {
|
12
12
|
callback_url: callback_url,
|
13
13
|
instruction: instruction,
|
@@ -17,7 +17,10 @@ class Scale
|
|
17
17
|
with_labels: with_labels,
|
18
18
|
examples: examples,
|
19
19
|
urgency: urgency,
|
20
|
-
metadata: metadata
|
20
|
+
metadata: metadata,
|
21
|
+
layers: layers,
|
22
|
+
splines: splines,
|
23
|
+
annotation_attributes: annotation_attributes
|
21
24
|
})
|
22
25
|
|
23
26
|
Lineannotation.new(JSON.parse(response.body))
|
@@ -8,21 +8,9 @@ class Scale
|
|
8
8
|
CREATE_PATH = 'task/phonecall'.freeze
|
9
9
|
|
10
10
|
def self.create(callback_url: nil, instruction: nil, phone_number: nil, script: nil, entity_name: nil, attachment: nil, attachment_type: nil, fields: {}, choices: {}, urgency: 'day', metadata: {}, client: nil)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
attachment_type: attachment_type,
|
15
|
-
attachment: attachment,
|
16
|
-
phone_number: phone_number,
|
17
|
-
script: script,
|
18
|
-
entity_name: entity_name,
|
19
|
-
fields: fields,
|
20
|
-
choices: choices,
|
21
|
-
urgency: urgency,
|
22
|
-
metadata: metadata
|
23
|
-
})
|
24
|
-
|
25
|
-
PhoneCall.new(JSON.parse(response.body))
|
11
|
+
message = 'Phone call tasks have been deprecated and are no longer available.'
|
12
|
+
pp message
|
13
|
+
raise ScaleApi::Api::BadRequest.new(message)
|
26
14
|
end
|
27
15
|
end
|
28
16
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'scale/api/tasks/base_task'
|
3
|
+
|
4
|
+
class Scale
|
5
|
+
class Api
|
6
|
+
class Tasks
|
7
|
+
class Pointannotation < Scale::Api::Tasks::BaseTask
|
8
|
+
CREATE_PATH = 'task/polygonannotation'.freeze
|
9
|
+
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
|
11
|
+
response = client.post(CREATE_PATH, {
|
12
|
+
callback_url: callback_url,
|
13
|
+
instruction: instruction,
|
14
|
+
attachment_type: attachment_type,
|
15
|
+
attachment: attachment,
|
16
|
+
objects_to_annotate: objects_to_annotate,
|
17
|
+
with_labels: with_labels,
|
18
|
+
examples: examples,
|
19
|
+
urgency: urgency,
|
20
|
+
metadata: metadata,
|
21
|
+
layers: layers,
|
22
|
+
annotation_attributes: annotation_attributes
|
23
|
+
})
|
24
|
+
|
25
|
+
Pointannotation.new(JSON.parse(response.body))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -7,7 +7,7 @@ class Scale
|
|
7
7
|
class Polygonannotation < Scale::Api::Tasks::BaseTask
|
8
8
|
CREATE_PATH = 'task/polygonannotation'.freeze
|
9
9
|
|
10
|
-
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, examples: [], urgency: 'day', metadata: {}, client: nil)
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
|
11
11
|
response = client.post(CREATE_PATH, {
|
12
12
|
callback_url: callback_url,
|
13
13
|
instruction: instruction,
|
@@ -17,7 +17,9 @@ class Scale
|
|
17
17
|
with_labels: with_labels,
|
18
18
|
examples: examples,
|
19
19
|
urgency: urgency,
|
20
|
-
metadata: metadata
|
20
|
+
metadata: metadata,
|
21
|
+
layers: layers,
|
22
|
+
annotation_attributes: annotation_attributes
|
21
23
|
})
|
22
24
|
|
23
25
|
Polygonannotation.new(JSON.parse(response.body))
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'scale/api/tasks/base_task'
|
3
|
+
|
4
|
+
class Scale
|
5
|
+
class Api
|
6
|
+
class Tasks
|
7
|
+
class Segmentannotation < Scale::Api::Tasks::BaseTask
|
8
|
+
CREATE_PATH = 'task/segmentannotation'.freeze
|
9
|
+
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: null, labels: [], allow_unlabeled: false, layers: nil, examples: [], urgency: 'day', metadata: {}, client: nil)
|
11
|
+
response = client.post(CREATE_PATH, {
|
12
|
+
callback_url: callback_url,
|
13
|
+
instruction: instruction,
|
14
|
+
attachment_type: attachment_type,
|
15
|
+
attachment: attachment,
|
16
|
+
labels: labels,
|
17
|
+
allow_unlabeled: allow_unlabeled,
|
18
|
+
urgency: urgency,
|
19
|
+
metadata: metadata
|
20
|
+
})
|
21
|
+
|
22
|
+
Segmentannotation.new(JSON.parse(response.body))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,8 +7,8 @@ class Scale
|
|
7
7
|
class Transcription < BaseTask
|
8
8
|
CREATE_PATH = 'task/transcription'.freeze
|
9
9
|
|
10
|
-
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, choices: {}, attachment: null, fields: {}, urgency: 'day', metadata: {}, client: nil)
|
11
|
-
|
10
|
+
def self.create(callback_url: nil, instruction: nil, attachment_type: nil, choices: {}, attachment: null, fields: {}, urgency: 'day', metadata: {}, client: nil, repeatable_fields: nil)
|
11
|
+
args = {
|
12
12
|
callback_url: callback_url,
|
13
13
|
instruction: instruction,
|
14
14
|
attachment_type: attachment_type,
|
@@ -17,8 +17,11 @@ class Scale
|
|
17
17
|
choices: choices,
|
18
18
|
urgency: urgency,
|
19
19
|
metadata: metadata
|
20
|
-
}
|
21
|
-
|
20
|
+
}
|
21
|
+
if repeatable_fields != nil
|
22
|
+
args['repeatable_fields'] = repeatable_fields
|
23
|
+
end
|
24
|
+
response = client.post(CREATE_PATH, args)
|
22
25
|
Transcription.new(JSON.parse(response.body))
|
23
26
|
end
|
24
27
|
end
|
data/scaleapi-ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaleapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandr Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,9 @@ files:
|
|
81
81
|
- lib/scale/api/tasks/image_recognition.rb
|
82
82
|
- lib/scale/api/tasks/lineannotation.rb
|
83
83
|
- lib/scale/api/tasks/phone_call.rb
|
84
|
+
- lib/scale/api/tasks/pointannotation.rb
|
84
85
|
- lib/scale/api/tasks/polygonannotation.rb
|
86
|
+
- lib/scale/api/tasks/segmentannotation.rb
|
85
87
|
- lib/scale/api/tasks/transcription.rb
|
86
88
|
- scaleapi-ruby.gemspec
|
87
89
|
homepage: https://www.scaleapi.com
|