turkleton.assignment package

Submodules

turkleton.assignment.answer module

turkleton.assignment.answer

Representations for various answer types from uploaded HITs.

class turkleton.assignment.answer.BaseAnswer(question_name, default)[source]

Bases: object

Base class for all answer types. This is a descriptor class.

class turkleton.assignment.answer.BooleanAnswer(question_name, default, string_to_bool=None)[source]

Bases: turkleton.assignment.answer.BaseAnswer

An answer representing a boolean choice

DEFAULT_STRING_TO_BOOL = {'1': True, '0': False}

Default mapping of strings to booleans

class turkleton.assignment.answer.DecimalAnswer(question_name, default)[source]

Bases: turkleton.assignment.answer.BaseAnswer

Represents an answer with a decimal value

class turkleton.assignment.answer.IntegerAnswer(question_name, default)[source]

Bases: turkleton.assignment.answer.BaseAnswer

Represents an answer with an integer value

class turkleton.assignment.answer.MultiChoiceAnswer(question_name, default=<object object>)[source]

Bases: turkleton.assignment.answer.BaseAnswer

An answer with multiple potential choices for input

class turkleton.assignment.answer.SingleChoiceAnswer(question_name, default)[source]

Bases: turkleton.assignment.answer.TextAnswer

Represents an answer to a single-choice question

class turkleton.assignment.answer.TextAnswer(question_name, default)[source]

Bases: turkleton.assignment.answer.BaseAnswer

An answer representing simple textual input

turkleton.assignment.assignment module

turkleton.assignment.assignment

Representations for the results from uploaded HITs.

class turkleton.assignment.assignment.BaseAssignment(assignment)[source]

Bases: object

Base class for all assignments

approve(message)[source]

Approve this assignment with the given message.

Parameters:message (str or unicode) – A message to send to the turker
assignment_id

Return the ID associated with this assignment.

Return type:str or unicode
classmethod get_by_hit_id(hit_id)[source]

Retrieve assignments over the given connection for the given HIT.

Parameters:hit_id (str or unicode) – A HIT id
Return type:list of BaseAssignment
hit_id

Return the ID associated with this HIT.

Return type:str or unicode
reject(message)[source]

Reject this assignment with the given message.

Parameters:message (str or unicode) – A message to send to the turker
worker_id

Return the ID of the worker who completed this assignment.

Return type:str or unicode
turkleton.assignment.assignment.get_answer_to_question(assignment, question_name)[source]

Get the answer to the given question from an assignment.

Parameters:
  • assignment (boto.mturk.Assignment) – An assignment
  • question_name (str or unicode) – The name of the question
Return type:

str or unicode

turkleton.assignment.assignment.get_question_name_to_answer_attribute_table(cls)[source]

Get a question name to answer attribute translation table for the given class. This is used to determine which attributes to set when a given question is encountered in an assignment

Parameters:cls (class) – A class
Return type:dict

turkleton.assignment.task module

turkleton.assignment.task

Representations for the human intelligence task (HIT) portion of an assignment.

class turkleton.assignment.task.BaseTask(**assignment_params)[source]

Bases: object

Base class for all human intelligence tasks

exception ValidationError[source]

Bases: turkleton.errors.Error

Represents an error while validating task

classmethod BaseTask.create_and_upload(**assignment_params)[source]

Create a new task and upload it to Mechanical Turk.

Parameters:assignment_params (dict) – Assignment parameters defined on MTurk.
BaseTask.upload(batch_id=None)[source]

Attempt to upload this task to mechanical turk.

Parameters:batch_id (mixed) – An optional ID to attach to this object
BaseTask.validate()[source]

Validate the attributes of this class. Raises ValidationError if any problems are found.

turkleton.assignment.task.batched_upload(*args, **kwds)[source]

Upload all items within this context in the same batch.

Parameters:batch_id (str or unicode) – A batch id
turkleton.assignment.task.dict_to_layout_parameters(dict_to_convert)[source]

Convert a dictionary into Mechanical Turk layout parameters. This is really equivalent to an XML formalization of a dictionary.

Parameters:dict_to_convert (dict) – A dictionary to be converted
Return type:boto.mturk.layoutparam.LayoutParameters
turkleton.assignment.task.keywords_from_list(keywords)[source]

Convert keywords from a list of strings into the appropriate format for creating a Mechanical Turk HIT.

Parameters:keywords (iterable) – A list of keywords
Return type:str or unicode

Module contents