Description Usage Arguments Details Value Author(s) References See Also Examples
Generate multiple HITs, possibly from an HTML template file, HITLayout parameters, or a vector of External Question URLs.
1 2 3 4 5 6 7 8 | BulkCreate(questions, annotation, verbose = FALSE, ...)
BulkCreateFromTemplate(template, input, annotation, type = "HTMLQuestion",
frame.height = 450, verbose = FALSE, ...)
BulkCreateFromURLs(url, frame.height = 450, annotation, verbose = FALSE, ...)
BulkCreateFromHITLayout(hitlayoutid, input, annotation, verbose = FALSE, ...)
|
questions |
A character vector where each entry is a valid argument for the |
template |
A character string or filename for a HIT template (probably a character string containing an HTML document or a path to a .html file). |
input |
A data.frame containing one row for each HIT to be created and columns named identically to the placeholders in the HIT template file (for |
type |
A character string specifying how to wrap the resulting HIT question contents for use in |
url |
A character vector of URLs (served over HTTPS) of HIT files stored anywhere other than the MTurk server. See |
frame.height |
A character string containing the integer value (in pixels) of the frame height for the ExternalQuestion iframe. See |
hitlayoutid |
An optional character string including a HITLayoutId retrieved from a HIT “project” template generated in the Requester User Interface at https://requester.mturk.com/create/projects. If the HIT template includes variable placeholders, must also specify |
annotation |
Either a one-element character vector containing a description for this group of HITs, or a character vector equal to the number of HITs to be created. This value is only visible to the requester. See |
verbose |
Optionally print the results of the API request (and other details) to the standard output. Default is |
... |
Additional arguments passed to |
These functions provide a wrapper for CreateHIT
to be able to produce a group of HITs with identical properties. BulkCreateFromTemplate
and BulkCreateFromHITLayout
provide further wrappers that make it easy to create a group of HITs in a manner similar to using the Requester User Interface (RUI). BulkCreateFromURLs
allows you to create multiple ExternalQuestion HITs.
The annotation
field is required in order to group the HITs together and facilitate monitoring the group using other MTurkR functions. Note that these functions do not create a “batch” as used by the RUI; a batch can only be created through that interface.
A list of data.frames, with each data.frame containing details of the HITs created. If all CreateHIT
operations succeed, this response value can easily be collapsed into a single data.frame using do.call("rbind", value)
.
Thomas J. Leeper
Requester User Interface: HIT Template
API Reference: ExternalQuestion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | ## Not run:
## BulkCreate ##
# load a vector of HTML files from the working directory
qvec <- sapply(list.files(pattern = ".html"), function(x) {
paste0(readLines(x, warn = FALSE), collapse = "\n")
})
# create a HIT from each question file
hits1 <- BulkCreate(questions = qvec,
annotation = paste("Bulk Create", Sys.Date()),
title = "Categorize an image",
description = "Categorize this image",
reward = ".05",
expiration = seconds(days = 4),
duration = seconds(minutes = 5),
keywords = "categorization, image, moderation, category")
# cleanup
ExpireHIT(annotation = paste("Bulk Create", Sys.Date()))
DisposeHIT(annotation = paste("Bulk Create", Sys.Date()))
## End(Not run)
## Not run:
## BulkCreateFromURLs ##
# create three HITs from the template
hits2 <-
BulkCreateFromURLs(url = paste0("https://www.example.com/",1:3,".html"),
frame.height = 400,
annotation = paste("Bulk From URLs", Sys.Date()),
title = "Categorize an image",
description = "Categorize this image",
reward = ".05",
expiration = seconds(days = 4),
duration = seconds(minutes = 5),
keywords = "categorization, image, moderation, category")
# cleanup
ExpireHIT(annotation = paste("Bulk From URLs", Sys.Date()))
DisposeHIT(annotation = paste("Bulk From URLs", Sys.Date()))
## End(Not run)
## Not run:
## BulkCreateFromTemplate ##
# load template HTML file
# should have placeholders of the form `${varName}` for variable values
temp <- system.file("templates/htmlquestion2.xml", package = "MTurkR")
# create/load data.frame of template variable values
a <- data.frame(hittitle = c("HIT title 1", "HIT title 2", "HIT title 3"),
hitvariable = c("HIT text 1", "HIT text 2", "HIT text 3"),
stringsAsFactors = FALSE)
# create three HITs from the template
hits3 <-
BulkCreateFromTemplate(template = temp,
input = a,
annotation = paste("Bulk From Template", Sys.Date()),
title = "Categorize an image",
description = "Categorize this image",
reward = ".05",
expiration = seconds(days = 4),
duration = seconds(minutes = 5),
keywords = "categorization, image, moderation, category")
# cleanup
ExpireHIT(annotation = paste("Bulk From Template", Sys.Date()))
DisposeHIT(annotation = paste("Bulk From Template", Sys.Date()))
## End(Not run)
## Not run:
## BulkCreateFromHITLayout ##
# retrieve HITLayoutID from Requester User Interface
layoutid <- "23ZGOOGQSCM61T1H5H9U0U00OQWFFU"
# create/load data.frame of HITLayout variable values
b <- data.frame(hittitle = c("HIT title 1", "HIT title 2", "HIT title 3"),
hitvariable = c("HIT text 1", "HIT text 2", "HIT text 3"),
stringsAsFactors = FALSE)
# create three HITs from the template
hits4 <-
BulkCreateFromHITLayout(hitlayoutid = layoutid,
input = b,
annotation = paste("Bulk From Layout", Sys.Date()),
title = "Categorize an image",
description = "Categorize this image",
reward = ".05",
expiration = seconds(days = 4),
duration = seconds(minutes = 5),
keywords = "categorization, image, moderation, category")
# cleanup
ExpireHIT(annotation = paste("Bulk From Layout", Sys.Date()))
DisposeHIT(annotation = paste("Bulk From Layout", Sys.Date()))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.