/** * Prints the submitted results of HITs when provided with a .success file. * @param successFile The .success file containing the HIT ID and HIT Type ID * @param outputFile The output file to write the submitted results to */ public void printResults(String successFile, String outputFile) { try { //Loads the .success file containing the HIT IDs and HIT Type IDs of HITs to be retrieved. HITDataInput success = new HITDataCSVReader(successFile); //Retrieves the submitted results of the specified HITs from Mechanical Turk HITTypeResults results = service.getHITTypeResults(success); results.setHITDataOutput(new HITDataCSVWriter(outputFile)); //Writes the submitted results to the defined output file. //The output file is a tab delimited file containing all relevant details //of the HIT and assignments. The submitted results are included as the last set of fields //and are represented as tab separated question/answer pairs results.writeResults(); System.out.println("Results have been written to: " + outputFile); } catch (Exception e) { System.err.println("ERROR: Could not print results: " + e.getLocalizedMessage()); } }
/** * Gets the results for specified HIT types. * * @param success a success file that contains the HITTypes * @return a HITTypeResults object that contains the results of the HITs */ public HITTypeResults getHITTypeResults(HITDataInput success) { HITTypeResults r = null; try { r = this.getHITTypeResults(success, null); } catch (IOException e) { // There shouldn't be any IO exception here log.error("IOException thrown. Did the HIT results get printed somehow?"); } return r; }