MturkR,R,自动发布微博

时间:2018-05-18 16:41:36

标签: r mechanicalturk

我是MTurk的新手,但与R有一定的流畅性。我第一次使用MTurkR包,我正在尝试创建随着时间的推移在MTurk上发布的“微批次”。我正在使用的代码可以在下面找到(XXXX部分显然填充了正确的值)。我没有得到任何错误消息,代码运行,并在沙箱和真实的正确发布HIT。但是,发布的HIT不会显示在Sandbox请求者帐户或真实的请求者帐户中,这意味着 - 据我所知 - 我无法评估在自动付款之前提交完成代码的工作人员。

有人能指出错误的位置,我怎样才能查看HIT? 谢谢。 ķ

##### Notes:
# 1) Change sandbox from TRUE to FALSE to run live (make sure to test in sandbox first!!)    

##### Step 1: Load library, set parameters

#### Load MTurkR library
library(MTurkR)
#### HIT Layout ID
# Layout ID for the choice task
# my_hitlayoutid = "XXXX"
# Layout ID for the choice task in the Sandbox
my_hitlayoutid = "XXXX"

#### Set MTurk credentials
Sys.setenv(    
  AWS_ACCESS_KEY_ID = "XXXX", 
  AWS_SECRET_ACCESS_KEY = "XXXX"
)

#### HIT parameters

## Run in sandbox?
sandbox_val <- "FALSE"

## Set the name of your project here (used to retrieve HITs later)
myannotation <- "myannotation"

## Enter other HIT aspects
newhittype <- RegisterHITType(
  title = "hope trial",
  description = "Description",
  reward = "2.5", 
  duration = seconds(hours = 1), 
  keywords = "survey, demographics, neighborhoods, employment",
  sandbox = sandbox_val
)

##### Step 2: Define functions

## Define a function that will create a HIT using information above
createhit <- function() {
  CreateHIT(    
    hit.type = newhittype$HITTypeId,
    assignments = 2,
    expiration = seconds(days = 30),
    annotation = myannotation,
    verbose = TRUE,
    sandbox = sandbox_val,
    hitlayoutid = my_hitlayoutid
  )
}

## Define a function that will expire all running HITs
## This keeps HITs from "piling up" on a slow day
## It ensures that A) HIT appears at the top of the list, B) workers won't accidentally accept HIT twice
# expirehits <- function() { 
#  ExpireHIT(
#    annotation = myannotation,
#    sandbox = sandbox_val
#  )
#}


##### Step 3: Execute a loop that runs createhit/expirehit functions every hour, and it will log the output to a file

## Define number of times to post the HIT (totalruns)
totalruns <- 2
counter <- 0

## Define log file (change the location as appropriate)
logfile <- file("/Users/kinga.makovi/Dropbox/Bias_Experiment/MTurk/logfile.txt", open="a")
sink(logfile, append=TRUE, type="message")

## Run loop (note: interval is hourly, but can be changed in Sys.sleep)
repeat {
  message(Sys.time())
  createhit()
  Sys.sleep(10)
  #expirehits()
  counter = counter + 1
  if (counter == totalruns){
    break
  }
}

## To stop the loop before it finishes, click the "STOP" button
## To stop logging, run sink()

1 个答案:

答案 0 :(得分:0)

您无法在请求者网站中看到通过API(通过MTurkR或其他方式)创建的HIT。它是一个&#34;功能&#34;。您必须通过MTurkR访问HIT(例如,SearchHITs()GetHIT())。