cloudfactory 0.3.1 → 0.4.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.
- data/CHANGELOG.md +5 -0
- data/lib/cf/account.rb +3 -6
- data/lib/cf/cli.rb +8 -12
- data/lib/cf/cli/line.rb +13 -13
- data/lib/cf/cli/production.rb +18 -14
- data/lib/cf/client.rb +2 -12
- data/lib/cf/custom_task_form.rb +1 -3
- data/lib/cf/input_format.rb +1 -3
- data/lib/cf/line.rb +63 -66
- data/lib/cf/robot_worker.rb +3 -5
- data/lib/cf/run.rb +21 -58
- data/lib/cf/station.rb +6 -10
- data/lib/cf/task_form.rb +1 -3
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +3 -5
- data/spec/badge_spec.rb +64 -64
- data/spec/concept_tagging_robot_spec.rb +37 -37
- data/spec/config_spec.rb +0 -1
- data/spec/content_scraping_robot_spec.rb +38 -38
- data/spec/custom_task_form_spec.rb +106 -105
- data/spec/department_spec.rb +5 -6
- data/spec/entity_extraction_robot_spec.rb +39 -39
- data/spec/form_field_spec.rb +148 -148
- data/spec/google_translate_robot_spec.rb +40 -40
- data/spec/human_worker_spec.rb +87 -87
- data/spec/image_processing_robot_spec.rb +37 -37
- data/spec/input_format_spec.rb +97 -97
- data/spec/keyword_matching_and_text_extraction_robot_spec.rb +56 -56
- data/spec/line_spec.rb +442 -416
- data/spec/mailer_robot_spec.rb +39 -39
- data/spec/media_converter_robot_spec.rb +40 -46
- data/spec/media_splitting_robot_spec.rb +41 -41
- data/spec/robot_worker_spec.rb +8 -8
- data/spec/run_spec.rb +424 -432
- data/spec/sentiment_robot_spec.rb +37 -37
- data/spec/station_spec.rb +209 -207
- data/spec/task_form_spec.rb +79 -79
- data/spec/term_extraction_robot_spec.rb +37 -37
- metadata +48 -48
data/spec/config_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe CF do
|
4
4
|
context "configuration" do
|
5
5
|
it "be able to configure the api key" do
|
6
|
-
API_CONFIG = YAML.load_file(File.expand_path("../../fixtures/api_credentials.yml", __FILE__))
|
7
6
|
CF.configure do |config|
|
8
7
|
config.account_name = API_CONFIG['account_name']
|
9
8
|
config.api_version = API_CONFIG['api_version']
|
@@ -5,53 +5,53 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create a content scraping robot worker" do
|
7
7
|
it "should create content_scraping_robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
10
|
+
sleep 1
|
11
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
12
|
+
CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
|
13
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
14
|
+
CF::RobotWorker.create({:station => s, :type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
|
15
15
|
end
|
16
|
-
run = CF::Run.create(line, "content_scraping_robot_run", [{"url"=> "http://www.sprout-technology.com"}])
|
17
|
-
# sleep 30
|
18
|
-
output = run.final_output
|
19
|
-
output.first['scraped_link_from_document'].should eql([""])
|
20
|
-
output.first['scraped_text_from_document'].should eql([""])
|
21
|
-
|
22
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
23
|
-
line.stations.first.worker.reward.should eql(0.5)
|
24
|
-
line.stations.first.worker.number.should eql(1)
|
25
|
-
line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
|
26
|
-
line.stations.first.worker.type.should eql("ContentScrapingRobot")
|
27
16
|
end
|
17
|
+
run = CF::Run.create(line, "content_scraping_robot_run", [{"url"=> "http://www.sprout-technology.com"}])
|
18
|
+
sleep 10
|
19
|
+
output = run.final_output
|
20
|
+
output.first['scraped_link_from_document'].should eql([""])
|
21
|
+
output.first['scraped_text_from_document'].should eql([""])
|
22
|
+
|
23
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
24
|
+
line.stations.first.worker.reward.should eql(0.5)
|
25
|
+
line.stations.first.worker.number.should eql(1)
|
26
|
+
line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
|
27
|
+
line.stations.first.worker.type.should eql("ContentScrapingRobot")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create content_scraping_robot worker for first station in a plain ruby way" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
WebMock.allow_net_connect!
|
32
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
33
|
+
sleep 1
|
34
|
+
line = CF::Line.new(title,"Digitization")
|
35
|
+
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
|
36
|
+
line.input_formats input_format
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
station = CF::Station.new({:type => "work"})
|
39
|
+
line.stations station
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
worker = CF::RobotWorker.create({:type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
|
42
|
+
line.stations.first.worker = worker
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
run = CF::Run.create(line, "content_scraping_robot_run_1", [{"url"=> "http://www.sprout-technology.com"}])
|
45
|
+
sleep 10
|
46
|
+
output = run.final_output
|
47
|
+
output.first['scraped_link_from_document'].should eql([""])
|
48
|
+
output.first['scraped_text_from_document'].should eql([""])
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
50
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
51
|
+
line.stations.first.worker.reward.should eql(0.5)
|
52
|
+
line.stations.first.worker.number.should eql(1)
|
53
|
+
line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
|
54
|
+
line.stations.first.worker.type.should eql("ContentScrapingRobot")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe CF::CustomTaskForm do
|
4
4
|
context "create a Custom Task Form" do
|
5
5
|
it "in block DSL way" do
|
6
|
-
|
7
|
-
VCR.use_cassette "custom-task-form/block/create", :record => :new_episodes do
|
6
|
+
WebMock.allow_net_connect!
|
8
7
|
html = '<div id="form-content">
|
9
8
|
<div id="instructions">
|
10
9
|
<ul>
|
@@ -32,7 +31,7 @@ describe CF::CustomTaskForm do
|
|
32
31
|
</div>
|
33
32
|
</div>'
|
34
33
|
|
35
|
-
|
34
|
+
css = '<style>body {background:#fbfbfb;}
|
36
35
|
#instructions{
|
37
36
|
text-align:center;
|
38
37
|
}
|
@@ -55,7 +54,7 @@ describe CF::CustomTaskForm do
|
|
55
54
|
margin:4px;
|
56
55
|
}</style>'
|
57
56
|
|
58
|
-
|
57
|
+
javascript = '<script src="http://code.jquery.com/jquery-latest.js"></script>
|
59
58
|
<script type="text/javascript" src="http://www.bizcardarmy.com/javascripts/jquery.autocomplete-min.js"></script>
|
60
59
|
<script type="text/javascript">
|
61
60
|
$(document).ready(function(){
|
@@ -74,26 +73,26 @@ describe CF::CustomTaskForm do
|
|
74
73
|
});
|
75
74
|
</script>'
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
77
|
+
sleep 1
|
78
|
+
line = CF::Line.create(title, "Digitization") do
|
79
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
80
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
81
|
+
CF::Station.create({:line => self, :type => "work"}) do |s|
|
82
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
83
|
+
CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
|
85
84
|
end
|
86
|
-
line.title.should eql("Digitizecustomform11")
|
87
|
-
line.department_name.should eql("Digitization")
|
88
|
-
line.stations.first.type.should eql("WorkStation")
|
89
|
-
CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
|
90
|
-
CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
|
91
|
-
CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
|
92
85
|
end
|
86
|
+
line.title.should eql(title)
|
87
|
+
line.department_name.should eql("Digitization")
|
88
|
+
line.stations.first.type.should eql("WorkStation")
|
89
|
+
CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
|
90
|
+
CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
|
91
|
+
CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
|
93
92
|
end
|
94
93
|
|
95
94
|
it "in plain ruby way" do
|
96
|
-
|
95
|
+
WebMock.allow_net_connect!
|
97
96
|
html = '<form><div id="form-content">
|
98
97
|
<div id="instructions">
|
99
98
|
<ul>
|
@@ -121,7 +120,7 @@ describe CF::CustomTaskForm do
|
|
121
120
|
</div>
|
122
121
|
</div></form>'
|
123
122
|
|
124
|
-
|
123
|
+
css = '<style>body {background:#fbfbfb;}
|
125
124
|
#instructions{
|
126
125
|
text-align:center;
|
127
126
|
}
|
@@ -162,36 +161,35 @@ describe CF::CustomTaskForm do
|
|
162
161
|
});
|
163
162
|
});
|
164
163
|
</script>'
|
164
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
165
|
+
sleep 1
|
166
|
+
line = CF::Line.new(title, "Digitization")
|
167
|
+
|
168
|
+
input_format_1 = CF::InputFormat.new({:name => "Name", :required => true, :valid_format => "general"})
|
169
|
+
input_format_2 = CF::InputFormat.new({:name => "Contact", :required => true, :valid_type => "url"})
|
170
|
+
line.input_formats input_format_1
|
171
|
+
line.input_formats input_format_2
|
165
172
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
line.input_formats input_format_2
|
172
|
-
|
173
|
-
station = CF::Station.new({:type => "work"})
|
174
|
-
line.stations station
|
175
|
-
|
176
|
-
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
177
|
-
line.stations.first.worker = worker
|
173
|
+
station = CF::Station.new({:type => "work"})
|
174
|
+
line.stations station
|
175
|
+
|
176
|
+
worker = CF::HumanWorker.new({:number => 1, :reward => 20})
|
177
|
+
line.stations.first.worker = worker
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
179
|
+
form = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
|
180
|
+
line.stations.first.form = form
|
181
|
+
line.title.should eql(title)
|
182
|
+
line.department_name.should eql("Digitization")
|
183
|
+
line.stations.first.type.should eql("WorkStation")
|
184
|
+
CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
|
185
|
+
CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
|
186
|
+
CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
|
188
187
|
end
|
189
188
|
end
|
190
189
|
|
191
190
|
context "create a Custom Task Form for Error Handling;" do
|
192
|
-
|
193
|
-
|
194
|
-
VCR.use_cassette "custom-task-form/block/invalid-html-content", :record => :new_episodes do
|
191
|
+
it "creating with invalid Html content" do
|
192
|
+
WebMock.allow_net_connect!
|
195
193
|
html = '<div id="form-content">
|
196
194
|
<div id="instructions">
|
197
195
|
<ul>
|
@@ -218,23 +216,23 @@ describe CF::CustomTaskForm do
|
|
218
216
|
</div>
|
219
217
|
</div>
|
220
218
|
</div>'
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
219
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
220
|
+
sleep 1
|
221
|
+
line = CF::Line.create(title, "Digitization") do
|
222
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
223
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
224
|
+
CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
|
225
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
226
|
+
CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
|
228
227
|
end
|
229
|
-
line.title.should eql("Digitizecustomform111")
|
230
|
-
line.department_name.should eql("Digitization")
|
231
|
-
line.stations.first.form.errors.should eql(["Raw html should contain a Form tag", "Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[email]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]"])
|
232
228
|
end
|
229
|
+
line.title.should eql(title)
|
230
|
+
line.department_name.should eql("Digitization")
|
231
|
+
line.stations.first.form.errors.should eql(["Raw html should contain a Form tag", "Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[email]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]"])
|
233
232
|
end
|
234
233
|
|
235
234
|
it "creating without title" do
|
236
|
-
|
237
|
-
VCR.use_cassette "custom-task-form/block/without-title", :record => :new_episodes do
|
235
|
+
WebMock.allow_net_connect!
|
238
236
|
html = '<div id="form-content">
|
239
237
|
<div id="instructions">
|
240
238
|
<ul>
|
@@ -261,23 +259,24 @@ describe CF::CustomTaskForm do
|
|
261
259
|
</div>
|
262
260
|
</div>
|
263
261
|
</div>'
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
262
|
+
|
263
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
264
|
+
sleep 1
|
265
|
+
line = CF::Line.create(title, "Digitization") do
|
266
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
267
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
268
|
+
CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
|
269
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
270
|
+
CF::CustomTaskForm.create({:station => s, :instruction => "Describe", :raw_html => html})
|
271
271
|
end
|
272
|
-
line.title.should eql("Digitizecustomform112")
|
273
|
-
line.department_name.should eql("Digitization")
|
274
|
-
line.stations.first.form.errors.should eql(["Title can't be blank", "Raw html should contain a Form tag"])
|
275
272
|
end
|
273
|
+
line.title.should eql(title)
|
274
|
+
line.department_name.should eql("Digitization")
|
275
|
+
line.stations.first.form.errors.should eql(["Title can't be blank", "Raw html should contain a Form tag"])
|
276
276
|
end
|
277
277
|
|
278
278
|
it "creating without instruction" do
|
279
|
-
|
280
|
-
VCR.use_cassette "custom-task-form/block/without-instruction", :record => :new_episodes do
|
279
|
+
WebMock.allow_net_connect!
|
281
280
|
html = '<div id="form-content">
|
282
281
|
<div id="instructions">
|
283
282
|
<ul>
|
@@ -304,55 +303,57 @@ describe CF::CustomTaskForm do
|
|
304
303
|
</div>
|
305
304
|
</div>
|
306
305
|
</div>'
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
306
|
+
|
307
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
308
|
+
sleep 1
|
309
|
+
line = CF::Line.create(title, "Digitization") do
|
310
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
311
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
312
|
+
CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
|
313
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
314
|
+
CF::CustomTaskForm.create({:station => s, :title => "title", :raw_html => html})
|
314
315
|
end
|
315
|
-
line.title.should eql("Digitizecustomform113")
|
316
|
-
line.department_name.should eql("Digitization")
|
317
|
-
line.stations.first.form.errors.should eql(["Instruction can't be blank", "Raw html should contain a Form tag"])
|
318
316
|
end
|
317
|
+
line.title.should eql(title)
|
318
|
+
line.department_name.should eql("Digitization")
|
319
|
+
line.stations.first.form.errors.should eql(["Instruction can't be blank", "Raw html should contain a Form tag"])
|
319
320
|
end
|
320
321
|
|
321
322
|
it "creating without any html data" do
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
323
|
+
WebMock.allow_net_connect!
|
324
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
325
|
+
sleep 1
|
326
|
+
line = CF::Line.create(title, "Digitization") do
|
327
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
328
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
329
|
+
CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
|
330
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
331
|
+
CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"})
|
331
332
|
end
|
332
|
-
line.title.should eql("Digitizecustomform114")
|
333
|
-
line.department_name.should eql("Digitization")
|
334
|
-
line.stations.first.form.errors.should eql(["Raw html is required"])
|
335
333
|
end
|
334
|
+
line.title.should eql(title)
|
335
|
+
line.department_name.should eql("Digitization")
|
336
|
+
line.stations.first.form.errors.should eql(["Raw html is required"])
|
336
337
|
end
|
337
338
|
|
338
339
|
it "creating without any html data in plain ruby way" do
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
340
|
+
WebMock.allow_net_connect!
|
341
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
342
|
+
sleep 1
|
343
|
+
line = CF::Line.create(title, "Digitization") do
|
344
|
+
CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
|
345
|
+
CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
|
346
|
+
CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
|
347
|
+
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
|
347
348
|
end
|
348
|
-
|
349
|
-
form = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe"})
|
350
|
-
line.stations.first.form = form
|
351
|
-
|
352
|
-
line.title.should eql("Digitizecustomform115")
|
353
|
-
line.department_name.should eql("Digitization")
|
354
|
-
line.stations.first.form.errors.should eql(["Raw html is required"])
|
355
349
|
end
|
350
|
+
|
351
|
+
form = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe"})
|
352
|
+
line.stations.first.form = form
|
353
|
+
|
354
|
+
line.title.should eql(title)
|
355
|
+
line.department_name.should eql("Digitization")
|
356
|
+
line.stations.first.form.errors.should eql(["Raw html is required"])
|
356
357
|
end
|
357
358
|
end
|
358
359
|
end
|
data/spec/department_spec.rb
CHANGED
@@ -3,12 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe CF::Department do
|
4
4
|
context "return category" do
|
5
5
|
it "should get all the departments" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
6
|
+
departments = CF::Department.all
|
7
|
+
departments_name = departments.map {|d| d['name']}.join(",")
|
8
|
+
departments_name.should include("Digitization")
|
9
|
+
departments_name.should include("Data Processing")
|
10
|
+
departments_name.should include("Survey")
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
@@ -5,53 +5,53 @@ module CF
|
|
5
5
|
describe CF::RobotWorker do
|
6
6
|
context "create an entity extraction robot worker" do
|
7
7
|
it "should create entity extraction robot worker for first station in Block DSL way" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
10
|
+
sleep 1
|
11
|
+
line = CF::Line.create(title,"Digitization") do |l|
|
12
|
+
CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
|
13
|
+
CF::Station.create({:line => l, :type => "work"}) do |s|
|
14
|
+
CF::RobotWorker.create({:station => s, :type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
|
15
15
|
end
|
16
|
-
run = CF::Run.create(line, "entity_extraction_robot_run", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
|
17
|
-
# sleep 20
|
18
|
-
output = run.final_output
|
19
|
-
output.first['entity_counts_of_document'].should eql(["2", "2", "1", "1", "2", "1"])
|
20
|
-
output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"])
|
21
|
-
output.first['entity_relevances_of_document'].should eql([92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997])
|
22
|
-
output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Person", "Country", "Country"])
|
23
|
-
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
24
|
-
line.stations.first.worker.reward.should eql(0.5)
|
25
|
-
line.stations.first.worker.number.should eql(1)
|
26
|
-
line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
|
27
16
|
end
|
17
|
+
run = CF::Run.create(line, "run-#{title}", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
|
18
|
+
sleep 10
|
19
|
+
output = run.final_output
|
20
|
+
output.first['entity_counts_of_document'].should eql(["2", "2", "1", "2", "1", "1"])
|
21
|
+
output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "countries", "Mozart", "Japan"])
|
22
|
+
output.first['entity_relevances_of_document'].should eql([94.98649999999999, 76.0806, 48.079100000000004, 30.461899999999996, 28.9416, 21.1997])
|
23
|
+
output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Country", "Person", "Country"])
|
24
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
25
|
+
line.stations.first.worker.reward.should eql(0.5)
|
26
|
+
line.stations.first.worker.number.should eql(1)
|
27
|
+
line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create entity extraction robot worker for first station in a plain ruby way" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
WebMock.allow_net_connect!
|
32
|
+
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
33
|
+
sleep 1
|
34
|
+
line = CF::Line.new(title,"Digitization")
|
35
|
+
input_format = CF::InputFormat.new({:name => "text", :required => "true"})
|
36
|
+
line.input_formats input_format
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
station = CF::Station.new({:type => "work"})
|
39
|
+
line.stations station
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
worker = CF::RobotWorker.create({:type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
|
42
|
+
line.stations.first.worker = worker
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
44
|
+
run = CF::Run.create(line, "run-#{title}", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
|
45
|
+
sleep 10
|
46
|
+
output = run.final_output
|
47
|
+
output.first['entity_counts_of_document'].should eql(["2", "2", "1", "2", "1", "1"])
|
48
|
+
output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "countries", "Mozart", "Japan"])
|
49
|
+
output.first['entity_relevances_of_document'].should eql([94.98649999999999, 76.0806, 48.079100000000004, 30.461899999999996, 28.9416, 21.1997])
|
50
|
+
output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Country", "Person", "Country"])
|
51
|
+
line.stations.first.worker.class.should eql(CF::RobotWorker)
|
52
|
+
line.stations.first.worker.reward.should eql(0.5)
|
53
|
+
line.stations.first.worker.number.should eql(1)
|
54
|
+
line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|