示例#1
0
 def answer_business_readerCard_00(cls, entity_dict, graph):
     respons_str=""
     if (len(rdfPrepare.rdf_query_propertiy("办理读书卡", "pro_step1", graph)) != 0):
         respons_str += rdfPrepare.rdf_query_propertiy("办理读书卡", "pro_step1", graph)[0]
         if multiwheelUnit.get_value('business') == None:
             multiwheelUnit.set_value('business', "办理读书卡")
         if multiwheelUnit.get_value('step') == None:
             multiwheelUnit.set_value('step', "_step1")
         return respons_str
     else:
         return None
示例#2
0
 def answer_business_readerCard_no(cls, entity_dict, graph):
     if multiwheelUnit.get_value('business')=="办理读书卡":
         if multiwheelUnit.get_value('step')!=None:
             arr = multiwheelUnit.get_value('step').split('_')
             step=arr[len(arr) - 1]
             if (len(rdfPrepare.rdf_query_propertiy("办理读书卡", "pro_"+step+"_no", graph)) != 0):
                 step_ans =rdfPrepare.rdf_query_propertiy("办理读书卡", "pro_"+step+"_no", graph)[0]
                 respons_str=rdfPrepare.rdf_query_propertiy("办理读书卡", "pro_"+step_ans, graph)[0]
                 multiwheelUnit.set_value('step',multiwheelUnit.get_value('step')+"_"+step_ans)
                 return respons_str
     else:
         return None
示例#3
0
 def answer_room_contact(cls, entity_dict, graph):
     if len(entity_dict['room'])!= 0:
         respons_str = ''
         for i in range(len(entity_dict['room'])):
             room_in_question = entity_dict['room'][i]
             if room_in_question:
                 for target_room in room_in_question:
                     if(len(rdfPrepare.rdf_query_propertiy(target_room, "pro_contact_phone", graph))!=0):
                         respons_str += "_".join(target_room.split('_')[0:3]) +"的电话:"+rdfPrepare.rdf_query_propertiy(target_room, "pro_contact_phone", graph)[0]+"。\n"
                     elif(len(rdfPrepare.rdf_query_relation(target_room, "rel_part_of_room", graph))!=0):
                         parent_room = rdfPrepare.rdf_query_relation(target_room, "rel_part_of_room", graph)
                         for p_room in parent_room:
                             if(rdfPrepare.rdf_query_propertiy(p_room, "pro_contact_phone", graph)):
                                 respons_str += target_room + '位于' + p_room.split('_')[2] + ',可致电' + p_room.split('_')[2]+":" + rdfPrepare.rdf_query_propertiy(p_room, "pro_contact_phone", graph)[0] + '。\n'
         return respons_str
     else:
         return None
示例#4
0
 def answer_room_pos(cls, entity_dict, graph, tag):
     if tag:
         respons_str = '您当前位置是' + GraphBaseConfig['now_floor'] + '。\n'
     else:
         respons_str = ''
     if len(entity_dict['room'])!=0:
         for i in range(len(entity_dict['room'])):
             room_in_question = entity_dict['room'][i]
             if room_in_question:
                 for target_room in room_in_question:
                     respons_str += "_".join(target_room.split('_')[0:3])+"位于:"
                     if(len(rdfPrepare.rdf_query_relation(target_room, "rel_part_of_floor", graph))!=0):
                         respons_str += rdfPrepare.rdf_query_relation(target_room, "rel_part_of_floor", graph)[0]+','
                     if(len(rdfPrepare.rdf_query_propertiy(target_room, "pro_position_describe", graph))!=0):
                         respons_str += "位置在" + rdfPrepare.rdf_query_propertiy(target_room, "pro_position_describe", graph)[0]
                     respons_str += '。\n'
         return respons_str
     else:
         return None
示例#5
0
 def answer_room_time_openday(cls, entity_dict, graph):
     '''
     馆室开放日
     :param entity_dict:
     :param graph:
     :return:
     '''
     room_in_question = entity_dict['room']
     respons_str =''
     if room_in_question:
         for target_room in room_in_question:
             if (len(rdfPrepare.rdf_query_propertiy(target_room, "pro_open_day", graph)) != 0):
                 respons_str += "_".join(target_room.split('_')[0:3]) + "开放日是:" + \
                                rdfPrepare.rdf_query_propertiy(target_room, "pro_open_day", graph)[0] + "。\n"
             elif (len(rdfPrepare.rdf_query_relation(target_room, "rel_part_of_room", graph)) != 0):
                 parent_room = rdfPrepare.rdf_query_relation(target_room, "rel_part_of_room", graph)
                 for p_room in parent_room:
                     if (rdfPrepare.rdf_query_propertiy(p_room, "pro_open_day", graph)):
                         respons_str += target_room + '位于' + p_room.split('_')[2] + ',开放日是:' + \
                                        rdfPrepare.rdf_query_propertiy(p_room, "pro_open_day", graph)[0] + '。\n'
         return respons_str
     else:
         return None
