import
statement into the top of your source file:mturk
) jobs using its MTurk domain-specific language (DSL).import
statement.object
in Scala is just a special kind of class that does not need to be instantiated. It is also sometimes referred to as a singleton class, since you can only have one of them.extends App
tells Scala to augment the MyFirstAutoManApp
with a public
and static
main
method that takes a String[]
. Any code you write inside the class will be interpreted as being a main
method implementation. Arguments are available via a variable called args
. If you come from Java, this is a lightweight version of the public static void main(String[] args)
which you have probably used many times.sbt
, it will likely download large numbers of libraries, printing huge amounts of diagnostic information along the way. Do not be alarmed. Subsequent runs should produce substantially less output.Hello world!
. If you see Hello world!
in your output, move on to the next step. If not, read the sbt
output carefully to diagnose and fix the problem.MyFirstAutoManApp
class.a
that stores an instance of mturk
. AutoMan needs what we call a platform adapter in order to know which service to connect to. In this case, we are connecting to Mechanical Turk.args
is an argument array, and args(0)
is the first element of that array (if you come from Java, note that arrays in Scala use ()
instead of []
). These are the same credentials you downloaded in an earlier step of this tutorial.access_key_id
or your secret_access_key
in your source code! Doing so makes it easy to accidentally push your code to a public site like GitHub where they can be stolen and abused.sandbox_mode
is set true
in the mturk
adapter, you will run in sandbox mode.sandbox_mode
to false
. It will run real jobs and it will spend real money!which_one
that takes no arguments. It is important to note that which_one
is just an ordinary function in Scala, although it does behave in some special ways that we will describe in the next section.radio
constructor. "Radio button questions" allow MTurk users to select one of n options.budget
: This parameter specifies the maximum amount of money AutoMan will spend on this task. AutoMan always tries to spend less. If the cost of a task exceeds the budget you supply, AutoMan will shut down the task and return a "low-confidence answer."text
: This parameter supplies the text of the question. You describe what you want workers to do here.options
: This parameter supplies the valid options. Since this is a radio button question, each option will produce a radio button.
The choice
constructor takes three parameters:label
of type Symbol
. You can think of a Symbol
as a special string designed for easy comparison. This parameter is not visible to MTurk workers.name
, which is visible to MTurk workers.confidence
(not shown): This parameter stands for the statistical confidence level and is a floating-point number between 0
and 1
(exclusive). A number approaching zero tells AutoMan that virtually any answer is fine. A number approaching one tells AutoMan that you want to be very certain that it is correct. Although the confidence
parameter is not shown above, it is set to the default of 0.95
, which is something of a standard threshold across empirical science.which_one()
inside our AutoMan block.mturk
initializer, this program will post jobs to the MTurk sandbox. When you run this program in the sandbox, no work will get done, because only the live production site has active workers. You must simulate the job yourself. We describe the process of simulating a job in the section titled Pro Tip: Use the MTurk Sandbox.apps
directory of our GitHub repository. An efficient, error-handling program that defines essentially the same task can be found here.