org.square.qa.utilities.constructs
Class GeneralUtilsParameterized<TypeWID,TypeQ,TypeR>

java.lang.Object
  extended by org.square.qa.utilities.constructs.GeneralUtilsParameterized<TypeWID,TypeQ,TypeR>

public class GeneralUtilsParameterized<TypeWID,TypeQ,TypeR>
extends Object


Constructor Summary
GeneralUtilsParameterized()
           
 
Method Summary
 Map<TypeR,Integer> getCategIntMap(Set<TypeR> responseCategories)
          Map response categories to integers
 Map<TypeQ,TypeR> getFilteredGT(Map<TypeQ,TypeR> gt, List<TypeQ> questions)
          Filter ground truth to include input questions only
 Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getFilteredWorkerMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap, List<TypeQ> questions)
          Filter worker responses to include input questions only
 Map<TypeQ,Integer> getQuestionIntMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
          Compute a map from questions to integers
 Map<TypeQ,TypeR> getQuestionResultPair(Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combined)
          Get question and estimated results from combined results
 Set<TypeQ> getQuestions(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
          Extract questions from workers map
 Set<TypeQ> getQuestionsGT(Map<TypeQ,TypeR> gt)
          Extract questions from ground truth
 Map<TypeWID,Integer> getWorkerIntMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
          Compute a map from workers to integers
 void printMapFileQI(Map<TypeQ,Integer> questionToInt, File file)
          Print questions mapped to integers to a file
 void printMapFileRI(Map<TypeR,Integer> responseToInt, File file)
          Print responses mapped to integers to a file
 void printMapFileWI(Map<TypeWID,Integer> workerToInt, File file)
          Print workers mapped to integers to a file
 void printNumberedGT(Map<TypeQ,TypeR> gt, File file)
          Print ground truth to file -- categToInt, workerToInt and questionToInt need to be valid
 void printNumberedResponses(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap, File file)
          Print worker responses to file -- categToInt, workerToInt and questionToInt need to be valid
 void printStatistics(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap, File... outDir)
          Prints workerStatistics.txt dataStatistics.txt and questionStatistics.txt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtilsParameterized

public GeneralUtilsParameterized()
Method Detail

getQuestions

public Set<TypeQ> getQuestions(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
Extract questions from workers map

Parameters:
workersMap - is a Map from worker ids to an object holding question and responses
Returns:
a Set holding all questions

getQuestionsGT

public Set<TypeQ> getQuestionsGT(Map<TypeQ,TypeR> gt)
Extract questions from ground truth

Parameters:
gt - is Map from questions to responses
Returns:
a Set holding questions

getFilteredWorkerMap

public Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getFilteredWorkerMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap,
                                                                        List<TypeQ> questions)
Filter worker responses to include input questions only

Parameters:
workersMap - is a Map from workers to an object holding questions and responses
questions - is a List of questions
Returns:
filtered workersMap

getFilteredGT

public Map<TypeQ,TypeR> getFilteredGT(Map<TypeQ,TypeR> gt,
                                      List<TypeQ> questions)
Filter ground truth to include input questions only

Parameters:
gt - is a Map from questions to responses
questions - is a List of questions
Returns:
is a Map from questions to responses

getQuestionIntMap

public Map<TypeQ,Integer> getQuestionIntMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
Compute a map from questions to integers

Parameters:
workersMap - is a Map from workers to an object holding questions and responses
Returns:
a Map from Questions to Integers

getWorkerIntMap

public Map<TypeWID,Integer> getWorkerIntMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
Compute a map from workers to integers

Parameters:
workersMap - is a Map from workers to an object holding questions and responses
Returns:
a Map from Workers to Integers

printNumberedResponses

public void printNumberedResponses(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap,
                                   File file)
                            throws FileNotFoundException
Print worker responses to file -- categToInt, workerToInt and questionToInt need to be valid

Parameters:
workersMap - is a Map from workers to an object holding questions and responses
file - is of type File -- output file
Throws:
FileNotFoundException

printNumberedGT

public void printNumberedGT(Map<TypeQ,TypeR> gt,
                            File file)
                     throws FileNotFoundException
Print ground truth to file -- categToInt, workerToInt and questionToInt need to be valid

Parameters:
gt - is a Map from questions to responses
file - is of type File -- output file
Throws:
FileNotFoundException

getCategIntMap

public Map<TypeR,Integer> getCategIntMap(Set<TypeR> responseCategories)
Map response categories to integers

Parameters:
responseCategories - is a Set of type responses holding response categories
Returns:
a Map from response categories to integers

printMapFileRI

public void printMapFileRI(Map<TypeR,Integer> responseToInt,
                           File file)
                    throws FileNotFoundException
Print responses mapped to integers to a file

Parameters:
responseToInt - is a Map from response categories to integers
file - is a File -- output file
Throws:
FileNotFoundException

printMapFileQI

public void printMapFileQI(Map<TypeQ,Integer> questionToInt,
                           File file)
                    throws FileNotFoundException
Print questions mapped to integers to a file

Parameters:
questionToInt - is a Map from questions to integers
file - is File -- output file
Throws:
FileNotFoundException

printMapFileWI

public void printMapFileWI(Map<TypeWID,Integer> workerToInt,
                           File file)
                    throws FileNotFoundException
Print workers mapped to integers to a file

Parameters:
workerToInt - is a Map from workers to integers
file - is a File -- output file
Throws:
FileNotFoundException

printStatistics

public void printStatistics(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap,
                            File... outDir)
                     throws FileNotFoundException
Prints workerStatistics.txt dataStatistics.txt and questionStatistics.txt

Parameters:
workersMap - is a Map from workers to an object holding questions and responses
outDir - of type File is the output directory to print files
Throws:
FileNotFoundException

getQuestionResultPair

public Map<TypeQ,TypeR> getQuestionResultPair(Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combined)
Get question and estimated results from combined results

Parameters:
combined - is a Map from questions to a Pair holding the most probable result and other result probabilities
Returns:
a Map from questions to estimated results


Copyright © 2013. All Rights Reserved.