def main():
    chatbot = Chatbot()
    while True:
        file = open("view.txt", "w")
        MyEncoder().encode(chatbot)
        file.write(json.dumps(chatbot, cls=MyEncoder, indent=4))
        file.close()

        file = open("AnswerList.txt", "w")
        i = 0
        for answer in chatbot.memory.actions:
            file.write(str(i) + ". " + answer + "\n")
            i = i + 1
        file.close()

        timestamp = time.strftime('%d %b %H:%M:%S', time.localtime())
        question = input(timestamp + "\tYou: ")
        if question == 'E':
            break
        elif question == 'I':
            filename = input("Please input the filename: ")
            chatbot.import_file(filename)
        elif question == 'X':
            filepath = input("Please input the path")
            filepath += "history.csv"
            chatbot.export_history(filepath)
        else:
            answer, outtime = chatbot.chat(question, timestamp)
            print(outtime + "\tChatbot: " + answer)
            #print("I am safe: ", chatbot.workMemory.action)
            while True:
                operation = input("Your operation: ")
                if operation == 'E' or operation == 'e':
                    #print("I am safe: ", chatbot.workMemory.action)
                    print("\n\n")
                    break
                if operation == 'C' or operation == 'c':
                    change = input("New answer: ")
                    chatbot.change(change)
                if operation == 'L' or operation == 'l':
                    chatbot.like()
                if operation == 'A' or operation == 'a':
                    print(chatbot.analysis())
        #print("I am safe: ", chatbot.workMemory.action)
        patternAnswer(chatbot)