Java 类com.amazonaws.mturk.requester.GetReviewResultsForHITResult 实例源码

项目:java-aws-mturk    文件:TestRequesterServiceRaw.java   
public void testCreateHITWithReviewPolicy() throws ServiceException {
  /* Create some review policies.
   * The policy details are nonsense and are not asserted on -- this test
   * just verifies that (1) the act of plugging in a review policy does not
   * cause createHIT to blow up, and that (2) said review policies appear in
   * the HIT's review results. */
  PolicyParameter[] skaParams = {
      new PolicyParameter("AnswerKey", null,
          new ParameterMapEntry[] { new ParameterMapEntry("1", new String[] {"correct answer"}) })
  };
  ReviewPolicy assignmentReviewPolicy = new ReviewPolicy("ScoreMyKnownAnswers/2011-09-01", skaParams);
  PolicyParameter[] phrParams = {
      new PolicyParameter("QuestionIds", new String[] {"1"}, null),
      new PolicyParameter("QuestionAgreementThreshold", new String[] {"50"}, null),
  };
  ReviewPolicy hitReviewPolicy = new ReviewPolicy("SimplePlurality/2011-09-01", phrParams);

  // Create the HIT with review policies
  HIT hit = service.createHIT(
      null, // hitTypeId
      defaultHITTitle + unique,
      defaultHITDescription,
      null, // keywords
      RequesterService.getBasicFreeTextQuestion(defaultQuestion),
      defaultReward,
      defaultAssignmentDurationInSeconds,
      defaultAutoApprovalDelayInSeconds,
      defaultLifetimeInSeconds,
      defaultMaxAssignments,
      null, // requesterAnnotation
      null, // qualificationRequirements
      null, // responseGroup
      null, // uniqueRequestToken
      assignmentReviewPolicy,
      hitReviewPolicy);

  // Make sure the policies were actually added to the created HIT
  GetReviewResultsForHITResult results = service.getReviewResultsForHIT(
      hit.getHITId(),
      new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT},
      true, // retrieveActions
      true, // retrieveResults
      1, // pageNumber
      1000, // pageSize
      null); // responseGroup
  assertEquals("Unexpected assignment policy", results.getAssignmentReviewPolicy().getPolicyName(), "ScoreMyKnownAnswers/2011-09-01");
  assertEquals("Unexpected HIT policy", results.getHITReviewPolicy().getPolicyName(), "SimplePlurality/2011-09-01");
}
项目:java-aws-mturk    文件:ReviewPolicyExample.java   
/**
 * Fetches and prints a bunch of review policy info about the given HIT.
 * @param hitId Which HIT to print results for
 */
