def answer_room_pos(cls, entity): response = "\n您当前在总馆北区一层\n" room = entity['room'][0] #print(room) ans_room = room if room.find("_") != -1: arr = room.split("_") ans_room = arr[2] area = Neo4jPrepare.get_relation(room, '馆区') #print(area) if area[0]['office_name'] != '总馆北区': response += ans_room + '在' + area[0]['office_name'] + ",位于" + area[ 0]['position'] + "\n" return response floor = Neo4jPrepare.get_relation(room, '楼层') #print(floor) if floor[0]['office_name'] != '总馆北区一层': response += ans_room + '在' + floor[0][ 'office_name'] + ", 直走340米您就能找到最近的电梯。\n" return response response += cls.navi(room) return response
def solve_room_pos(self, entity): response = "\n您当前在总馆北区一层\n" room = entity['room'][0] #print(entity) ans_room = room if room.find("_") != -1: arr = room.split("_") ans_room = arr[2] #print("room",room) area = Neo4jPrepare.get_relation(room, '馆区') #print(area) if area[0]['office_name'] != '总馆北区': response += ans_room + '在' + area[0]['office_name'] + ",位于" + area[ 0]['position'] + "\n" return [response] floor = Neo4jPrepare.get_relation(room, '楼层') #print(floor) if floor[0]['office_name'] != '总馆北区一层': response += ans_room + '在' + floor[0][ 'office_name'] + ", 直走340米您就能找到最近的电梯。\n" return [response] respo, img = self.navi(room) response += respo return [response, img]
def solve_res_floor(self, entity): resource = entity['res'][0] floor = entity['floor'][0] res = Neo4jPrepare.get_relation(resource,'馆室') room_name = res[0]['office_name'] if room_name.find("_")!=-1: room_name = res[0]['office_name'].split("_")[2] des_floor = Neo4jPrepare.get_relation(res[0]['office_name'],'楼层') ans = "\n" if floor == des_floor[0]['office_name']: ans += resource+"存放在"+floor else: ans += resource+"不存放在"+floor+"\n"+resource+"存放在"+des_floor[0]['office_name']+"的"+room_name return ans
def solve_book_back(self, entity): resource = entity['res'][0] res = Neo4jPrepare.get_relation(resource,'馆室') ans = "\n"+resource+"存放在" for r in res[:-1]: #print(r) ans += r['office_name']+"," ans += res[-1]['office_name']+"\n" card = Neo4jPrepare.get_relation(res[-1]['office_name'],'证件') for c in card: ans += "年龄"+c['age']+"可持"+c['office_name']+"进入馆室\n" return ans
def solve_library_area(self): res = Neo4jPrepare.get_relation("国家图书馆","馆区") print(res) ans = "\n国家图书馆包括" for r in res[:-1]: ans += r['office_name']+"," ans += res[-1]['office_name']+"\n" return ans
def answer_res_pos(cls, entity): response = "\n" res = entity['res'][0] ans = Neo4jPrepare.get_relation(res, '馆室') ans_room = ans[0]['office_name'] if ans[0]['office_name'].find("_") != -1: arr = ans[0]['office_name'].split("_") ans_room = arr[2] response += res + "存放于" + ans_room + "\n" #print(ans) response += cls.navi(ans[0]['office_name']) return response
def solve_restype_pos(self, entity): restype = entity['restype'][0] res = Neo4jPrepare.get_reverse_relation(restype, '资源') #print(res) ans = "\n" + restype + "包括:\n" for r in res: #print(r) room = Neo4jPrepare.get_relation(r['office_name'], '馆室') ans += r['office_name'] + ",存放在" for sub_room in room[:-1]: ans += sub_room['office_name'] + "," ans += room[-1]['office_name'] + "\n" return ans
def solve_res_pos(self, entity): response = "\n" res = entity['res'][0] ans = Neo4jPrepare.get_relation(res, '馆室') ans_room = ans[0]['office_name'] if ans[0]['office_name'].find("_") != -1: arr = ans[0]['office_name'].split("_") ans_room = arr[2] response += res + "存放于" + ans_room + "\n" #print(ans) dict = {} dict['room'] = [ans[0]['office_name']] ans = self.solve_room_pos(dict)[0] response += ans[0] return response
def solve_room_floor(self,entity): floor = entity['floor'][0] room = entity['room'][0] res = Neo4jPrepare.get_relation(room,'楼层') ans = "\n" room_name = room if room.find("_")!=-1: room_name = room.split("_")[2] #print(res['office_name']) #print(res[0]['office_name'],floor) if res[0]['office_name'] == floor: ans += room_name+"在"+floor else: ans += room_name+"不在"+floor+"\n"+room_name+"在"+res[0]['office_name']+"\n" return ans
def solve_res_borrow(self,entity): res = entity['res'][0] room_res = Neo4jPrepare.get_relation(res,'馆室') #print(room_res) room = room_res[0]['office_name'] room_name = room if room.find("_")!=-1: room_name=room.split("_")[2] ans = "\n" if room_res[0]['borrow'] == 1: ans+=res+"可以外借\n" elif room_res[0]['borrow'] == 2: ans += res + "不可以外借,但可以复制与扫描\n" else: ans += res + "不可以外借,仅供借阅\n" return ans
def solve_service_describe(self, entity): service = entity['service'][0] #print(service) res = Neo4jPrepare.get_property(service) #print(res.keys()) ans = '' if res['discribe'] != '': ans = "\n" + service + "指" + res['discribe'] else: room_res = Neo4jPrepare.get_relation(service, '馆室') for r in room_res: if r['describe'] != '': ans += "\n" + r['office_name'] + r['describe'] if ans == '': ans = "很抱歉,暂时没有" + service + "的描述信息\n" return ans
def solve_res_room(self, entity): room = entity['room'][0] resource = entity['res'][0] res = Neo4jPrepare.get_relation(resource, '馆室') room_name = room ans = "\n" if room.find("_")!=-1: room_name = room.split("_")[2] if res[0]['office_name'] == room: ans += resource+"存放在"+room_name else: des_room = res[0]['office_name'] if res[0]['office_name'].find("_")!=-1: des_room = res[0]['office_name'].split("_")[2] ans += resource+"不存放在"+room_name+"\n"+resource+"存放在"+des_room+"\n" return ans
def solve_restype_borrow(self,entity): restype = entity['restype'][0] res_res = Neo4jPrepare.get_reverse_relation(restype,'资源') #print(res_res) yes_room = [] copy_room = [] no_room = [] for res in res_res: room_res = Neo4jPrepare.get_relation(res['office_name'],'馆室') for r in room_res: room = r['office_name'] if r['borrow'] == 1: yes_room.append(room) elif r['borrow'] == 2: copy_room.append(room) else: no_room.append(room) copy_room = np.unique(copy_room) ans = "\n" if len(yes_room)>0: ans += "存放在" for y in yes_room[:-1]: ans += y+"," ans += yes_room[len(yes_room)-1]+"的"+restype+"可以外借\n" if len(copy_room)>0: ans += "存放在" for c in copy_room[:-1]: ans += c+"," ans += copy_room[len(copy_room) - 1] + "的" + restype + "可以不外借,但可以复制和扫描\n" if len(no_room)>0: ans += "存放在" for y in no_room[:-1]: ans += y+"," ans += no_room[len(no_room)-1]+"的"+restype+"不可以外借,仅供借阅\n" return ans