Exemple #1
0
def intro():
    print("hello!")
    print("Welcome to A Naruto Adventure")
    name = input("What is your name?")
    #add kun to end of name
    print("Cool! Your Ninja Name is", name + "-kun")
    enteredNum = int(input("type 1 if you are ready to start: "))
    if enteredNum == 1:
        print("Lets Begin! **SPOILERS AHEAD**")
    else:
        print("You must enter 1 to start")
        enteredNum = int(input("type 1 if you are ready to start: "))
    quesListLevel1 = [
        "What clan is Naruto in?\n(a) Sarutobi\n(b) Uzumaki\n(c) Uchiha\n\n",
        "What clan is Sasuke in?\n(a) Sarutobi\n(b) Uzumaki\n(c) Uchiha\n\n",
        "What clan is Itachi in?\n(a) Sarutobi\n(b) Uzumaki\n(c) Uchiha\n\n",
        "What village does Naruto live in?\n(a) Hidden Leaf\n(b) Hidden Sand\n(c) Hidden Sound\n\n"
    ]

    q1 = Question.Question(quesListLevel1[0], "b")
    q2 = Question.Question(quesListLevel1[1], "c")
    q3 = Question.Question(quesListLevel1[2], "c")
    q4 = Question.Question(quesListLevel1[3], "a")
    questions = [q1, q2, q3, q4]
    print(questions[0].prompt)
    print(questions[0].answer)
    print(questions[1].prompt)
    print(questions[2].prompt)
    print(questions[3].prompt)
Exemple #2
0
def onClick_question():
    now = str(datetime.datetime.now())
    # 현재 날짜를 숫자화한것
    now_int = int(now[0:4]) * 365 + int(now[5:7]) * 30 + int(now[8:10])

    # 어디까지 질문이 나갔는지
    cursor1 = conn.cursor()
    sql1 = f"select max(id) from member"
    cursor1.execute(sql1)
    number = cursor1.fetchone()[0]

    # 가장 마지막 질문 날짜 구함
    cursor2 = conn.cursor()
    sql2 = f"select date from diaryme.member where id = {number}"
    cursor2.execute(sql2)
    date = cursor2.fetchone()[0]
    short_date = str(date)[0:10]

    conn.close()

    # 마지막 질문 날짜를 숫자화 한것
    short_date_int = int(short_date[0:4]) * 365 + int(
        short_date[5:7]) * 30 + int(short_date[8:10])

    # 오늘이 마지막 질문 날짜보다 많으면(24시간이 지났으면)
    if now_int > short_date_int:
        Question.main()
    else:
        tkinter.messagebox.showinfo(
            "Diary Me",
            "Diary Me의 질문들은 하루에 한 번씩 제공됩니다.\n" + f"마지막 답변 일시는 {date} 이에요. \n"
            f"조금만 기다려주세요 :) ♡")
Exemple #3
0
	def test_was_published_recently_with_future_question(self):
		"""
		was_published_recently() should return False for questions whose
		pub_date is in the future.
		"""
		time = timezone.now() + datetime.timedelta(days=30)
		future_question = Question(pub_date=time)
		self.assertIs(future_question.was_published_recently(), False)
def SetQuestion():
    for i in range(10):
        ques = Question('', '', '', '', '', '')
        print(i + 1, end=':')
        ques.Set_Problem()
        ques.Set_Answers()
        ques.Set_Correct()
        Trivia.append(ques)
Exemple #5
0
	def test_was_published_recently_with_recent_question(self):
		"""
		was_published_recently() should return True for questions whose
		pub_date is within the last day.
		"""
		time = timezone.now() - datetime.timedelta(hours=1)
		recent_question = Question(pub_date=time)
		self.assertIs(recent_question.was_published_recently(), True)
