Exemplo n.º 1
0
    def _build_linked_list(self, value, tag):
        from question_interface import question_interface
        q = question_interface()
        temp = q

        while True:
            temp = self._assign_attributes(temp, value, tag)

            if value.has_key('linked_questions'):
                temp.linked_questions = question_interface()
                temp = temp.linked_questions
                value = value['linked_questions']
            else:
                break

        return q
Exemplo n.º 2
0
    def _build_linked_list(self, value, tag):
        from question_interface import question_interface
        q = question_interface()
        temp = q

        while True:
            temp = self._assign_attributes(temp, value, tag)

            if value.has_key('linked_questions'):
                temp.linked_questions = question_interface()
                temp = temp.linked_questions
                value = value['linked_questions']
            else:
                break

        return q
Exemplo n.º 3
0
 def create_question(self, question):
     q_obj = question_interface()
     q_obj = q_obj.return_question(question)
     # print bcolors.HEADER+q_obj.question
     # print q_obj.response
     # print bcolors.OKBLUE
     # print question
     self.last_asked_question = question
     return q_obj
Exemplo n.º 4
0
 def create_question(self, question):
     q_obj = question_interface()
     q_obj = q_obj.return_question(question)
     # print bcolors.HEADER+q_obj.question
     # print q_obj.response
     #print bcolors.OKBLUE
     # print question
     self.last_asked_question = question
     return q_obj
Exemplo n.º 5
0
 def __init__(self):
     self.db_object = db()
     self.top_questions = list()
     self.top_questions_asked = list()
     self.question = question_interface()
     self.last_question_asked_tag = None
     self.question_flag = 0
     self.call_db()
     self.hunger = 10
     pass
Exemplo n.º 6
0
    def load_top_questions(self):
        from top_questions import data
        from question_interface import question_interface

        top_questions_list = []
        data = data()

        for tag, value in data.iteritems():
            top = question_interface()
            top_questions_list.append(self._assign_attributes(top, value, tag))

        return top_questions_list
Exemplo n.º 7
0
    def load_top_questions(self):
        from top_questions import data
        from question_interface import question_interface

        top_questions_list = []
        data = data()

        for tag, value in data.iteritems():
            top = question_interface()
            top_questions_list.append(self._assign_attributes(top, value, tag))

        return top_questions_list
Exemplo n.º 8
0
    def next_basic_data_question(self):
        next_question = None
        for tag in self.basic_data_questions_table:
            if not self.basic_data_questions_table[tag]:
                next_question = tag
                self.last_asked_basic_question = tag
                break

        if next_question is None:
            return None

        question_dict = __import__("basic_data").data()[next_question]
        q_obj = question_interface()
        q_obj.question = question_dict["question"]
        q_obj.response = question_dict["response"]
        q_obj.response_type = question_dict["response_type"]

        return q_obj
Exemplo n.º 9
0
    def next_basic_data_question(self):
        next_question = None
        for tag in self.basic_data_questions_table:
            if not self.basic_data_questions_table[tag]:
                next_question = tag
                self.last_asked_basic_question = tag
                break

        if next_question is None:
            return None

        question_dict = __import__('basic_data').data()[next_question]
        q_obj = question_interface()
        q_obj.question = question_dict['question']
        q_obj.response = question_dict['response']
        q_obj.response_type = question_dict['response_type']

        return q_obj
Exemplo n.º 10
0
    def run_expert(self, user_response):
        q_obj = question_interface()
        key = 'Start'
        # print user_response

        valid_keys = ['Start', 'Begin consultation with Doctor SkyNet']
        if self.status == 0:
            if user_response in valid_keys:
                self.status = 1
            else:

                return None

        if self.status == 1:  # stage 1 last response from user stays None
            self.status = 2
            q_obj = self.AI.askdoctor()
            returns = dict()
            returns['text'] = q_obj.question
            returns['keyboard'] = q_obj.response
            return returns

        if self.status == 2:  # in stage 2 last response from user is passed to AI
            q_obj = self.AI.askdoctor(user_response)
            if q_obj is None:
                self.status = 3
                returns = dict()
                returns[
                    'text'] = 'Your Test is Complete, Please tell the doctor your ID:' + str(
                        self.chat_id)
                returns['keyboard'] = []
                self.done = 1

                return returns

            returns = dict()
            returns['text'] = q_obj.question
            returns['keyboard'] = q_obj.response
            # print "options are:" + str(q_obj.response)
            return returns
Exemplo n.º 11
0
    def run_expert(self, user_response):
        q_obj = question_interface()
        key = 'Start'
        # print user_response

        valid_keys = ['Start', 'Begin consultation with Doctor SkyNet']
        if self.status == 0:
            if user_response in valid_keys:
                self.status = 1
            else:

                return None

        if self.status == 1: # stage 1 last response from user stays None
            self.status = 2
            q_obj = self.AI.askdoctor()
            returns = dict()
            returns['text'] = q_obj.question
            returns['keyboard'] = q_obj.response
            return returns

        if self.status == 2: # in stage 2 last response from user is passed to AI 
            q_obj = self.AI.askdoctor(user_response)
            if q_obj is None:
                self.status = 3
                returns = dict()
                returns['text'] = 'Your Test is Complete, Please tell the doctor your ID:' + str(self.chat_id)
                returns['keyboard'] = []
                self.done = 1

                return returns

            returns = dict()
            returns['text'] = q_obj.question
            returns['keyboard'] = q_obj.response
            # print "options are:" + str(q_obj.response)
            return returns