def m_button1OnButtonClick(self, event):
        answers.append('yes')
        global step
        step = step + 1
        self.parent.status.gauge.SetValue(10 * step)

        if step == len(questions):
            createStepGlobal(step)
            clips.BuildGlobal('ten_answer', 1)
            clips.Run()
            changePanel(self.parent, 6)

        else:
            createStepGlobal(step)
            self.m_staticText1.SetLabel(questions[step])
            # 1 == YES  0 == NO
            if step == 1:
                clips.BuildGlobal('one_answer', 1)
            elif step == 9:
                clips.BuildGlobal('nine_answer', 1)

            if step == 1 and answers[0] == 'yes':
                step = step + 1
                answers.append('NULL')
                changePanel(self.parent, 1)
    def m_button1OnButtonClick(self, event):

        global step
        step = step + 1
        self.parent.status.gauge.SetValue(10 * step)
        answer = self.m_choice1.GetStringSelection().split('.')[0]
        answers.append(answer)
        createStepGlobal(step)

        if step == 3:
            self.parent.panelTwo.m_choice1.SetItems(selections[1])
            self.parent.panelTwo.m_staticText1.SetLabel(questions[step])
            clips.BuildGlobal('three_answer', answer)
        elif step == 4:
            self.parent.panelTwo.m_choice1.SetItems(selections[2])
            self.parent.panelTwo.m_staticText1.SetLabel(questions[step])
            clips.BuildGlobal('four_answer', answer)
        elif step == 5:
            clips.BuildGlobal('five_answer', answer)
            changePanel(self.parent, 4)
    def m_button2OnButtonClick(self, event):
        global step
        step = step + 1
        self.parent.status.gauge.SetValue(10 * step)
        if step == len(questions):
            createStepGlobal(step)
            clips.BuildGlobal('ten_answer', 0)
            clips.Run()
            changePanel(self.parent, 6)
        else:
            createStepGlobal(step)
            self.m_staticText1.SetLabel(questions[step])
            answers.append('no')

            if step == 1 and answers[0] == 'no':
                clips.Assert("(YN_second)")
                changePanel(self.parent, 2)
            if step == 1:
                clips.BuildGlobal('one_answer', 0)
            elif step == 9:
                clips.BuildGlobal('nine_answer', 0)
    def m_button1OnButtonClick(self, event):
        if self.flag[0] == 1 or self.flag[1] == 1:
            answer = self.flag.index(1) + 1
            answers.append(answer)
            global step
            step = step + 1
            createStepGlobal(step)
            self.flag[0] = 0
            self.flag[1] = 0
            self.parent.status.gauge.SetValue(10 * step)
            if step == 6:
                self.m_staticText6.SetLabel(questions[step])
                self.m_bpButton1.SetBitmap(
                    wx.Image(self.pics[self.picIndex[1][0]],
                             wx.BITMAP_TYPE_ANY).ConvertToBitmap())
                self.m_bpButton2.SetBitmap(
                    wx.Image(self.pics[self.picIndex[1][1]],
                             wx.BITMAP_TYPE_ANY).ConvertToBitmap())
                clips.BuildGlobal('six_answer', answer)

            elif step == 7:
                self.m_staticText6.SetLabel(questions[step])
                self.m_bpButton1.SetBitmap(
                    wx.Image(self.pics[self.picIndex[2][0]],
                             wx.BITMAP_TYPE_ANY).ConvertToBitmap())
                self.m_bpButton2.SetBitmap(
                    wx.Image(self.pics[self.picIndex[2][1]],
                             wx.BITMAP_TYPE_ANY).ConvertToBitmap())
                clips.BuildGlobal('seven_answer', answer)
            elif step == 8:
                clips.BuildGlobal('eight_answer', answer)
                changePanel(self.parent, 5)
        else:
            dlg = wx.MessageDialog(None, "Please click one picture", "",
                                   wx.OK | wx.ICON_QUESTION)
            if dlg.ShowModal() == wx.ID_YES:
                self.Close(True)
                dlg.Destroy()
    def __init__(self, parent):
        clips.Load('try.clp')
        clips.Reset()
        clips.BuildGlobal('religion', parent.religion)
        clips.BuildGlobal('sex', parent.sex)
        clips.BuildGlobal('age', parent.age)
        self.parent = parent
        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          title=wx.EmptyString,
                          pos=wx.DefaultPosition,
                          size=wx.Size(600, 350),
                          style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
        self.status = customStatusBar(self)
        self.SetStatusBar(self.status)
        self.panelOne = Panel_YESorNO(self)
        bsizer = wx.BoxSizer(wx.VERTICAL)
        bsizer.Add(self.panelOne, 1, wx.EXPAND)
        self.SetSizer(bsizer)
        self.Layout()

        self.Centre(wx.BOTH)
    def m_button1OnButtonClick(self, event):
        global step
        step = step + 1
        self.parent.status.gauge.SetValue(10 * step)
        createStepGlobal(step)

        answer = [
            str(self.flag[0]),
            str(self.flag[1]),
            str(self.flag[2]),
            str(self.flag[3]),
            str(self.flag[4]),
            str(self.flag[5])
        ]
        answers.append(answer)
        clips.BuildGlobal('two_answer1', answer[0])
        clips.BuildGlobal('two_answer2', answer[1])
        clips.BuildGlobal('two_answer3', answer[2])
        clips.BuildGlobal('two_answer4', answer[3])
        clips.BuildGlobal('two_answer5', answer[4])
        clips.BuildGlobal('two_answer6', answer[5])
        changePanel(self.parent, 3)
# Function to convert user question into clips form
def parse_input_to_string():
	user_input = raw_input("Enter your question : ")
	words_list = user_input.lower().split()
	final_string = ""
	for word in words_list :
		final_string += '"' + word +'"' 
	return final_string 
# importing clips library
import clips
# get input from user and store it in a variable called user_input
user_input = parse_input_to_string();
# build a global variable using clips library called Final_answer to store final answer inside it
Final_answer = clips.BuildGlobal('Final_answer','sorry, i have no answers for you at this moment.')
# load clips file 
clips.BatchStar("algorithm.clp")
# reset clips environment 
clips.Reset()
# add new fact using assert with user inputs
clips.Assert('(User_input'+user_input+')')
# run the program
clips.Run()
# print out the final answer
print "Phronesis said : " + Final_answer.Value
# t = clips.StdoutStream.Read()
# print t