• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java HITQuestion类的典型用法和代码示例

java 1次浏览

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

HITQuestion类属于com.amazonaws.mturk.addon包,在下文中一共展示了HITQuestion类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: previewHIT

点赞 3

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
/**
 * Creates a preview of a HIT in a file.
 * 
 * @param previewFileName  the file in which the HIT is copied
 * @param input            the input needed for the HIT
 * @param props            the properties of the HIT 
 * @param question         the question asked in the HIT
 * @throws ServiceException
 */
public void previewHIT(String previewFileName, HITDataInput input, HITProperties props, 
    HITQuestion question) throws ServiceException {
  try {
    String previewString = previewHIT(input, props, question);

    if (previewString != null) {
      FileUtil fts = new FileUtil(previewFileName);
      fts.saveString(previewString, false); // overwrite
    }
  }
  catch (Exception e)
  {
    throw new ServiceException("Error generating preview file " + previewFileName, e);
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:25,
代码来源:RequesterService.java

示例2: hireWorkers

点赞 3

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的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

示例3: createHITs

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
/**
 * Creates multiple HITs. 
 * 
 * @param input          the input data needed for the HITs
 * @param props          the properties of the HITs
 * @param question       the question asked in the HITs
 * @param numHITToLoad   the number of HITs to create
 * @return an array of HIT objects
 * @throws Exception
 * @deprecated
 */  
public HIT[] createHITs(HITDataReader input, HITProperties props, HITQuestion question, int numHITToLoad) {
  String prefix = input.getFileName();
  if ( prefix == null || prefix.length() == 0 ) {
    prefix = "input";
  }

  HITDataOutput success = null;
  HITDataOutput failure = null;
  try {
    success = new HITDataWriter(prefix + ".success");
    failure = new HITDataWriter(prefix + ".failure");
    return createHITs(input,props,question,numHITToLoad,success,failure);
  }
  catch (Exception e) {
    log.error("Error loading HITs", e);
  }
  finally {
      if (success != null) {
          success.close();
      }
      if (failure != null) {
          failure.close();
      }
  }
  return null;
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:38,
代码来源:RequesterService.java

示例4: testValidateInvalidExternalQuestion

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testValidateInvalidExternalQuestion() throws Exception {
  HITQuestion htmlQuestion = new HITQuestion(defaultInvalidExternalQuestionFileName);

  try {
    service.previewHIT(defaultHITInput, defaultHITProperties, htmlQuestion);

    fail("Expected ValidationException when previewing HIT with invalid external question." );
  }
  catch (ValidationException e) {
    // Expected exception
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:13,
代码来源:TestRequesterService.java

示例5: testCreateFormattedContentHIT

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testCreateFormattedContentHIT() throws Exception {
  HITQuestion htmlQuestion = new HITQuestion(defaultFormattedContentQuestionFileName);

  HIT[] hits = service.createHITs(defaultHITInput, defaultHITProperties, 
                                  htmlQuestion, null, null);
  
  assertNotNull(hits);
  assertTrue("should have succeeded with more than 1, but was " + hits.length, hits.length > 1);
  assertNotNull(hits[1]);
  assertNotNull(hits[1].getHITId());
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:12,
代码来源:TestRequesterService.java

示例6: testCreateInvalidFormattedContentHIT

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testCreateInvalidFormattedContentHIT() throws Exception {
  HITQuestion htmlQuestion = new HITQuestion(defaultInvalidFormattedContentQuestionFileName);

  try {
    service.previewHIT(defaultHITInput, defaultHITProperties, htmlQuestion);

    fail("Expected ValidationException when creating HIT with invalid formatted content." );
  }
  catch (ValidationException e) {
    // Expected exception
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:13,
代码来源:TestRequesterService.java

示例7: testCreateScriptFormattedContentHIT

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testCreateScriptFormattedContentHIT() throws Exception {
  HITQuestion htmlQuestion = new HITQuestion(defaultScriptFormattedContentQuestionFileName);

  try {
    service.previewHIT(defaultHITInput, defaultHITProperties, htmlQuestion);

    fail("Expected ValidationException when creating HIT with script in formatted content." );
  }
  catch (ValidationException e) {
    // Expected exception
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:13,
代码来源:TestRequesterService.java

示例8: createSurvey

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void createSurvey() {
  try {

    QualificationRequirement[] requirements = null;
    if(haveQualifications) {
      requirements = new QualificationRequirement[4];
      requirements[0] = new QualificationRequirement(RequesterService.LOCALE_QUALIFICATION_TYPE_ID, Comparator.EqualTo, null, new Locale("US"), invisible); //USA! USA!
      requirements[1] = new QualificationRequirement(getQualificationTypeId(), Comparator.EqualTo, 1, null, invisible); //Completed the screener
      requirements[2] = new QualificationRequirement(RequesterService.APPROVAL_RATE_QUALIFICATION_TYPE_ID, Comparator.GreaterThanOrEqualTo, 95, null, invisible); //>=95% approval
      requirements[3] = new QualificationRequirement("00000000000000000040", Comparator.GreaterThanOrEqualTo, 1000, null, invisible); //>=1000 HITs
    }

    String[] responseGroup = new String[]{"Minimal"};

    HITQuestion question = new HITQuestion("fullsurveyquestion.xml");

    SurveyParameters p = parameters;

    String hitType = service.registerHITType(p.autoApprovalDelay, p.assignmentDuration, p.reward, p.title, p.keywords, p.description, requirements);

    HIT hit = service.createHIT(hitType, p.title, p.description, p.keywords, question.getQuestion(), p.reward, p.assignmentDuration, p.autoApprovalDelay, p.lifetime, p.numAssignments, p.annotation, requirements, responseGroup);

    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());

    PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("hitid.txt", append))); //Should hopefully append the hit id.
    writer.println(hit.getHITId() + " " + service.getWebsiteURL() + "/mturk/preview?groupId=" + hit.getHITTypeId());
    writer.close();

  } catch (Exception e) {
    System.err.println(e.getLocalizedMessage());
  }
}
 

开发者ID:depstein,
项目名称:mturk-screening-presurvey,
代码行数:38,
代码来源:FullSurvey.java

示例9: createScreener

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void createScreener() {
  try {

    QualificationRequirement[] requirements = null;
    if(haveQualifications) {
      requirements = new QualificationRequirement[3];
      requirements[0] = new QualificationRequirement(RequesterService.APPROVAL_RATE_QUALIFICATION_TYPE_ID, Comparator.GreaterThanOrEqualTo, 95, null, invisible); //>=95% approval
      requirements[1] = new QualificationRequirement("00000000000000000040", Comparator.GreaterThanOrEqualTo, 1000, null, invisible); //>=1000 HITs
      requirements[2] = new QualificationRequirement(RequesterService.LOCALE_QUALIFICATION_TYPE_ID, Comparator.EqualTo, null, new Locale("US"), invisible); //USA! USA!
    }

    String[] responseGroup = new String[]{"Minimal"};

    HITQuestion question = new HITQuestion("screenerquestion.xml");

    String hitType = service.registerHITType(autoApprovalDelay, assignmentDuration, reward, title, keywords, description, requirements);

    HIT hit = service.createHIT(hitType, title, description, keywords, question.getQuestion(), reward, assignmentDuration, autoApprovalDelay, lifetime, numAssignments, annotation, requirements, responseGroup);

    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());

    PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("hitid.txt", append))); //Should hopefully append the hit id.
    writer.println(hit.getHITId() + " " + service.getWebsiteURL() + "/mturk/preview?groupId=" + hit.getHITTypeId());
    writer.close();

  } catch (Exception e) {
    System.err.println(e.getLocalizedMessage());
  }
}
 

开发者ID:depstein,
项目名称:mturk-screening-presurvey,
代码行数:34,
代码来源:ScreenerQuestion.java

示例10: testValidateExternalQuestion

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testValidateExternalQuestion() throws Exception {
  HITQuestion htmlQuestion = new HITQuestion(defaultExternalQuestionFileName);

  service.previewHIT(defaultHITInput, defaultHITProperties, htmlQuestion);
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:6,
代码来源:TestRequesterService.java

示例11: testLoadUTF8QuestionFile

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
public void testLoadUTF8QuestionFile() throws Exception {
    HITQuestion q = new HITQuestion(defaultUTF8QuestionFileName);
    assertFalse("Expected Unicode string was missing.", q.getQuestion().indexOf("Uñìçődé") == -1);
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:5,
代码来源:TestHITQuestion.java

示例12: createSimpleSurvey

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
/**
 * Creates the simple survey.
 *
 */
public void createSimpleSurvey() {
  try {

    // This is an example of creating a qualification.
    // This is a built-in qualification -- user must be based in the US
    QualificationRequirement qualReq = new QualificationRequirement();
    qualReq.setQualificationTypeId(RequesterService.LOCALE_QUALIFICATION_TYPE_ID);
    qualReq.setComparator(Comparator.EqualTo);
    Locale country = new Locale();
    country.setCountry("US");
    qualReq.setLocaleValue(country);

    // The create HIT method takes in an array of QualificationRequirements
    // since a HIT can have multiple qualifications.
    QualificationRequirement[] qualReqs = null;
    qualReqs = new QualificationRequirement[] { qualReq };

    // Loading the question (QAP) file. HITQuestion is a helper class that
    // contains the QAP of the HIT defined in the external file. This feature 
    // allows you to write the entire QAP externally as a file and be able to 
    // modify it without recompiling your code.
    HITQuestion question = new HITQuestion(questionFile);
    
    //Creating the HIT and loading it into Mechanical Turk
    HIT hit = service.createHIT(null, // HITTypeId 
        title, 
        description, keywords, 
        question.getQuestion(),
        reward, assignmentDurationInSeconds,
        autoApprovalDelayInSeconds, lifetimeInSeconds,
        numAssignments, requesterAnnotation, 
        qualReqs,
        null // responseGroup
      );
    
    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());
    
    //Demonstrates how a HIT can be retrieved if you know its HIT ID
    HIT hit2 = service.getHIT(hit.getHITId());
    
    System.out.println("Retrieved HIT: " + hit2.getHITId());
    
    if (!hit.getHITId().equals(hit2.getHITId())) {
      System.err.println("The HIT Ids should match: " 
          + hit.getHITId() + ", " + hit2.getHITId());
    }
    
  } catch (Exception e) {
    System.err.println(e.getLocalizedMessage());
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:62,
代码来源:SimpleSurvey.java

示例13: createSiteCategoryHITs

点赞 2

import com.amazonaws.mturk.addon.HITQuestion; //导入依赖的package包/类
/**
 * Create the website category HITs.
 *
 */
public void createSiteCategoryHITs() {
  try {

    //Loading the input file.  The input file is a tab delimited file where the first row
    //defines the fields/variables and the remaining rows contain the values for each HIT.
    //Each row represents a unique HIT.  The SDK uses the Apache Velocity engine to merge
    //the input values into a templatized QAP file.
    //Please refer to http://velocity.apache.org for more details on this engine and
    //how to specify variable names.  Apache Velocity is fully supported so there may be
    //additional functionality you can take advantage of if you know the Velocity syntax.
    HITDataInput input = new HITDataCSVReader(inputFile);

    //Loading the question (QAP) file.  This QAP file contains Apache Velocity variable names where the values
    //from the input file are to be inserted.  Essentially the QAP becomes a template for the input file.
    HITQuestion question = new HITQuestion(questionFile);

    //Loading the HIT properties file.  The properties file defines two system qualifications that will
    //be used for the HIT.  The properties file can also be a Velocity template.  Currently, only
    //the "annotation" field is allowed to be a Velocity template variable.  This allows the developer
    //to "tie in" the input value to the results.
    HITProperties props = new HITProperties(propertiesFile);

    HIT[] hits = null;

    // Create multiple HITs using the input, properties, and question files

    System.out.println("--[Loading HITs]----------");
    Date startTime = new Date();
    System.out.println("  Start time: " + startTime);

    //The simpliest way to bulk load a large number of HITs where all details are defined in files.
    //When using this method, it will automatically create output files of the following type:
    //  - <your input file name>.success - A file containing the HIT IDs and HIT Type IDs of
    //                                     all HITs that were successfully loaded.  This file will
    //                                     not exist if there are no HITs successfully loaded.
    //  - <your input file name>.failure - A file containing the input rows that failed to load.
    //                                     This file will not exist if there are no failures.
    //The .success file can be used in subsequent operations to retrieve the results that workers submitted.
    HITDataOutput success = new HITDataCSVWriter(inputFile + ".success");
    HITDataOutput failure = new HITDataCSVWriter(inputFile + ".failure");
    hits = service.createHITs(input, props, question, success, failure);

    System.out.println("--[End Loading HITs]----------");
    Date endTime = new Date();
    System.out.println("  End time: " + endTime);
    System.out.println("--[Done Loading HITs]----------");
    System.out.println("  Total load time: "
        + (endTime.getTime() - startTime.getTime())/1000 + " seconds.");

    if (hits == null) {
      throw new Exception("Could not create HITs");
    }

  } catch (Exception e) {
    System.err.println(e.getLocalizedMessage());
  }
}
 

开发者ID:dbarowy,
项目名称:java-aws-mturk,
代码行数:62,
代码来源:SiteCategory.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)