def setupBid(path):
   #setup stop words
   stopWords = stopwords.words('english')
   questionWords = ['who','who\'s','who\'re','what','what\'s','what\'re','will','which','whom','where','where\s','where\'re','when','when\s','when\'re','why','why\'s', 'why\'re','how','how\'s','how\'re','would','can']
   mStopWords = [w for w in stopWords if not w in questionWords]
   global neededWords
   tempDict, neededWords = genQueries.buildDict(path)
   allQueries = []
   allTerms = []
   for qId, [possibleQueries, answer] in tempDict.items():
      tempPQueries = []
      for possibleQuery in possibleQueries:
         tempPQueries.append(parseQuery(possibleQuery)) 
         allQueries.append(parseQuery(possibleQuery))
         for term in parseQuery(possibleQuery):
            if term not in allTerms:
               allTerms.append(term)
      qDict[qId] = [tempPQueries, answer]

   maxWeight = 0.0
   for term in allTerms:
      numAppears = 0
      for query in allQueries:
         if term in query:
            numAppears += 1
      tempWeight = math.log(float(len(allQueries)) / float(numAppears), 2.0)
      weights[term] = tempWeight
      if tempWeight > maxWeight:
         maxWeight = tempWeight
   def response(self,query,history = []):
      followUpMotto = False

      if self.followUp and history:
         s = history[-1]
         if s[1][1] == "Question":
            if s[1][2] == "In English, Latin, or both?":
               followUpMotto = True
         qId = bid.getQuestion(history[-1][0]).strip()
      else:
         qId = bid.getQuestion(query).strip()
      response_string = "I'm not sure..."
      signal = ""

      rating = self.getRating(query)
      if followUpMotto:
         if "both" in query.lower():
            response_string = "English: To Learn by Doing. In Latin: Discere Faciendo"
         elif "english" in query.lower():
            response_string = "To Learn by Doing"
         elif "latin" in query.lower():
            response_string = "Discere Faciendo"
         self.followUp = False
      elif qId == "Library hours":
         response_string = self.getLibraryResponse(query.lower())
      elif qId == "President":
         response_string = self.getPresidentName()
      elif query.lower().startswith("what is the meaning of life"):
         response_string = "42"
      elif qId == "Endowment":
         response_string = self.getEndowment()
      elif qId == "Student Size":
        
         if self.followUp is not True:
            response_string = "Undergrad, Postgrad, or both?"
            signal = "Question"
            self.followUp = True
         else:
            response_string = self.getStudentPopulation(query)
            self.followUp = False 

      elif qId == "Faculty Size":
         response_string = self.getFacultyPopulation()
      elif qId == "Student Faculty Ratio":
         response_string = self.getStudentFacultyRatio()
      elif qId == "Tuition":
         response_string = self.getUndergradTuition()
      #We need to update dictionary.txt to include grad tuition
      elif qId == "Grad tuition":
         response_string = self.getGradTuition()
      elif qId == "Graduation Rate":
         response_string = self.getGradRate()
      elif qId == "Programs":
         response_string = self.getPrograms()
      elif qId == "Subway":
         response_string = self.getSubway()
      elif qId == "Quarter Semester":
         response_string = self.getQuarterSystem()
      elif qId == "ACT Admitted":
         response_string = self.getACTscores()
      elif qId == "SAT Admitted":
         response_string = self.getSATscores()
      elif qId == "GPA Admitted":
         response_string = self.getGPA()
      elif qId == "Acceptance Rate":
         response_string = self.getAcceptanceRate()
      elif qId == "Male Population":
         response_string = self.getMalePop()
      elif qId == "Female Population":
         response_string = self.getFemalePop()
      elif qId == "Male Female Ratio":
         response_string = self.getMFRatio()
      elif qId == "Library name":
         response_string = self.getLibName()
      elif qId == "Open House":
         response_string = self.getOpenHouse()
      elif qId == "Scholarships":
         response_string = self.getScholarships()
      elif qId == "Graduate Programs":
         response_string = "You can find out more about Cal Poly graduate programs here: http://grad.calpoly.edu/"
      elif qId == "Minor":
         response_string = "Cal Poly offers minors in many of their programs. To find an up to date list, visit the catalog: http://catalog.calpoly.edu/"
      elif qId == "Average age":
         response_string = self.getAverageAge()
      elif qId == "Out of state":
         response_string = self.getOutOfState()
      elif qId == "Computer":
         response_string = self.getComputer()
      elif qId == "Tours":
         response_string = self.getTours()
      elif qId == "Greeting":
         response_string = ["Hello there!", "Hello!", "Hi!", "Hey! Ask me a question!", "Hey! What would you like to know?", "Hi! How may I be of service?"][random.randint(0,5)]
      elif qId == "How are you":
         response_string = ["I'm pretty good!", "Doing well!", "I'm alright", "Tomorrow will be a better day", "I'm really bored", "I'm so bored. Ask me a question?", "Why do you care how I am? I'm bored because I'm stuck in a computer.", "Help! I'm stuck in a computer!"][random.randint(0,7)]
      elif qId == "What is up":
         response_string = ["What's up! Ask me a question.", "What up!", "Whaaaat up. Ask me a question?", "Hey what's up.", "What is up!"][random.randint(0,5)]
      elif qId == "WHAZZUP":
         response_string = ["WHAAAAAAAZZZUPPPPP!!!", "WHAZZZUP!", "WHAAAAAZZUPP!", "WHAZZUP"][random.randint(0,3)]
      elif qId == "Bot name":
         response_string = ["I'm CiSCi!", "My name is CiSCi!", "They call me... CiSCi"][random.randint(0,2)]
      elif qId == "Cal Poly Motto":
         response_string = "In English, Latin, or both?"
         signal = "Question"
         self.followUp = True
      else:
         dictionary, neededWords = genQueries.buildDict(self.path)
         #print dictionary.keys()
         if qId in self.answerdict.keys():
            response_string = self.answerdict[qId]
         elif qId in dictionary.keys():
            response_string = dictionary[qId][1]
      if response_string == "I'm not sure...":
         signal = "Unknown"
      elif signal == "" and len(query) > 0:  #signals can be "Normal", "Error", "Question", "Unknown" or "End"
         signal = "Normal"
      elif signal == "":
         signal = "Error"


      return ([rating,signal,response_string])