예제 #1
0
 def performPrediction(self, tree, model_count_title,
                       model_count_description, count_vectorizer_title,
                       count_vectorizer_description):
     """
         Data Simulation Option loop
         Ask the user which action he/she wants to take, initialize model construction and perform prediction if required
         The loop is break (and the program ends) whenever the user types quit.
     """
     try:
         userInput = ""
         while userInput != "quit":
             self.printPredictionOptions()
             userInput = raw_input("\nPlease provide the input : ")
             if userInput == "1":
                 print "\nNow please go on YoutTube, chose the video of your choice, and enter the title and the description of that video (for more information, please read the README file)"
                 time.sleep(1.5)
                 title = raw_input(
                     "\nPlease provide the title of your video (as one single line) : "
                 )
                 description = raw_input(
                     "\nPlease provide the description of the video (as one single line) : "
                 )
                 video = Video(title, description)
                 predicted_category_value = video.predictVideoCategory(
                     tree, model_count_title, model_count_description,
                     count_vectorizer_title, count_vectorizer_description)
                 predicted_category_name = self.dataexplorer.Catagory_mapping[
                     predicted_category_value]
                 print "\nMy prediction is that your video is a {} video".format(
                     predicted_category_name)
                 time.sleep(3)
             elif userInput == "4":
                 self.InitiateFlow()
             elif userInput == "quit":
                 self.ExitProgram()
             else:
                 print "\nOops...Incorrect Input...Please enter correct Input !!!\n"
                 self.performPrediction(tree, model_count_title,
                                        model_count_description,
                                        count_vectorizer_title,
                                        count_vectorizer_description)
     except KeyboardInterrupt:
         print "quitting..."
         sys.exit()