Exemplo n.º 1
0
def add_questions_to_sentences(resultlines, categories, tasks):
    """Adds the Questions to the Sentences in the Tasks (phew), reading the worker's
    data from resultlines (a list of lines from the result file) and using the
    dictionary categories to put the Questions in the correct places.
    pre: resultlines is a list of lines from the result file, categories is a
    hash table based on metadata strings.
    post: Returns the task dictionary."""
    workers = []
    for rline in resultlines:                                                   #For each worker's data...
      l = rline.split("\t")                                                         #Make it a list of data
      workerID = l[19]                                                              #Retrieve workerID
      l = map(deleteQuotes,l)                                                       #Delete all the unnecessary quotes
      worker = Worker(workerID, l[29])
      workers.append(worker)
      currentTask = tasks[ l[29] ]                                                  #Find the Task that the worker is working on (taskID @l[29])
      #print currentTask.get_ID()
      currentTask = __add_questions(l, currentTask, categories, worker)           #Add the questions where they should go
      #currentTask.add_worker(worker)
    #print len(currentTask.get_workers())
    for worker in workers:
      taskID = worker.get_taskID()
      task = tasks[taskID]
      if task.get_ID()==taskID:
      	task.add_worker(worker)
    #print len(
    return tasks