turkee 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -8
- data/Rakefile +0 -1
- data/lib/tasks/turkee.rb +6 -4
- data/lib/turkee.rb +2 -5
- metadata +8 -24
data/README.rdoc
CHANGED
@@ -4,6 +4,10 @@ Seamlessly convert your Rails forms for use on Mechanical Turk. Then, easily im
|
|
4
4
|
|
5
5
|
External forms are created using a simple form helper. HITs are created by issuing a rake command. Retrieving submitted response data and importing that data into your model(s) requires just one more rake command.
|
6
6
|
|
7
|
+
== Examples
|
8
|
+
|
9
|
+
If you'd like to jump straight into code, check out the {Turkee Iterator}[https://github.com/aantix/Turkee-Iterator] example.
|
10
|
+
|
7
11
|
== Dependencies
|
8
12
|
|
9
13
|
Make sure that the rturk gem is installed configured with your Amazon Turk credentials. I created a config/initializers/turk_task_config.rb file with the following in it:
|
@@ -20,17 +24,21 @@ Install the Turkee gem:
|
|
20
24
|
|
21
25
|
sudo gem install turkee
|
22
26
|
|
23
|
-
|
27
|
+
For Rails 2, add it to your environment.rb configuration as a gem dependency:
|
24
28
|
|
25
29
|
config.gem 'turkee'
|
26
30
|
|
31
|
+
For Rails 3, add it to your Gemfile as a gem dependency, then do a 'bundle install':
|
32
|
+
|
33
|
+
gem 'turkee'
|
34
|
+
|
27
35
|
To access the Turkee rake tasks, add the following to your application's Rakefile:
|
28
36
|
require 'tasks/turkee'
|
29
37
|
|
30
38
|
Run the turkee generator from your application directory to copy the needed migrations into your application:
|
31
39
|
|
32
40
|
./script/generate turkee # Rails 2
|
33
|
-
|
41
|
+
rails g turkee # Rails 3
|
34
42
|
|
35
43
|
== Use
|
36
44
|
|
@@ -62,6 +70,7 @@ Run the turkee generator from your application directory to copy the needed migr
|
|
62
70
|
Using the turkee_form_for helper will post the form to the Mechanical Turk sandbox if you're in development/test mode, otherwise it will be posted to Mechanical Turk production/live site.
|
63
71
|
|
64
72
|
4) Run the following rake task to post to Mechanical Turk :
|
73
|
+
# Host URL of your application
|
65
74
|
# Title of your HIT
|
66
75
|
# Description of your HIT
|
67
76
|
# Model name of your task form (the New action should be implemented)
|
@@ -69,24 +78,29 @@ Using the turkee_form_for helper will post the form to the Mechanical Turk sandb
|
|
69
78
|
# The reward for a successful completion
|
70
79
|
# The lifetime of the HIT in days (e.g. 5 days)
|
71
80
|
|
72
|
-
rake turkee:
|
81
|
+
rake turkee:post_hit[<Host>, <Title>, <Description>, <Model>, <Number of Assignments>, <Reward>, <Lifetime>]
|
73
82
|
|
74
83
|
e.g. :
|
75
|
-
rake turkee:
|
84
|
+
rake turkee:post_hit["https://www.yourapp.com","Please complete our survey","Tell us your favorite color.","Survey",100,0.05,2]
|
85
|
+
** Do not put spaces before or after commas for the rake task parameters
|
86
|
+
|
87
|
+
This will insert a row for the requested HIT into the turkee_tasks table. The turkee_tasks entry stores (along with the other properties) the HIT URL (e.g. http://workersandbox.mturk.com/mturk/preview?groupId=1HGHJJGHQSJB7WMWJ33YS8WM169XNIL ) and HIT ID (e.g. 1J1EXO8SUQ3URTTUYGHJ7EKUT11 ). These values are returned from Mechanical Turk when the HIT request is posted.
|
88
|
+
|
89
|
+
When a Turk worker views your HIT, the HIT will display your form within an iFrame. With the above example, Mechanical Turk will open an iFrame for the HIT assignment displaying the form http://www.yourapp.com/surveys/new
|
76
90
|
|
77
|
-
|
91
|
+
** The application that hosts your external forms preferably should have an https interface (you're going to have to buy an SSL certificate). If the forms are hosted on an unsecured host (http), because Mechanical Turk defaults to https, you're going to receive the ugly popup from IE regarding "mixed content" (http://msdn.microsoft.com/en-us/library/ee264315%28v=vs.85%29.aspx).
|
78
92
|
|
79
93
|
5) Allow some time for the Mechanical Turk workers ("Turkers") to respond to your HIT.
|
80
94
|
|
81
95
|
6) Run the rake task that retrieves the values from Mechanical Turk and stores the user entered values into your model.
|
82
|
-
rake turkee::
|
96
|
+
rake turkee::get_all_results
|
83
97
|
|
84
98
|
Rerun this task periodically to retrieve newly entered form values. You can setup this task as a cronjob to automate this.
|
85
99
|
|
86
100
|
crontab -e
|
87
101
|
|
88
102
|
# E.g. run every five minutes
|
89
|
-
*/5 * * * * cd /var/www/your/turk/application && rake turkee:
|
103
|
+
*/5 * * * * cd /var/www/your/turk/application && rake turkee:get_all_results
|
90
104
|
|
91
105
|
Or you can directly call :
|
92
106
|
|
@@ -102,4 +116,4 @@ As for Mechanical Turk approval, if the row is created and you haven't specified
|
|
102
116
|
|
103
117
|
== Copyright
|
104
118
|
|
105
|
-
Copyright (c) 2010 Jim Jones. See LICENSE for details.
|
119
|
+
Copyright (c) 2010 - 2011 Jim Jones. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -23,7 +23,6 @@ begin
|
|
23
23
|
gem.email = "jjones@aantix.com"
|
24
24
|
gem.homepage = "http://github.com/aantix/turkee"
|
25
25
|
gem.authors = ["Jim Jones"]
|
26
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
27
26
|
gem.add_development_dependency "rturk", ">= 2.3.0"
|
28
27
|
gem.add_development_dependency "lockfile", ">= 1.4.3"
|
29
28
|
gem.post_install_message = INSTALL_MESSAGE
|
data/lib/tasks/turkee.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rake'
|
1
2
|
require 'turkee'
|
2
3
|
|
3
4
|
include ActionController::PolymorphicRoutes
|
@@ -6,10 +7,11 @@ include ActionView::Helpers::UrlHelper
|
|
6
7
|
# clear && rake turkee:post_hit['Test title','Test desc','Joke',3,0.05,1] --trace
|
7
8
|
|
8
9
|
namespace :turkee do
|
9
|
-
desc "Post your form to Mechanical Turk (HIT). Task takes HIT title, HIT description, model name, number of responses, reward for each response, and number of days the HIT should be valid."
|
10
|
-
task :post_hit, :title, :description, :model, :num_assignments, :reward, :lifetime, :needs => :environment do |t, args|
|
11
|
-
Turkee::TurkeeTask.create_hit(args[:title], args[:description], args[:model],
|
12
|
-
|
10
|
+
desc "Post your form to Mechanical Turk (HIT). Task takes the application's host URL, HIT title, HIT description, model name, number of responses, reward for each response, and number of days the HIT should be valid."
|
11
|
+
task :post_hit, :host, :title, :description, :model, :num_assignments, :reward, :lifetime, :needs => :environment do |t, args|
|
12
|
+
hit = Turkee::TurkeeTask.create_hit(args[:host],args[:title], args[:description], args[:model],
|
13
|
+
args[:num_assignments], args[:reward], args[:lifetime])
|
14
|
+
puts "Hit created ( #{hit.hit_url} )."
|
13
15
|
end
|
14
16
|
|
15
17
|
desc "Retrieve all results from Mechanical Turk for all open HITs."
|
data/lib/turkee.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'socket'
|
3
|
+
require 'rturk'
|
3
4
|
require 'lockfile'
|
4
5
|
require 'active_record'
|
5
6
|
require 'action_view'
|
@@ -40,10 +41,6 @@ module Turkee
|
|
40
41
|
param_hash = Rack::Utils.parse_nested_query(params)
|
41
42
|
model = find_model(param_hash)
|
42
43
|
|
43
|
-
logger.debug "params = #{params.inspect}"
|
44
|
-
logger.debug "param_hash = #{param_hash.inspect}"
|
45
|
-
logger.debug "model = #{model.inspect}"
|
46
|
-
|
47
44
|
next if model.nil?
|
48
45
|
|
49
46
|
result = model.create(param_hash[model.to_s.underscore])
|
@@ -196,7 +193,7 @@ module Turkee
|
|
196
193
|
end
|
197
194
|
|
198
195
|
# concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
|
199
|
-
concat(form_tag(mturk_url))
|
196
|
+
concat(form_tag(mturk_url, options.delete(:html) || {}))
|
200
197
|
concat("<input type=\"hidden\" id=\"assignmentId\" name=\"assignmentId\" value=\"#{assignment_id}\"/>")
|
201
198
|
fields_for(object_name, *(args << options), &proc)
|
202
199
|
concat('</form>'.html_safe)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turkee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Jones
|
@@ -15,29 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-27 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: rspec
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 9
|
34
|
-
version: 1.2.9
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
21
|
- !ruby/object:Gem::Dependency
|
38
22
|
name: rturk
|
39
23
|
prerelease: false
|
40
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
42
26
|
requirements:
|
43
27
|
- - ">="
|
@@ -49,11 +33,11 @@ dependencies:
|
|
49
33
|
- 0
|
50
34
|
version: 2.3.0
|
51
35
|
type: :development
|
52
|
-
version_requirements: *
|
36
|
+
version_requirements: *id001
|
53
37
|
- !ruby/object:Gem::Dependency
|
54
38
|
name: lockfile
|
55
39
|
prerelease: false
|
56
|
-
requirement: &
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
42
|
requirements:
|
59
43
|
- - ">="
|
@@ -65,7 +49,7 @@ dependencies:
|
|
65
49
|
- 3
|
66
50
|
version: 1.4.3
|
67
51
|
type: :development
|
68
|
-
version_requirements: *
|
52
|
+
version_requirements: *id002
|
69
53
|
description: Turkee will help you to create your Rails forms, post the HITs, and retrieve the user entered values from Mechanical Turk.
|
70
54
|
email: jjones@aantix.com
|
71
55
|
executables: []
|