示例#6
0
 def answer_res_time(cls, entity_dict, graph,day):
     '''
     资源开放时间
     :param entity_dict:
     :param graph:
     :return:
     '''
     res_in_question = entity_dict['res']
     respons_str=''
     if day=="today":
         respons_str = '今天是' + GraphBaseConfig['now_day'] + ','
         week_str = time.strftime("%w", time.localtime())
         if str(week_str) == '1':
             week_str = "pro_Monday_opentime"
             respons_str = respons_str.replace('星期1', '星期一')
         elif str(week_str) == '2':
             week_str = "pro_Tuesday_opentime"
             respons_str = respons_str.replace('星期2', '星期二')
         elif str(week_str) == '3':
             week_str = "pro_Wednesday_opentime"
             respons_str = respons_str.replace('星期3', '星期三')
         elif str(week_str) == '4':
             week_str = "pro_Thursday_opentime"
             respons_str = respons_str.replace('星期4', '星期四')
         elif str(week_str) == '5':
             week_str = "pro_Friday_opentime"
             respons_str = respons_str.replace('星期5', '星期五')
         elif str(week_str) == '6':
             week_str = "pro_Saturday_opentime"
             respons_str = respons_str.replace('星期6', '星期六')
         elif str(week_str) == '日':
             week_str = "pro_Sunday_opentime"
     elif day=="tomorrow":
         respons_str = '明天是' + GraphBaseConfig['now_day'] + ','
         week_str = time.strftime("%w", time.localtime())
         if str(week_str) == '1':
             week_str = "pro_Tuesday_opentime"
             respons_str = respons_str.replace('星期1', '星期二')
         elif str(week_str) == '2':
             week_str = "pro_Wednesday_opentime"
             respons_str = respons_str.replace('星期2', '星期三')
         elif str(week_str) == '3':
             week_str = "pro_Thursday_opentime"
             respons_str = respons_str.replace('星期3', '星期四')
         elif str(week_str) == '4':
             week_str = "pro_Friday_opentime"
             respons_str = respons_str.replace('星期4', '星期五')
         elif str(week_str) == '5':
             week_str = "pro_Saturday_opentime"
             respons_str = respons_str.replace('星期5', '星期六')
         elif str(week_str) == '6':
             week_str = "pro_Sunday_opentime"
             respons_str = respons_str.replace('星期6', '星期日')
         elif str(week_str) == '日':
             week_str = "pro_Monday_opentime"
             respons_str = respons_str.replace('星期日', '星期一')
     elif day=="Monday":
         respons_str = '星期一,'
         week_str = "pro_Monday_opentime"
     elif day=="Tuesday":
         respons_str = '星期二,'
         week_str = "pro_Tuesday_opentime"
     elif day=="Wednesday":
         respons_str = '星期三,'
         week_str = "pro_Wednesday_opentime"
     elif day=="Thursday":
         respons_str = '星期四,'
         week_str = "pro_Thursday_opentime"
     elif day=="Friday":
         respons_str = '星期五,'
         week_str = "pro_Friday_opentime"
     elif day == "Saturday":
         respons_str = '星期六,'
         week_str = "pro_Saturday_opentime"
     elif day == "Sunday":
         respons_str = '星期日,'
         week_str = "pro_Sunday_opentime"
     if res_in_question:
         for target_res in res_in_question:
             room=rdfPrepare.rdf_query_relation(target_res, "rel_part_of_room", graph)
             if(len(room)!=0):
                 if(len(rdfPrepare.rdf_query_propertiy(room[0], week_str, graph))!=0):
                     # print(rdfPrepare.rdf_query_propertiy(room[0], week_str, graph))
                     respons_str += target_res +"开放时间是:"+rdfPrepare.rdf_query_propertiy(room[0], week_str, graph)[0]+"。\n"
             elif(len(rdfPrepare.rdf_query_relation(room[0], "rel_part_of_room", graph))!=0):
                 parent_room = rdfPrepare.rdf_query_relation(room[0], "rel_part_of_room", graph)
                 for p_room in parent_room:
                     if(rdfPrepare.rdf_query_propertiy(p_room, week_str, graph)):
                         respons_str += target_res + '位于' + p_room.split('_')[2] + ',开放时间是:' + rdfPrepare.rdf_query_propertiy(p_room, week_str, graph)[0] + '。\n'
         return respons_str
     else:
         return None