Exemple #6
0
 def testGetListOfQuestions(self):
     questionA = Question.Question("25306175", "MCQ", "What is 13 + 13",
                                   "26", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     questionB = Question.Question("21111111", "MCQ", "What is 13 + 14",
                                   "27", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     listOfQ = [questionA, questionB]
     ass1 = Assignment.Assignment("123", listOfQ)
     self.assertTrue(ass1.getListOfQuestions() == listOfQ)
Exemple #7
0
 def testCheckIfPerfectTrue(self):
     questionC = Question.Question("33333333", "MCQ", "What is 22 + 33",
                                   "55", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     questionD = Question.Question("44444444", "MCQ", "What is 33 + 44",
                                   "77", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     listOfQ = [questionC, questionD]
     ass1 = Assignment.Assignment("123", listOfQ)
     self.assertFalse(ass1.checkIfPerfect())
Exemple #8
0
 def testSetVisibilityFalse(self):
     questionC = Question.Question("33333333", "MCQ", "What is 22 + 33",
                                   "55", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     questionD = Question.Question("44444444", "MCQ", "What is 33 + 44",
                                   "77", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     listOfQ = [questionC, questionD]
     ass1 = Assignment.Assignment("123", listOfQ)
     self.assertFalse(ass1.getVisibility())
Exemple #9
0
 def testGetNameNone(self):
     questionC = Question.Question("33333333", "MCQ", "What is 22 + 33",
                                   "55", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     questionD = Question.Question("44444444", "MCQ", "What is 33 + 44",
                                   "77", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     listOfQ = [questionC, questionD]
     ass1 = Assignment.Assignment("123", listOfQ)
     self.assertTrue(ass1.getName() == None)
Exemple #10
0
def main():
    # define questions
    question1 = Question.Question(
        "In What year did the game Super Meat Boy release?", "A: 2009",
        "B: 2010", "C: 2011", "D: 2012", "B")
    question2 = Question.Question(
        "In What year did the game StarCraft 2 release?", "A: 2007", "B: 2008",
        "C: 2009", "D: 2010", "D")
    question3 = Question.Question(
        "In What year did the game Minecraft initially release?", "A: 2007",
        "B: 2008", "C: 2009", "D: 2010", "C")
    question4 = Question.Question(
        "In What year did the game Overwatch release?", "A: 2016", "B: 2008",
        "C: 1999", "D: 2001", "A")
    question5 = Question.Question(
        "Which of these characters is NOT in the game Halo3?",
        "A: Master Chief", "B: Cortana", "C: Tonnika", "D: The Arbiter", "C")
    question6 = Question.Question(
        "Which of these characters is NOT in the game Overwatch?", "A: Pharah",
        "B: Nazeebo", "C: Roadhog", "D: Genji", "B")
    question7 = Question.Question(
        "Which video game shooter franchise introduced the Iron Sight mechanic?",
        "A: Half-Life", "B: Team Fortress", "C: Call of Duty", "D: Halo", "C")
    question8 = Question.Question(
        "Which video game shooter franchise did away with a health bar mechanic?",
        "A: Half-Life", "B: Team Fortress", "C: Call of Duty", "D: Halo", "C")
    question9 = Question.Question(
        "What is the most sold video game of all time?", "A: TETRIS",
        "B: GTA V", "C: Super Mario Bros", "D: PUBG", "A")
    question10 = Question.Question(
        "What is the second most sold video game of all time?",
        "A: Wii Sports", "B: Minecraft", "C: Overwatch", "D: TES V: Skyrim",
        "B")

    # place questions into two tuples
    set1 = [question1, question3, question5, question7, question9]
    set2 = [question2, question4, question6, question8, question10]

    # play game
    print("\nPlayer 1's turn!\n")
    player1_points = game_round(set1)
    print("\bPlayer 2's turn!\n")
    player2_points = game_round(set2)

    # print out the winner
    print("Player 1 earned " + str(player1_points) + " points!")
    print("Player 2 earned " + str(player2_points) + " points!")

    if player1_points == player2_points:
        print("The game was a tie!")
    elif player1_points > player2_points:
        print("Player 1 is the winner!")
    else:
        print("Player 2 is the winner!")
Exemple #11
0
    def readReportFile(self, fileName, usedPolls):
        number = 0
        with open(fileName, 'r', encoding='utf-8') as file:
            reader = csv.reader(file)
            poll1 = Poll("poll1", [], [])
            for row in reader:
                questions = []
                for i in range(4, len(row) - 1):
                    if i % 2 == 0:
                        # Create a question and add the answer
                        question = Question("".join(row[i].splitlines()))
                        question.setAnswer(row[i + 1])
                        questions.append(question)
                        poll1.questions.append(question)

                # find which student, and which poll then create that poll and add the student's polls
                for student in self.students:
                    if student.checkStudent(row[1]):
                        for poll in self.allPolls:
                            if poll.checkPoll(questions):

                                if poll.answerKeys[0].used == False:
                                    temp_poll = Poll(poll.pollName,
                                                     poll.answerKeys,
                                                     poll.questions)
                                    usedPolls.append(temp_poll)
                                count = 0
                                for poll in usedPolls:
                                    if poll.pollName == usedPolls[
                                            len(usedPolls) - 1].pollName:
                                        count = count + 1
                                if poll.answerKeys[0].used == False:
                                    if count > 1:
                                        usedPolls[
                                            len(usedPolls) -
                                            1].pollName = usedPolls[
                                                len(usedPolls) -
                                                1].pollName + "-" + str(count)
                                poll.answerKeys[0].used = True

                                number = number + 1
                                temp = Poll(temp_poll.pollName,
                                            temp_poll.answerKeys,
                                            temp_poll.questions)
                                temp.questions = poll1.questions
                                temp.setDate(row[3])
                                student.addPoll(temp)

                poll1.questions = []
            for poll in self.allPolls:
                poll.answerKeys[0].used = False
Exemple #12
0
    def testSetStudentAnswerAtIndex(self):
        questionA = Question.Question("25306175", "MCQ", "What is 13 + 13",
                                      "26", "1", "Unit 1 Test", "01-Nov-17",
                                      "1", "1")
        questionB = Question.Question("21111111", "MCQ", "What is 13 + 14",
                                      "27", "1", "Unit 1 Test", "01-Nov-17",
                                      "1", "1")
        listOfQ = [questionA, questionB]
        ass1 = Assignment.Assignment("123", listOfQ)

        studentAnswer = 27
        ass1.setStudentAnswerAtIndex(1, studentAnswer)

        self.assertTrue(questionB.getStudentAnswer() == studentAnswer)
Exemple #13
0
def select_section() -> None:
    """Ask the user if they would like to focus on a certain section, if yes, pick the section.

    Raises:
        ValueError: The course must be initialized to select a section (sub-property)
    """
    global course, section
    if not course:
        raise ValueError("course has not been initialized")

    if Question.askYn("Would you like to filter by section?"):
        sections: List[Dict[Any,
                            Any]] = Sections.get_all_sections(course["id"])
        section = Question.select_option(sections, "section")
Exemple #14
0
 def __init__(self, filePath):
     with open(filePath, "r") as myfile:
         lines = myfile.readlines()
         ql = []
         self.questions = []
         for l in lines:
             if l.startswith("QUESTION"):
                 if len(ql) > 0:
                     self.questions.append(Question.Question(ql))
                     ql = []
             else:
                 ql.append(l)
         if len(ql) > 0:
             self.questions.append(Question.Question(ql))
             ql = []
Exemple #15
0
 def testInit(self):
     questionA = Question.Question("25306175", "MCQ", "What is 13 + 13",
                                   "26", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     questionB = Question.Question("25301111", "MCQ", "What is 56 - 26",
                                   "30", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     listOfQ = [questionA, questionB]
     myAssignment = Assignment.Assignment("123", listOfQ)
     initSuccess = ((len(myAssignment.getAssignmentId()) == 3)
                    and (myAssignment.getVisibility() == False)
                    and (myAssignment.getDeadline() == None)
                    and (myAssignment.getName() == None)
                    and myAssignment.getListOfQuestions() == listOfQ)
     self.assertTrue(initSuccess)
def question_UI(question = None):
    if question == None:
        question = Question.Question("", Checkbox.Checkbox())

    answer_layout = Answer_UI(question.get_answer())

    question_layout = QVBoxLayout()

    question_text = QLineEdit()
    question_text.setPlaceholderText('[Enter Question Text]')
    question_text.setText(question.get_question_text())
    question_text.setMaximumWidth(725)
    question_text.setMaximumHeight(50)
    question_text.textChanged.connect(question.set_question_text)

    dropdown = QComboBox()
    dropdown.setMaximumWidth(110)
    dropdown.addItem("Checkbox")
    dropdown.addItem("Dropdown")
    dropdown.addItem("Toggle")
    if question.Answer.get_Answer_Type() == 'Checkbox':
        dropdown.setCurrentIndex(0)
    elif question.Answer.get_Answer_Type() == 'Dropdown':
        dropdown.setCurrentIndex(1)
    elif question.Answer.get_Answer_Type() == 'Toggle':
        dropdown.setCurrentIndex(2)
    else:
        print('error invalid answer type')
    dropdown.currentIndexChanged.connect(lambda type: change_answer_type(type, question, answer_layout))

    question_layout.addWidget(question_text)
    question_layout.addWidget(dropdown)
    question_layout.addLayout(answer_layout)

    return question_layout
Exemple #17
0
    def load(self, x, y):
        try:
            a = open("qcm/" + x + "/" + y + ".txt")
            file_lines = a.readlines()
            a.close()

            #verification fichier
            old = ""
            bloc_size = 0
            for line in file_lines:
                line = line.strip()
                if line == "":
                    if bloc_size < 4:
                        print "<4"
                        raise Exception
                    bloc_size = 0
                else:
                    bloc_size += 1
                old = line
            #end

            #questions loading
            for codec in ["utf-8", "ISO-8859-15", "utf-16", ""]:
                try:
                    blocs = Question().extract(file_lines)
                    self.qcm[x][y] = self.loader(blocs)
                    break
                except:
                    pass
            print y, " loaded correctly"
            return True
        except Exception, e:
            print "loading error : " + x + "/" + y + "\n" + str(e) + "\n"
            return False
Exemple #18
0
def want_continue_previous_session() -> bool:
    """Ask the user if they would like to continue an existing session (don't re-prompt for course, section, assignment).

    Returns:
        bool: What the user wants: Yes: True...
    """
    return Question.askyN("Would you like to continue the previous session?")
Exemple #19
0
 def checkAnswer(self, Question, filterKeyword, checkBoxState):
     if (filterKeyword in Question.ShowAnswer()):
         if (not checkBoxState):
             #                checkBox.toggle()
             #                checkBox.setStyleSheet("color: red")
             return False
         elif (checkBoxState):
             #                checkBox.setStyleSheet("color: green")
             return True
     if (filterKeyword not in Question.ShowAnswer()):
         if (not checkBoxState):
             Question.IsRight()
             return True
         elif (checkBoxState):
             #                 checkBox.toggle()
             return False
Exemple #20
0
 def CreateFillInAnswerQuestion(self, question):
     layout = QFormLayout()
     if (type(question).__name__ == 'Question'
             and question.getQuestionType() == 'Fill'):
         tmp = FillTheWord(question)
         layout.addRow(tmp)
     return layout
Exemple #21
0
    def parse(txt):
        questions = {}
        data = None

        with open(MARKING_SCHEME, "r") as f:
            data = f.read()

        total = re.findall(r"Total: \[\/(\d+)\]", data)
        if total:
            total = int(total[0])

        data = data.split("\n\n")

        for q in data:
            name = q.split(":")[0]
            if "Total" in name:
                continue

            num = "".join(re.findall(r'\d+', name))

            filename = f"a{ASSIGNMENT_NUM}_p{num}.py" if num else name
            if filename not in TEST_CASES:
                TEST_CASES[filename] = False

            question = Question(q.split("\n"), filename, TEST_CASES[filename])
            questions[question.file] = question
        return questions, total
Exemple #22
0
 def CreateTrueFalseQuestion(self, question):
     layout = QFormLayout()
     if (type(question).__name__ == 'Question'
             and question.getQuestionType() == 'TrueFalse'):
         tmp = TrueFalse(question)
         layout.addRow(tmp)
     return layout
Exemple #23
0
 def CreateMultipleChoiceQuestion(self, question):
     layout = QFormLayout()
     if (type(question).__name__ == 'Question'
             and question.getQuestionType() == 'MultipleChoice'):
         tmp = MultipleChoice(question)
         layout.addRow(tmp)
     return layout
def add_question_UI(question_list, question=None):
    if question == None:
        question = Question.Question("", Checkbox.Checkbox())

    question_list.add_obj(question)

    return inalize_question_UI(question_list, question)
Exemple #25
0
    def play(self):
        print('--- start game ---')
        my_quest = Question()

        chance = 3
        score = 0
        while chance > 0:
            if my_quest.add_dic_to_question():
                score = score + 1
            else:
                chance = chance - 1
            print('--- chance: ', chance, ', score: ', score, ' ---\n')

        print('--------------------')
        print('| FINAL SCORE : ', score, '|')
        print('--------------------')
    def m_button1OnButtonClick(self, event):
        self.sex = self.m_choice2.GetStringSelection()
        self.age = self.m_choice3.GetStringSelection()
        self.religion = self.m_choice1.GetStringSelection()

        Question.QuestionPage(self).Show()
        self.Hide()
 def findBestSplit(self, rows):
     bestInfoGain = 0
     bestQuestion = None
     # parentCurrentGiniUncertainty - childrenWeightedAvgGiniUncertainty = infogain
     currentGiniUncertainty = self.giniImpurity(rows)
     # 0,1,2,3...13
     for colIndex in range(self.columns):
         # this is the label vector dont want to split on this or we get no uncertainty
         if colIndex == 1:
             continue
         # get all unique column values at current colIndex
         uniqueVals = set([row[colIndex] for row in rows])
         for uniqueVal in uniqueVals:
             quest = qst.Question(colIndex, uniqueVal, self.header)
             trueRows, falseRows = self.partition(rows, quest)
             # if this occurs then the column value we used to split on was probably shit or it has reached a leaf node
             if len(trueRows) == 0 or len(falseRows) == 0:
                 continue
             trueGini = self.giniImpurity(trueRows)
             falseGini = self.giniImpurity(falseRows)
             trueWeightedRatio = len(trueRows) / (len(trueRows) +
                                                  len(falseRows))
             falseWeightedRation = 1 - trueWeightedRatio
             # currentGiniUncertainty - weightedAvgGiniUncertainty = infogain
             infoGain = currentGiniUncertainty - (
                 trueWeightedRatio * trueGini +
                 falseWeightedRation * falseGini)
             if infoGain > bestInfoGain:
                 bestInfoGain = infoGain
                 bestQuestion = quest
     return bestInfoGain, bestQuestion
Exemple #28
0
 def parse(self, filename):
     question_block = False
     answer_block = False
     explain_block = False
     with open(filename[:-5] + '_processed.txt') as openfileobject:
         # set our variable for the question
         q_number = None
         q_question = ""
         q_options = []
         q_answer = None
         q_explain = ""
         for line in openfileobject:
             # line.split('\n')
             # print(line)
             # if only a new line then skip it
             if (line == "\n"):
                 continue
             if (not question_block and "QUESTION" in line):
                 question_block = True
                 q_number = line
                 self.total_questions = self.total_questions + 1
                 # skip to next line to check for its properties
                 continue
             # if found next qustion then get each propertiy and add them
             if (question_block):
                 #keep adding lines until we reach the end
                 if ("?") in line:
                     question_block = False
                     answer_block = True
                 q_question = q_question + line
                 continue
             if (answer_block):
                 if ("A. " in line or "B. " in line or "C. " in line
                         or "D. " in line):
                     line = line[:-1]
                     q_options.append(line)
                     continue
                 if ("Correct Answer:") in line:
                     q_answer = line
                     answer_block = False
                     explain_block = True
                     continue
             if (explain_block):
                 if ("Reference" not in line):
                     q_explain = q_explain + line
                     continue
                 else:
                     explain_block = False
                     # Add everything into one question
                     new_question = Question.Question(
                         q_number, q_question, q_options, q_answer,
                         q_explain)
                     self.addToTest(new_question)
                     # Reset our question
                     q_number = None
                     q_question = ""
                     q_options = []
                     q_answer = None
                     q_explain = ""
Exemple #29
0
def loadQuestions(directory="../data/train/"):
    files = getRecursiveFiles(
        directory, lambda x: x[x.rfind("/") + 1] != "." and ".txt" in x and x[
            -1] != '~' and "norvig" not in x.lower())
    return [
        Question(text) for filename in files
        for text in readFile(filename).split("\n\n")
    ]
Exemple #30
0
 def testSetDeadline(self):
     deadline = "17-Apr-17"
     questionA = Question.Question("25306175", "MCQ", "What is 13 + 13",
                                   "26", "1", "Unit 1 Test", "01-Nov-17",
                                   "1", "1")
     ass1 = Assignment.Assignment("123", [questionA])
     ass1.setDeadline(deadline)
     self.assertTrue(ass1.getDeadline() == deadline)
Exemple #31
0
def buildQueries():
    stopWords = Question.STOP_WORDS
    questions = getQuestions()
    fullQuestions = []
    for i in range(len(questions)):
        num, q = questions[i]
        kw = Question.getKeyWords(q, stopWords)
        kwString = " ".join(kw)
        fullQuestions.append((num, q+" "+kwString))
    """
    for (num, q) in questions:
        synset = buildSynset(q, hyponyms=False)
        synString = " ".join(synset)
        fullQuestions.append((num, q+" "+synString))
    """
    return fullQuestions    
Exemple #32
0
    def create_update_question(self):
        global db_timer
        if not self.user:
            self.redirect('/')

	ukey = self.user.key
        question = self.request.get('question').strip()
        question = question if question[-1:] == '?' else question+'?'
        
        #logging.error('NewQuestion.post question:'+question)
        #### form the url###
        new_question = re.sub('[^a-zA-Z0-9\n\.]', ' ', question)
	new_question = new_question[:-1]+'?'
        qurl = 'qs/'+new_question.replace(' ','-')
        
        logging.error('NewQuestion.post qurl:'+qurl)

        path = self.request.path
	isEdit = True if path[:6] == '/_edit' else False
	path = path[6:]+'?' if isEdit else path+'?'
	
	logging.error('NewQuestion.post path:'+path)
	logging.error(isEdit)
        if question:
	    qq = Question.getQuestionByPath(path)
	    logging.error(qq.count())
	    if qq and qq.count()>0:
	    	q = qq.fetch()[0]
	    	q.last_updated_by = ukey
	    else:
	    	q = Question()
	    	q.added_by = ukey
	    	
            q.question = question
            q.qurl = '/'+qurl
            
            q = q.put()
            search.Index(name=_Q_INDEX_NAME).add(CreateDocument(str(q.id()), question))

            self.redirect('/%s' % qurl)
            
        else:
            error = "question, please!"
            self.render("question.html", q=question, error=error)
def readQuestionsFile(storyId):
    questionFile = open(directoryName.replace("\\", "/") + "/" + storyId + ".questions", "r")
    readQuestions = []
    while True:
        ques = Question()
        # Question Id of the question
        questionId = questionFile.readline()
        if not questionId: break
        colonIndex = questionId.index(":")
        ques.quesId = questionId[colonIndex + 2:]
        # print(ques.quesId)
        # Question of the question
        question = questionFile.readline()
        colonIndex = question.index(":")
        ques.ques = question[colonIndex + 2:]
        # print(ques.ques)
        # Question Type of the question
        questionText = question[colonIndex + 2:]
        questionText = questionText.replace(",", "")
        questionText = questionText.replace(".", "")
        spaceIndex = questionText.index(" ")
        firstWord = questionText[0:spaceIndex]
        quesTypes = ['why', 'what', 'where', 'who', 'when', 'how']
        if firstWord.lower() in quesTypes:
            ques.quesType = firstWord.lower()
        else:
            for qtype in quesTypes:
                if qtype in ques.ques.lower():
                    ques.quesType = qtype
        # Question Difficulty of the question
        questionDiff = questionFile.readline()
        colonIndex = questionDiff.index(":")
        ques.difficulty = questionDiff[colonIndex + 2:]
        # print(ques.difficulty)
        questionFile.readline()
        readQuestions.append(ques)
    return readQuestions
Exemple #34
0
from Question import *

parser = argparse.ArgumentParser()
parser.add_argument("--key", metavar = "<Freebase API key>", type = str, nargs = 1)
parser.add_argument("-q",    metavar = "<query>",            type = str, nargs = "+")
parser.add_argument("-f",    metavar = "<file of queries>",  type = str, nargs = 1)
parser.add_argument("-t",    metavar = "<infobox|question>", type = str, nargs = 1)

args = parser.parse_args()

if args.key is None:
    parser.print_usage()
    sys.exit(2)

ib = Infobox(args.key[0])
que = Question(args.key[0])

if args.t is None:
    print "Welcome to infoxbox creator using Freebase knowledge graph"
    print "created by Qianxi Zhang (qz2204) and Qinfan Wu (qw2168)"
    print "Feel curious? Start exploring..."
    print ""
    while True:
        prompt = time.strftime("%H:%M:%S", time.localtime()) + "  " + os.getlogin() + "@" + socket.gethostname() + " > "
        query = raw_input(prompt)
        print "Let me see..."
        query = " ".join(query.lower().split())
        if re.match("who created .", query) is None:
            ib.search(query)
        else:
            que.ask(query, True)
Exemple #35
0
	def runScene(self):
		for i in self.instructions:
			spriteToMove = i[0]
			action = i[1]
			if action == "moveLeft":
				while spriteToMove.rect.left > i[2]:
					spriteToMove.rect.left -= 5
					spriteToMove.moveImage("left")
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveRight":
				while spriteToMove.rect.right < i[2]:
					spriteToMove.rect.right += 5
					spriteToMove.moveImage("right")
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveDown":
				while spriteToMove.rect.bottom < i[2]:
					spriteToMove.rect.bottom += 5
					spriteToMove.moveImage("down")
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveUp":
				while spriteToMove.rect.top > i[2]:
					spriteToMove.rect.top -=5
					spriteToMove.moveImage("up")
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveLeftTogether":
				while spriteToMove.rect.left > i[2]:
					for j in i[3]:
						j.rect.left -= 5
						j.moveImage("left")
					spriteToMove.moveImage("left")
					spriteToMove.rect.left -= 5
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveRightTogether":
				while spriteToMove.rect.right < i[2]:
					for j in i[3]:
						j.rect.right += 5
						j.moveImage("right")
					spriteToMove.moveImage("right")
					spriteToMove.rect.right += 5
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveDownTogether":
				while spriteToMove.rect.bottom < i[2]:
					for j in i[3]:
						j.rect.bottom += 5
						j.moveImage("down")
					spriteToMove.moveImage("down")
					spriteToMove.rect.bottom += 5
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "moveUpTogether":
				while spriteToMove.rect.top > i[2]:
					for j in i[3]:
						j.rect.top -= 5
						j.moveImage("up")
					spriteToMove.moveImage("up")
					spriteToMove.rect.top -=5
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
					fpsClock.tick(FPS)
			elif action == "turn":
					spriteToMove.moveImage(i[2])
					self.scene.drawBackground()
					self.mainSurface.blit(self.hero.image, self.hero.rect)
					self.scene.drawAll()
					pygame.display.update()
			elif action == "talk":
				talking = Dialogue(i[2])
				talking.runText(self.mainSurface, spriteToMove.rect.y)
			elif action == "question":
				question = Question(i[2],i[3],i[4])
				trigger = question.runQuestion(self.mainSurface, spriteToMove.rect.y)
				self.level.reaction(trigger)
			elif action == "leave":
				self.scene.remove(i[2])
				self.scene.drawBackground()
				self.mainSurface.blit(self.hero.image, self.hero.rect)
				self.scene.drawAll()
				pygame.display.update()
				fpsClock.tick(FPS)
			elif action == "murder":
				if i[2] == 1:
					weapon = pygame.image.load("swordUp.png")
					self.mainSurface.blit(weapon, (self.hero.rect.left, self.hero.rect.top - 50))
					pygame.display.update()
				elif i[2] == 2:
					weapon = pygame.image.load("swordRight.png")
					self.mainSurface.blit(weapon, (self.hero.rect.right, self.hero.rect.top))
					pygame.display.update()
				elif i[2] == 3:
					weapon = pygame.image.load("swordDown.png")
					self.mainSurface.blit(weapon, (self.hero.rect.right, self.hero.rect.bottom))
					pygame.display.update()
				elif i[2] == 4:
					weapon = pygame.image.load("swordLeft.png")
					self.mainSurface.blit(weapon, (self.hero.rect.left - 30, self.hero.rect.bottom - 8))
					pygame.display.update()
				pygame.time.wait(200)
Exemple #36
0
def buildQuery(question):
    stopWords = Question.STOP_WORDS
    return " ".join(Question.getKeyWords(question, stopWords))
from Question import *
import random
random.seed()

print ("This is the Italian Test!!\n")

Q1 = Question("What does this mean? 'Come si puo vivere con te stesso?'", "1. What do you want?", "2. How can you live with yourself?", "3. Are you okay?", "2")
Q2 = Question("How do you say 'SHUT UP'?", "1. Sta' Zitto", "2. Callar", "3. Silentu", "1")
Q3 = Question("What Language is this in? 'Ich bin genial'", "1. German", "2. Esperanto", "3. Russian", "1")
Q4 = Question("What does this mean? 'Ego sum angelus mortis'", "1. I am EPIC", "2. I can do anything", "3. I am the angel of death", "3")
Q5 = Question("How do you say 'ILIKEPIE' in LATIN?", "1. Ego quasi pastillus", "2. Ich mag pie", "3. Mi Sastas kukajo", "1")

QuestionInt = random.randint(0, 4)


Q1.ask()

QuestionInt = random.randint(0, 4)

if Q1.correct == 0:
	Q2.ask()
	
QuestionInt = random.randint(0, 4)
	
if Q2.correct == 0:
	Q3.ask()
	
QuestionInt = random.randint(0, 4)
	
if Q3.correct == 0:
	Q4.ask()