README.markdown in rturk-1.0.5 vs README.markdown in rturk-2.0.0
- old
+ new
@@ -9,55 +9,75 @@
If you want to build forms that are hosted on Mechanical Turk, this is not the library you need.
You'd be better off with amazon's official library, in all its XML cruftiness.
## Installation
- sudo gem install markpercival-rturk --source http://gems.github.com
+ sudo gem install rturk --source http://gemcutter.org
## Use
Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers can add some tags to items in your catalogue.
### Creating HIT's
require 'rturk'
- props = {:Title=>"Add tags to an item",
- :MaxAssignments=>1, :LifetimeInSeconds=>3600,
- :Reward=>{:Amount=>0.05, :CurrencyCode=>"USD"},
- :Keywords=>"twitter, blogging, writing, english",
- :Description=>"Simply add some tags for me",
- :RequesterAnnotation=>"Example1",
- :AssignmentDurationInSeconds=>3600, :AutoApprovalDelayInSeconds=>3600,
- :QualificationRequirement=>[{
- # Approval rate of greater than 90%
- :QualificationTypeId=>"000000000000000000L0",
- :IntegerValue=>90,
- :Comparator=>"GreaterThan",
- :RequiredToPreview=>"false"
- }]
- }
-
- @turk = RTurk::Requester.new(AWSAccessKeyId, AWSAccessKey, :sandbox => true)
- page = RTurk::ExternalQuestionBuilder.build(
- "http://myapp.com/turkers/add_tags", :item_id => '1234')
+ RTurk.setup(YourAWSAccessKeyId, YourAWSAccessKey, :sandbox => true)
+ hit = RTurk::Hit.create(:title => "Add some tags to a photo") do |hit|
+ hit.assignments = 2
+ hit.question("http://myapp.com/turkers/add_tags")
+ hit.reward = 0.05
+ hit.qualifications.approval_rate, {:gt => 80}
+ end
- # Turkers will be directed to http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=abcd12345
-
- p @turk.create_hit(props, page)
+ p hit.url #=> 'https://workersandbox.mturk.com:443/mturk/preview?groupId=Q29J3XZQ1ASZH5YNKZDZ'
-### Reviewing HIT's
+### Reviewing and Approving hits HIT's
- require 'rturk'
- @turk = RTurk::Requester.new(AWSAccessKeyId, AWSAccessKey, :sandbox => true)
+ hits = RTurk::Hit.all_reviewable
- p @turk.getAssignmentsForHIT(:HITId => 'abcde1234567890')
+ puts "#{hits.size} reviewable hits. \n"
+
+ unless hits.empty?
+ puts "Reviewing all assignments"
+
+ hits.each do |hit|
+ hit.assignments.each do |assignment|
+ puts assignment.answers['tags']
+ assignment.approve! if assignment.status == 'Submitted'
+ end
+ end
+ end
+
+### Wiping all your hits out
+
+ hits = RTurk::Hit.all_reviewable
+
+ puts "#{hits.size} reviewable hits. \n"
+
+ unless hits.empty?
+ puts "Approving all assignments and disposing of each hit!"
+
+ hits.each do |hit|
+ hit.expire!
+ hit.assignments.each do |assignment|
+ assignment.approve!
+ end
+ hit.dispose!
+ end
+ end
+
+### Logging
+Want to see what's going on - enable logging.
+
+RTurk::Logger.level = Logger::DEBUG
+
## Nitty Gritty
Here's a quick peak at what happens on the Mechanical Turk side.
-A worker takes a look at your hit. The page will contain an iframe with your external URL loaded inside of it.
+A worker takes a look at your hit. The page will contain an iframe with your question URL loaded inside of it.
Amazon will append the AssignmentID parameter to the URL for your own information. In preview mode this will look like
http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=ASSIGNMENT_ID_NOT_AVAILABLE
If the Turker accepts the HIT, the page will reload and the iframe URL will resemble
\ No newline at end of file