public void printReviewResults(String hitId) {
  service.getRequesterStatistic(RequesterStatistic.EstimatedTotalLiability, TimePeriod.LifeToDate, null);

  System.out.println("Getting review policy results for HIT " + hitId + "...");
  System.out.println();
  GetReviewResultsForHITResult results = service.getReviewResultsForHIT(
      hitId,
      new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT},
      true, // retrieveActions
      true, // retrieveResults
      1, // pageNumber
      1000, // pageSize
      null); // responseGroup

  // Print ScoreKnownAnswers results/actions for this HIT
  printReviewReport(results.getAssignmentReviewReport(), results.getAssignmentReviewPolicy().getPolicyName());

  // Print PluralityHitReview results/actions for this HIT
  printReviewReport(results.getHITReviewReport(), results.getHITReviewPolicy().getPolicyName());

  // Get a list of workers who worked on this HIT
  Assignment[] assignments = service.getAssignmentsForHIT(hitId, 1);
  Set<String> workerIds = new HashSet<String>();
  if (assignments != null) {
    for (Assignment assignment : assignments) {
      workerIds.add(assignment.getWorkerId());
    }
  }

  // For each of those workers, fetch statistics relevant to review policies
  RequesterStatistic[] statistics = { // which statistics to print
      RequesterStatistic.NumberKnownAnswersCorrect,
      RequesterStatistic.NumberKnownAnswersIncorrect,
      RequesterStatistic.NumberKnownAnswersEvaluated,
      RequesterStatistic.PercentKnownAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersIncorrect,
      RequesterStatistic.NumberPluralityAnswersEvaluated,
      RequesterStatistic.PercentPluralityAnswersCorrect
  };
  if (workerIds.size() == 0) {
    System.out.println("No workers worked on this HIT.");
  } else {
    System.out.println("Review-policy-related statistics follow.");
    System.out.println("These statistics are life-to-date counts for each worker who worked on this HIT.");
    System.out.println("These counts only include work done for the requester of the HIT.");
    for (String workerId : workerIds) {
      System.out.println("Worker " + workerId + ":");
      for (RequesterStatistic statistic : statistics) {
        System.out.println("- " + statistic.getValue() + ": " + getStatistic(workerId, statistic));
      }
    }
  }
}
项目:mturksdk-java-code-maven    文件:TestRequesterServiceRaw.java   
public void testCreateHITWithReviewPolicy() throws ServiceException {
  /* Create some review policies.
   * The policy details are nonsense and are not asserted on -- this test
   * just verifies that (1) the act of plugging in a review policy does not
   * cause createHIT to blow up, and that (2) said review policies appear in
   * the HIT's review results. */
  PolicyParameter[] skaParams = {
      new PolicyParameter("AnswerKey", null,
          new ParameterMapEntry[] { new ParameterMapEntry("1", new String[] {"correct answer"}) })
  };
  ReviewPolicy assignmentReviewPolicy = new ReviewPolicy("ScoreMyKnownAnswers/2011-09-01", skaParams);
  PolicyParameter[] phrParams = {
      new PolicyParameter("QuestionIds", new String[] {"1"}, null),
      new PolicyParameter("QuestionAgreementThreshold", new String[] {"50"}, null),
  };
  ReviewPolicy hitReviewPolicy = new ReviewPolicy("SimplePlurality/2011-09-01", phrParams);

  // Create the HIT with review policies
  HIT hit = service.createHIT(
      null, // hitTypeId
      defaultHITTitle + unique,
      defaultHITDescription,
      null, // keywords
      RequesterService.getBasicFreeTextQuestion(defaultQuestion),
      defaultReward,
      defaultAssignmentDurationInSeconds,
      defaultAutoApprovalDelayInSeconds,
      defaultLifetimeInSeconds,
      defaultMaxAssignments,
      null, // requesterAnnotation
      null, // qualificationRequirements
      null, // responseGroup
      null, // uniqueRequestToken
      assignmentReviewPolicy,
      hitReviewPolicy);

  // Make sure the policies were actually added to the created HIT
  GetReviewResultsForHITResult results = service.getReviewResultsForHIT(
      hit.getHITId(),
      new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT},
      true, // retrieveActions
      true, // retrieveResults
      1, // pageNumber
      1000, // pageSize
      null); // responseGroup
  assertEquals("Unexpected assignment policy", results.getAssignmentReviewPolicy().getPolicyName(), "ScoreMyKnownAnswers/2011-09-01");
  assertEquals("Unexpected HIT policy", results.getHITReviewPolicy().getPolicyName(), "SimplePlurality/2011-09-01");
}
项目:mturksdk-java-code-maven    文件:ReviewPolicyExample.java   
/**
 * Fetches and prints a bunch of review policy info about the given HIT.
 * @param hitId Which HIT to print results for
 */
