本文整理汇总了Java中com.amazonaws.mturk.requester.HIT类的典型用法代码示例。如果您正苦于以下问题:Java HIT类的具体用法?Java HIT怎么用?Java HIT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HIT类属于com.amazonaws.mturk.requester包,在下文中一共展示了HIT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHIT
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public HIT createHIT(String title, String description, double reward, int maxAssignments,
String layoutId, Map<String,String> layoutParameters) {
Set<HITLayoutParameter> parameterObjects = new HashSet<HITLayoutParameter>();
for (String key : layoutParameters.keySet()) {
parameterObjects.add(new HITLayoutParameter(key, layoutParameters.get(key)));
}
return super.createHIT(
null, // hitTypeId
title,
description,
null, // keywords
reward,
DEFAULT_ASSIGNMENT_DURATION_IN_SECONDS,
DEFAULT_AUTO_APPROVAL_DELAY_IN_SECONDS,
DEFAULT_LIFETIME_IN_SECONDS,
maxAssignments,
null, // requesterAnnotation
null, // qualificationRequirements
null, // responseGroup
null, // uniqueRequestToken
null, // assignmentReviewPolicy
null, // hitReviewPolicy
layoutId,
(HITLayoutParameter[]) parameterObjects.toArray(new HITLayoutParameter[0]));
}
示例2: searchHITs
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
* Retrieves the Requester's HITs found on the specified page.
* The request uses either the default or full responseGroup.
*
* @param pageNum The page of results to return. Once the HITs
* have been filtered, sorted, and divided into pages, the page
* corresponding to pageNum is returned.
* @param getFullResponse if true, all properties for the HIT are returned. If false, only the
* HIT Id and the HIT type Id are returned.
* @return an array of HITs
* @throws ServiceException
*/
public HIT[] searchHITs(int pageNum, boolean getFullResponse) throws ServiceException {
// Include HIT detail, HIT Question, and Assignment summary in response
String[] responseGroup = null;
if (getFullResponse == true) {
responseGroup = new String [] { "Minimal", "HITDetail",
"HITQuestion", "HITAssignmentSummary" };
}
SearchHITsResult result = super.searchHITs(
DEFAULT_SORT_DIRECTION, SearchHITsSortProperty.Expiration,
pageNum, DEFAULT_PAGE_SIZE, responseGroup
);
return result.getHIT();
}
示例3: searchAllHITs
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
* Retrieves all of the Requester's active HITs.
*
* @return an array of HITs
* @throws ServiceException
*/
public HIT[] searchAllHITs() throws ServiceException {
List<HIT> results = new ArrayList<HIT>();
int numHITsInAccount = this.getTotalNumHITsInAccount();
double numHITsInAccountDouble = new Double(numHITsInAccount);
double pageSizeDouble = new Double(DEFAULT_PAGE_SIZE);
double numPagesDouble = Math.ceil(numHITsInAccountDouble / pageSizeDouble);
int numPages = (new Double(numPagesDouble)).intValue();
for (int i = 1; i <= numPages; i = i + 1)
{
HIT[] hits = this.searchHITs(i, true);
Collections.addAll(results, hits);
}
return (HIT[]) results.toArray(new HIT[results.size()]);
}
示例4: getAllReviewableHITs
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
* Retrieves all of the Requester's reviewable HITs of the specified HIT type.
*
* @param hitTypeId the ID of the HIT type of the HITs to consider for the query
* @return an array of Reviewable HITs
* @throws ServiceException
*/
public HIT[] getAllReviewableHITs(String hitTypeId) throws ServiceException {
List<HIT> results = new ArrayList<HIT>();
int pageNum = 1;
do {
HIT[] hit = this.getReviewableHITs(hitTypeId, pageNum);
if (hit != null) {
// Add the results
Collections.addAll(results, hit);
}
// Check if we're on the last page or not
if (hit == null || hit.length < DEFAULT_PAGE_SIZE)
break;
pageNum++;
} while (true);
return (HIT[]) results.toArray(new HIT[results.size()]);
}
示例5: testSearchHITsResponseGroups
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public void testSearchHITsResponseGroups() throws ServiceException {
getTestHITId(); // make sure there is at least one HIT
SearchHITsResult result = service.searchHITs(RequesterService.DEFAULT_SORT_DIRECTION,
SearchHITsSortProperty.CreationTime, defaultPageNum, defaultPageSize,
new String [] {"Minimal", "HITQuestion"});
assertNotNull(result);
assertNotNull(result.getHIT(0));
HIT hit = result.getHIT(0);
assertNotNull(hit.getQuestion());
result = service.searchHITs(RequesterService.DEFAULT_SORT_DIRECTION,
SearchHITsSortProperty.CreationTime, defaultPageNum, defaultPageSize,
new String [] {"Minimal"});
assertNotNull(result);
assertNotNull(result.getHIT(0));
hit = result.getHIT(0);
assertNull(hit.getQuestion());
}
示例6: testUpdateHITTextAttributes
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public void testUpdateHITTextAttributes() throws ServiceException {
HIT hit = service.createHIT(defaultHITTitle + unique, defaultHITDescription, defaultReward,
RequesterService.getBasicFreeTextQuestion(defaultQuestion),
defaultMaxAssignments, true);
String newHITTypeId = service.updateHIT(hit.getHITId(),
hit.getTitle() + " amended",
hit.getDescription() + " amended",
"new, updated, improved, amended", null);
HIT newHIT = service.getHIT(hit.getHITId());
assertFalse(newHITTypeId.equals(hit.getHITTypeId()));
assertEquals(newHITTypeId, newHIT.getHITTypeId());
assertEquals(hit.getHITId(), newHIT.getHITId());
assertTrue(newHIT.getTitle().endsWith(" amended"));
assertTrue(newHIT.getDescription().endsWith(" amended"));
assertTrue(newHIT.getKeywords().endsWith(" amended"));
assertEquals(hit.getReward(), newHIT.getReward());
}
示例7: testUpdateHITReward
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public void testUpdateHITReward() throws ServiceException {
HIT hit = service.createHIT(defaultHITTitle + unique, defaultHITDescription, defaultReward,
RequesterService.getBasicFreeTextQuestion(defaultQuestion),
defaultMaxAssignments, true);
String newHITTypeId = service.updateHIT(hit.getHITId(),
null, null, null, 0.50);
HIT newHIT = service.getHIT(hit.getHITId());
assertFalse(newHITTypeId.equals(hit.getHITTypeId()));
assertEquals(newHITTypeId, newHIT.getHITTypeId());
assertEquals(hit.getHITId(), newHIT.getHITId());
assertEquals(hit.getTitle(), newHIT.getTitle());
assertEquals(hit.getDescription(), newHIT.getDescription());
assertEquals(hit.getKeywords(), newHIT.getKeywords());
assertEquals(0.50, newHIT.getReward().getAmount().doubleValue());
}
示例8: createHIT
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
protected HIT createHIT(QualificationRequirement qualRequirement) throws ServiceException {
QualificationRequirement[] qualRequirements = null;
if (qualRequirement != null) {
qualRequirements = new QualificationRequirement[] { qualRequirement };
}
HIT hit = service.createHIT(null, // HITTypeId
defaultHITTitle + unique,
defaultHITDescription, null, // keywords
RequesterService.getBasicFreeTextQuestion(defaultQuestion), defaultReward,
defaultAssignmentDurationInSeconds, defaultAutoApprovalDelayInSeconds,
defaultLifetimeInSeconds, defaultMaxAssignments, null, // requesterAnnotation
qualRequirements,
null // responseGroup
);
assertNotNull(hit);
assertNotNull(hit.getHITId());
return hit;
}
示例9: createHelloWorld
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
* Creates the simple HIT.
*
*/
public void createHelloWorld() {
try {
// The createHIT method is called using a convenience static method of
// RequesterService.getBasicFreeTextQuestion that generates the QAP for
// the HIT.
HIT hit = service.createHIT(
title,
description,
reward,
RequesterService.getBasicFreeTextQuestion(
"What is the weather like right now in Seattle, WA?"),
numAssignments);
System.out.println("Created HIT: " + hit.getHITId());
System.out.println("You may see your HIT with HITTypeId '"
+ hit.getHITTypeId() + "' here: ");
System.out.println(service.getWebsiteURL()
+ "/mturk/preview?groupId=" + hit.getHITTypeId());
} catch (ServiceException e) {
System.err.println(e.getLocalizedMessage());
}
}
示例10: createMyHIT
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public void createMyHIT() {
try {
// The createHIT method is called using a convenience static method of
// RequesterService.getBasicFreeTextQuestion that generates the QAP for
// the HIT.
HIT hit = service.createHIT(
title,
description,
reward,
RequesterService.getBasicFreeTextQuestion(
"What is the current temperature now in Seattle, WA?"),
numAssignments);
System.out.println("Created HIT: " + hit.getHITId());
System.out.println("You may see your HIT with HITTypeId '"
+ hit.getHITTypeId() + "' here: ");
System.out.println(service.getWebsiteURL()
+ "/mturk/preview?groupId=" + hit.getHITTypeId());
} catch (ServiceException e) {
System.err.println(e.getLocalizedMessage());
}
}
示例11: hireWorkers
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
* This makes a post to hire workers
*/
public String hireWorkers(int numWorkersToHire) {
try {
String title = "30 minutes of real-time decisions, BONUS at ~$12 / hr if busy";
String description = "Receive $3 for just sitting here for 30 mins, and an extra $0.01 for every 5 labels.";
String question = new HITQuestion("lense/src/resources/external.question").getQuestion();
double reward = 3.00;
HIT hit = mturkService.createHIT(title, description, reward, question, numWorkersToHire);
String url = mturkService.getWebsiteURL()+"/mturk/preview?groupId="+hit.getHITTypeId();
log.info("Created HIT: " + hit.getHITId());
log.info("You can see it here: " + url);
return url;
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
示例12: getTask
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public ITask getTask(String taskId)
{
String name = "getTask";
int waittime = 2;
while (true) {
synchronized (service) {
try {
HIT hit = service.getHIT(taskId);
// LOGGER.info(String.format("Retrieved HIT %s", hit.getHITId()));
return new MturkTask(hit);
} catch (InternalServiceException ise) {
if (overTime(name, waittime)) {
LOGGER.error(String.format("%s ran over time", name));
return null;
}
LOGGER.warn(format("{0} {1}", name, ise));
chill(waittime);
waittime *= 2;
} catch (ObjectDoesNotExistException odnee) {
LOGGER.warn(format("{0} {1}", name, odnee));
}
}
}
}
示例13: getAllAssignmentsForHIT
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
private List<Assignment> getAllAssignmentsForHIT(
HIT hit)
{
String name = "getAllAssignmentsForHIT";
int waittime = 2;
while (true) {
synchronized (service) {
try {
Assignment[] hitAssignments = service.getAllAssignmentsForHIT(hit.getHITId());
List<Assignment> assignments = new LinkedList<>();
boolean addAll = assignments.addAll(Arrays.asList(hitAssignments));
if (addAll)
LOGGER.info(String.format("Retrieved %d assignments for HIT %s", hitAssignments.length, hit.getHITId()));
return assignments;
} catch (InternalServiceException ise) {
LOGGER.warn(format("{0} {1}", name, ise));
chill(waittime);
waittime *= 2;
}
}
}
}
示例14: numAvailableAssignments
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
int numAvailableAssignments(ITask task) {
String name = "availableAssignments";
while (true){
synchronized (service) {
try{
HIT hit = service.getHIT(task.getTaskId());
return hit.getNumberOfAssignmentsAvailable();
}catch(InternalServiceException ise){
LOGGER.warn(MessageFormat.format("{0} {1}", name, ise));
chill(1);
}catch(ObjectDoesNotExistException odne) {
LOGGER.warn(MessageFormat.format("{0} {1}", name, odne));
return 0;
}
}
}
}
示例15: createDBHIT
import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public static org.cmuchimps.gort.modules.dataobject.HIT createDBHIT(GortEntityManager gem, EntityManager em, HIT mturkHIT) {
if (gem == null || em == null || mturkHIT == null) {
return null;
}
//(String type, Date submission, String hitId, String hitTypeId, String hitGroupId, String hitLayoutId)
org.cmuchimps.gort.modules.dataobject.HIT gortHIT =
new org.cmuchimps.gort.modules.dataobject.HIT(
(mturkHIT.getCreationTime() != null) ? mturkHIT.getCreationTime().getTime() : DateHelper.getUTC(),
mturkHIT.getHITId(), mturkHIT.getHITTypeId(),
mturkHIT.getHITGroupId(), mturkHIT.getHITLayoutId());
gortHIT.setInput(mturkHIT.getQuestion());
gem.insertEntity(em, gortHIT);
return gortHIT;
}