/**
   * A method to create a HIT with context and the target word provided Takes in the target word and
   * the surrounding context in two pieces
   *
   * @param Context before the target word
   * @param Target word
   * @param Context after the target word
   * @throws FileNotFoundException
   */
  public void createContextGivenSurvey(String firstSentence, String word, String secondSentence)
      throws FileNotFoundException {
    try {
      HIT hit =
          service.createHIT(
              null,
              contextGivenTitle,
              contextGivenDescription,
              null,
              contextGivenSub(firstSentence, word, secondSentence),
              reward,
              (long) 300,
              (long) 432000,
              (long) 345600,
              numAssignments,
              word,
              requirements,
              null);

      // Print out the HITId and the URL to view the HIT.
      System.out.println("Created HIT: " + hit.getHITId());
      contextpr.println(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());
    }
  }
  /**
   * A Method to create a HIT with the target word and the 2 words on either side along with the
   * sense and part of speech
   *
   * @param Context before the target word
   * @param Target word
   * @param Context after the target word
   * @param Word sense
   * @param Part of speech
   */
  private void createPartialContextGivenSurvey(
      String partialFirst, String target, String partialSecond, String sense, String POS) {
    try {
      HIT hit =
          service.createHIT(
              null,
              partialContextTitle,
              partialContextDescription,
              null,
              partialContextSub(partialFirst, target, partialSecond, sense, POS),
              reward,
              (long) 300,
              (long) 432000,
              (long) 259200,
              numAssignments,
              target,
              requirements,
              null);

      // Print out the HITId and the URL to view the HIT.
      System.out.println("Created HIT: " + hit.getHITId());
      partialContextpr.println(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());
    }
  }
  /**
   * Deletes the hit whose ID is given
   *
   * @param HIT Id
   * @throws IOException
   */
  public void deleteHIT(String hitId) throws IOException {
    try {
      hitId.trim();
      service.disableHIT(hitId);

      // Print out the HITId and the URL to view the HIT.
      System.out.println("Removed HIT: " + hitId);

    } catch (ServiceException e) {
      System.err.println(e.getLocalizedMessage());
    }
  }
  /**
   * Approves all the submissions for the hit whose ID is given
   *
   * @param HIT Id
   * @throws IOException
   */
  public void approveHIT(String hitId) throws IOException {
    try {
      hitId.trim();
      HIT currentHIT = service.getHIT(hitId);
      Assignment[] answers = service.getAssignmentsForHIT(hitId, currentHIT.getMaxAssignments());

      // Print out the HITId and the URL to view the HIT.
      System.out.println("Retrieved HIT: " + hitId);
      for (Assignment answer : answers) {
        answer.setAssignmentStatus(AssignmentStatus.Approved);
        System.out.println("Approved HIT: " + hitId);
        service.approveAssignment(answer.getAssignmentId(), "Accepted");
      }

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