public void printReviewResults(String hitId) {
  service.getRequesterStatistic(RequesterStatistic.EstimatedTotalLiability, TimePeriod.LifeToDate, null);

  System.out.println("Getting review policy results for HIT " + hitId + "...");
  System.out.println();
  GetReviewResultsForHITResult results = service.getReviewResultsForHIT(
      hitId,
      new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT},
      true, // retrieveActions
      true, // retrieveResults
      1, // pageNumber
      1000, // pageSize
      null); // responseGroup

  // Print ScoreKnownAnswers results/actions for this HIT
  printReviewReport(results.getAssignmentReviewReport(), results.getAssignmentReviewPolicy().getPolicyName());

  // Print PluralityHitReview results/actions for this HIT
  printReviewReport(results.getHITReviewReport(), results.getHITReviewPolicy().getPolicyName());

  // Get a list of workers who worked on this HIT
  Assignment[] assignments = service.getAssignmentsForHIT(hitId, 1);
  Set<String> workerIds = new HashSet<String>();
  if (assignments != null) {
    for (Assignment assignment : assignments) {
      workerIds.add(assignment.getWorkerId());
    }
  }

  // For each of those workers, fetch statistics relevant to review policies
  RequesterStatistic[] statistics = { // which statistics to print
      RequesterStatistic.NumberKnownAnswersCorrect,
      RequesterStatistic.NumberKnownAnswersIncorrect,
      RequesterStatistic.NumberKnownAnswersEvaluated,
      RequesterStatistic.PercentKnownAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersIncorrect,
      RequesterStatistic.NumberPluralityAnswersEvaluated,
      RequesterStatistic.PercentPluralityAnswersCorrect
  };
  if (workerIds.size() == 0) {
    System.out.println("No workers worked on this HIT.");
  } else {
    System.out.println("Review-policy-related statistics follow.");
    System.out.println("These statistics are life-to-date counts for each worker who worked on this HIT.");
    System.out.println("These counts only include work done for the requester of the HIT.");
    for (String workerId : workerIds) {
      System.out.println("Worker " + workerId + ":");
      for (RequesterStatistic statistic : statistics) {
        System.out.println("- " + statistic.getValue() + ": " + getStatistic(workerId, statistic));
      }
    }
  }
}
项目:gort-public    文件:ReviewPolicyExample.java   
/**
 * Fetches and prints a bunch of review policy info about the given HIT.
 * @param hitId Which HIT to print results for
 */
public void printReviewResults(String hitId) {
  service.getRequesterStatistic(RequesterStatistic.EstimatedTotalLiability, TimePeriod.LifeToDate, null);

  System.out.println("Getting review policy results for HIT " + hitId + "...");
  System.out.println();
  GetReviewResultsForHITResult results = service.getReviewResultsForHIT(
      hitId,
      new ReviewPolicyLevel[] {ReviewPolicyLevel.Assignment, ReviewPolicyLevel.HIT},
      true, // retrieveActions
      true, // retrieveResults
      1, // pageNumber
      1000, // pageSize
      null); // responseGroup

  // Print ScoreKnownAnswers results/actions for this HIT
  printReviewReport(results.getAssignmentReviewReport(), results.getAssignmentReviewPolicy().getPolicyName());

  // Print PluralityHitReview results/actions for this HIT
  printReviewReport(results.getHITReviewReport(), results.getHITReviewPolicy().getPolicyName());

  // Get a list of workers who worked on this HIT
  Assignment[] assignments = service.getAssignmentsForHIT(hitId, 1);
  Set<String> workerIds = new HashSet<String>();
  if (assignments != null) {
    for (Assignment assignment : assignments) {
      workerIds.add(assignment.getWorkerId());
    }
  }

  // For each of those workers, fetch statistics relevant to review policies
  RequesterStatistic[] statistics = { // which statistics to print
      RequesterStatistic.NumberKnownAnswersCorrect,
      RequesterStatistic.NumberKnownAnswersIncorrect,
      RequesterStatistic.NumberKnownAnswersEvaluated,
      RequesterStatistic.PercentKnownAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersCorrect,
      RequesterStatistic.NumberPluralityAnswersIncorrect,
      RequesterStatistic.NumberPluralityAnswersEvaluated,
      RequesterStatistic.PercentPluralityAnswersCorrect
  };
  if (workerIds.size() == 0) {
    System.out.println("No workers worked on this HIT.");
  } else {
    System.out.println("Review-policy-related statistics follow.");
    System.out.println("These statistics are life-to-date counts for each worker who worked on this HIT.");
    System.out.println("These counts only include work done for the requester of the HIT.");
    for (String workerId : workerIds) {
      System.out.println("Worker " + workerId + ":");
      for (RequesterStatistic statistic : statistics) {
        System.out.println("- " + statistic.getValue() + ": " + getStatistic(workerId, statistic));
      }
    }
  }
}