• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HIT类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.mturk.requester.HIT的典型用法代码示例。如果您正苦于以下问题:Java HIT类的具体用法?Java HIT怎么用?Java HIT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HIT类属于com.amazonaws.mturk.requester包,在下文中一共展示了HIT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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]));
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:27,代码来源:RequesterService.java


示例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(); 
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:29,代码来源:RequesterService.java


示例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()]);	
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:26,代码来源:RequesterService.java


示例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()]);
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:30,代码来源:RequesterService.java


示例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());
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:22,代码来源:TestRequesterServiceRaw.java


示例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());
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:21,代码来源:TestRequesterService.java


示例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());
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:19,代码来源:TestRequesterService.java


示例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;
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:22,代码来源:TestBase.java


示例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());
  }
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:30,代码来源:MTurkHelloWorld.java


示例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());
      }
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:26,代码来源:MyHIT.java


示例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";
    }
}
 
开发者ID:keenon,项目名称:lense,代码行数:21,代码来源:MTurkSystem.java


示例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));
                }
            }
        }
    }
 
开发者ID:SurveyMan,项目名称:Runner,代码行数:25,代码来源:MturkResponseManager.java


示例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;
            }
        }
    }
}
 
开发者ID:SurveyMan,项目名称:Runner,代码行数:23,代码来源:MturkResponseManager.java


示例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;
            }
        }
    }
}
 
开发者ID:SurveyMan,项目名称:Runner,代码行数:18,代码来源:MturkResponseManager.java


示例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;
}
 
开发者ID:samini,项目名称:gort-public,代码行数:17,代码来源:Utility.java


示例16: createDBHITs

import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public static org.cmuchimps.gort.modules.dataobject.HIT[] createDBHITs(GortEntityManager gem, EntityManager em, HIT[] mturkHITs) {
    if (gem == null || em == null || mturkHITs == null) {
        return null;
    }
    
    if (mturkHITs.length <= 0) {
        return null;
    }
    
    List<org.cmuchimps.gort.modules.dataobject.HIT> retVal = new LinkedList<org.cmuchimps.gort.modules.dataobject.HIT>();
    
    for (HIT h : mturkHITs) {
        org.cmuchimps.gort.modules.dataobject.HIT gortHIT = createDBHIT(gem, em, h);
        
        if (gortHIT == null) {
            continue;
        }
        retVal.add(gortHIT);
    }
    
    return (retVal.size() > 0) ? 
            retVal.toArray(new org.cmuchimps.gort.modules.dataobject.HIT[retVal.size()]) :
            null;
}
 
开发者ID:samini,项目名称:gort-public,代码行数:25,代码来源:Utility.java


示例17: assignCrowdTaskHITs

import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
public static void assignCrowdTaskHITs(GortEntityManager gem, EntityManager em,
        CrowdTask crowdTask, org.cmuchimps.gort.modules.dataobject.HIT[] hits) {
    if (gem == null || em == null || crowdTask == null || hits == null) {
        return;
    }
    
    for (org.cmuchimps.gort.modules.dataobject.HIT h : hits) {
        if (h == null) {
            continue;
        }
        
        h.setCrowdTask(crowdTask);
        gem.updateEntity(em, h);
        
        /*
        if (crowdTask.getHits() == null) {
            crowdTask.setHits(new LinkedList<org.cmuchimps.gort.modules.dataobject.HIT>());
        }
        
        crowdTask.getHits().add(h);
        */
    }
    
    //gem.updateEntity(crowdTask);
}
 
开发者ID:samini,项目名称:gort-public,代码行数:26,代码来源:Utility.java


示例18: createMovieSurvey

import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
 * Create a simple survey.
 *
 */
public void createMovieSurvey()
 {
     try {
         // The createHIT method is called using a convenience static method
         // RequesterService.getBasicFreeTextQuestion() that generates the question format
         // for the HIT.
         HIT hit = service.createHIT
         (
             title,
             description,
             reward,
             RequesterService.getBasicFreeTextQuestion(
             "How many movies have you seen this month?"),
             numAssignments);
             // Print out the HITId and the URL to view the HIT.
             System.out.println("Created HIT: " + hit.getHITId());
             System.out.println("HIT location: ");
             System.out.println(service.getWebsiteURL() + "/mturk/preview?groupId="
             + hit.getHITTypeId());
     } catch (ServiceException e) {
         System.err.println(e.getLocalizedMessage());
     }
 }
 
开发者ID:samini,项目名称:gort-public,代码行数:28,代码来源:MovieSurvey.java


示例19: createHIT

import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
 * Backwards compatibility for programs that don't specify review policies
 */
public HIT createHIT(String hitTypeId, String title, String description, String keywords, 
    String question, Double reward, Long assignmentDurationInSeconds, Long autoApprovalDelayInSeconds, 
    Long lifetimeInSeconds, Integer maxAssignments, String requesterAnnotation, 
    QualificationRequirement[] qualificationRequirements, String[] responseGroup)
  throws ServiceException {
  
  return createHIT(hitTypeId, title, description, keywords, question, reward,
      assignmentDurationInSeconds, autoApprovalDelayInSeconds, lifetimeInSeconds,
      maxAssignments, requesterAnnotation, qualificationRequirements, responseGroup,
      null, null, null);
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:15,代码来源:RequesterServiceRaw.java


示例20: updateHIT

import com.amazonaws.mturk.requester.HIT; //导入依赖的package包/类
/**
 * Updates a HIT with new title, description, keywords, and reward. If new values are 
 * not specified, the values from the original HIT are used. The following default values 
 * are used:
 * <ul>
 *  <li>AssignmentDurationInSeconds: 1 hour</li>
 *  <li>AutoApprovalDelayInSeconds:  15 days</li>
 *  <li>QualificationRequirement: null</li>
 * </ul>
 * 
 * @param hitId        the Id of the HIT to update
 * @param title        the title of the updated HIT. If null, the current title 
 *                     of the HIT is used.
 * @param description  the description of the updated HIT. If null, the current description 
 *                     of the HIT is used.
 * @param keywords     one or more words or phrases to describe the updated HIT. If null, 
 *                     the current keywords are used.                  
 * @param reward       the amount to pay for the updated HIT when completed. If null, the 
 *                     the current reward of the HIT is used.
 * @return the new HITType Id
 * @throws ServiceException
 */
public String updateHIT(String hitId, String title, String description, String keywords,
    Double reward) throws ServiceException {
  if (title == null || description == null || keywords == null || reward == null) {
    HIT currentHIT = this.getHIT(hitId);
    if (title == null) {
      title = currentHIT.getTitle();
    }
    if (description == null) {
      description = currentHIT.getDescription();
    }
    if (keywords == null) {
      keywords = currentHIT.getKeywords();
    }
    if (reward == null) {
      reward = currentHIT.getReward().getAmount().doubleValue();
    }
  }
  String newHITTypeId = this.registerHITType(
      DEFAULT_AUTO_APPROVAL_DELAY_IN_SECONDS,
      DEFAULT_ASSIGNMENT_DURATION_IN_SECONDS,
      reward,
      title,
      keywords,
      description,
      null); // qualificationRequirements
  this.changeHITTypeOfHIT(hitId, newHITTypeId);
  return newHITTypeId;
}
 
开发者ID:dbarowy,项目名称:java-aws-mturk,代码行数:51,代码来源:RequesterService.java



注:本文中的com.amazonaws.mturk.requester.HIT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ScannerContext类代码示例发布时间:2022-05-22
下一篇:
Java BAMRecordCodec类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap