If you have Java as your MTurk implementation language, there is Java library exclusively for you. The key part is to implement MyHit
interface, where you customize your own operations on HITs such as creating a HIT, retrieving answers from a HIT and dumping an used HIT. By passing an instance of class implementing MyHit
, building an instance of the algorithm and starting it, everything will be done by the library.
If you program your MTurk task in other programming languages, you can pass your questions in a request string to an algorithm server through socket. The string for communication between the algorithm server and your client is in a CGI style. You don't have to implement MyHit interface if you choose this way. Instead, the only thing is to intract with the algorithm server. The steps are as follows:
java -jar TopOneServer tree 50000 50001 127.0.0.1 mturk.properties
tree
is the type of the algorithm the server will be running. Another available value of this parameter can be bubble
.50000
is the port of the server. The server will keep listening at this port to accept initilization requests from client side.50001
is the port of the client. The client will keep listening at this port to accept requests of creating HITs, fetching answers or returning final answers from server. When a request comes up, the client will open up a new thread to process this request. After creating a new HIT/fetching the answers of a HIT/receiving the final answers, this thread will be closed.127.0.0.1
is the IP address of the client program.mturk.properties
is the name of your Amazon Mechanical Turk property file, which stores your access_key, secret_key and service_url. You are supposed to provide this file since the algorithm needs to keep track on the active HITs you created. Once a HIT is done, the algorithm will send your client program a request for answers.qnum=19&q0=1&q1=2&q2=3&q3=4&q4=5&q5=6&q6=7&q7=8&q8=9&q9=10&q10=11&
q11=12&q12=13&q13=14&q14=15&q15=16&q16=17&q17=18&q18=19&nInput=3&
nOutput=2&nAssignment=2&nTieAssignment=1\n
qnum
is the number of all the questions you have, q0
is the first question and q18
is the last question here.nInput
is the number of inputs/questions a HIT has.nOutput
is the number of outputs/answers a HIT should return.nAssignment
is the number of assignments of a normal HIT.nTieAssignment
is the number of assignments of a tie-solving HIT (because there may be a tie among different answers who win same amount of votes).isShuffled
is true if the server shuffles the inputs. If it is omitted, it is true by default.isLogged
is true if the server records a log. If it is omitted, it is true by default.jobId
is the name of the instance of algorithm (namly, the current specific task) given by you. It is also the name of the log file. If it is omitted, it is a random number generated by the hash code of the date.type=createHit&nOutput=2&nAssignment=3&jobId=1831723&qnum=3&
q0=3&q1=13&q2=7\n
8W7E5D9AWE67WQ\n
type=getAnswer&hitId=JASDH7SD9S9&jobId=1831723\n
anum=2&a0=3&a1=6\n
, where anum
is the number of answers, and a0
is the first answer and so on. type=returnFinalAnswer&finalAnswer=6\n
finalAnswer
field.