def process_info_query(entities): if "faculty_name" in entities: faculty_attributes, faculty_info = helper.load_faculty_information() if contains("research area", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] research_area = str(faculty_info[staff_name][5]) response += response_generator.provide_faculty_research_area( staff_name, research_area) print(response) if contains("research interest", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] research_interest = str(faculty_info[staff_name][10]) response += response_generator.provide_faculty_research_interest( staff_name, research_interest) print(response) if contains("title", entities["info_target"]) or contains( "job", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] title = str(faculty_info[staff_name][1]) response += response_generator.provide_faculty_title( staff_name, title) print(response) new_state = "end" return new_state, entities if "staff_name" in entities: staff_attributes, staff_info = helper.load_staff_information() if helper.check_job(entities["info_target"]): response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] position = str(staff_info[staff_name][4].replace("\n", "")) staff_type = str(staff_info[staff_name][5]) response += response_generator.provide_staff_position( staff_name, position, staff_type) print(response) new_state = "end" return new_state, entities new_state = "error" return new_state, entities
def process_contact_query_questions(entities): if "staff_name" in entities: staff_attributes, staff_info = helper.load_staff_information() if "info_target" in entities: # Query about telephone number if contains("tel", entities["info_target"]): response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] try: tel = str(int(staff_info[staff_name][2])) except ValueError: tel = "information not available" response += response_generator.provide_staff_telephone_number( staff_name, tel) print(response) # Query about email if contains("email", entities["info_target"]): response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] email = str(staff_info[staff_name][1]) if "\\N" in email: email = "information not available" response += response_generator.provide_staff_email( staff_name, email) print(response) # Query about room number if contains("room number", entities["info_target"]): response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] try: room_number = str(int(staff_info[staff_name][3])) except ValueError: room_number = "information not available" response += response_generator.provide_staff_room( staff_name, room_number) print(response) # Query about website if contains("links", entities["info_target"]): response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] link = str(staff_info[staff_name][6]) if "\\N" in link: link = "information not available" response += response_generator.provide_staff_link( staff_name, link) print(response) new_state = "end" return new_state, entities else: response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"] # Get email email = str(staff_info[staff_name][1]) if "\\N" in email: email = "information not available" # Get telephone number try: tel = str(int(staff_info[staff_name][2])) except ValueError: tel = "information not available" # Get room number try: room_number = str(int(staff_info[staff_name][3])) except ValueError: room_number = "information not available" link = str(staff_info[staff_name][6]) if "\\N" in link: link = "information not available" response += response_generator.provide_staff_info( staff_name, email, tel, room_number, link) print(response) new_state = "end" return new_state, entities if "faculty_name" in entities: faculty_attributes, faculty_info = helper.load_faculty_information() if "info_target" in entities: # Query about telephone number if contains("tel", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] tel = faculty_info[staff_name][2] if "\\N" in tel: tel = "information not available" response += response_generator.provide_faculty_tel( staff_name, tel) print(response) # Query about email if contains("email", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] email = str(faculty_info[staff_name][3]) if "\\N" in email: email = "information not available" response += response_generator.provide_faculty_email( staff_name, email) print(response) # Query about room number # Query about website is given to "get_access" intent if contains("room number", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] room_number = str(faculty_info[staff_name][4]) if "\\N" in room_number: room_number = "information not available" response += response_generator.provide_staff_room( staff_name, room_number) print(response) if contains("links", entities["info_target"]): response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] link = "http://www.cse.ust.hk/~" link += faculty_info[staff_name][3].replace( "@cse.ust.hk", "") link += "/" response += response_generator.provide_staff_link( staff_name, link) print(response) else: response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" staff_name = entities["faculty_name"][i]["value"] # Get email email = str(faculty_info[staff_name][3]) if "\\N" in email: email = "information not available" # Get telephone number try: tel = str(faculty_info[staff_name][2]) except ValueError: tel = "information not available" # Get room number try: room_number = str(faculty_info[staff_name][4]) except ValueError: room_number = "information not available" link = str(faculty_info[staff_name][7]) if "\\N" in link: link = "information not available" profile_link = str(faculty_info[staff_name][8]) if "\\N" in profile_link: profile_link = "information not available" scholar_link = str(faculty_info[staff_name][9]) if "\\N" in scholar_link: scholar_link = "information not available" response += provide_faculty_info(staff_name, email, tel, room_number, link, profile_link, scholar_link) print(response) new_state = "end" return new_state, entities response = response_generator.provide_dept_contact_info() print(response) new_state = "end" return new_state, entities
def process_people_query_questions(entities): if "staff_name" in entities: staff_attributes, staff_info = helper.load_staff_information() response = "" for i in range(len(entities["staff_name"])): if i != 0: response += "\n" staff_name = entities["staff_name"][i]["value"].replace("\n", "") position = staff_info[staff_name][4].replace("\n", "").lower() staff_type = staff_info[staff_name][5].replace("\n", "") response += response_generator.provide_staff_people_info( staff_name, position, staff_type) print(response) new_state = "end" return new_state, entities if "research_area" in entities: response = "" area_faculty, faculty_area = helper.load_faculty_research_info() for i in range(len(entities["research_area"])): if i != 0: response += "\n" research_area = entities["research_area"][i]["value"] faculty_list = area_faculty[research_area] response += response_generator.provide_faculty_in_research_area( research_area, faculty_list) print(response) new_state = "end" return new_state, entities if "faculty_name" in entities: faculty_attributes, faculty_info = helper.load_faculty_information() response = "" for i in range(len(entities["faculty_name"])): if i != 0: response += "\n" name = entities["faculty_name"][i]["value"] response += faculty_info[name][6] print(response) new_state = "end" return new_state, entities if "info_target" in entities: if contains("head", entities["info_target"]): response = "The head of the department is Prof. Dit-Yan Yeung." print(response) new_state = "end" return new_state, entities if contains("ug coordinator", entities["info_target"]): response = "The coordinator for UG programs is Dr. Qiong Luo." print(response) new_state = "end" return new_state, entities if contains("pg coordinator", entities["info_target"]): response = "The coordinator for PG programs is Dr. Kai Chen." print(response) new_state = "end" return new_state, entities if contains("coordinator", entities["info_target"]): if "program" in entities: response = "" for i in range(len(entities["program"])): if i != 0: response += "\n" program = entities["program"][i]["value"] coordinator = helper.load_program_info()[4] response += response_generator.provide_coordinator_info( program, coordinator) print(response) new_state = "end" return new_state, entities new_state = "query_coordinator" return new_state, entities new_state = "error" return new_state, entities