Exemple #1
0
    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 = self.navi(room)

        response += respo
        img = self.get_pic()
        return [response, img]
Exemple #2
0
    def solve_multype_room(self, entity):

        room = entity['room'][0]
        multype = entity['multype'][0]
        restype_search = Neo4jPrepare.get_reverse_relation(multype, '资源类型')
        restype_arr = [x['office_name'] for x in restype_search]
        ans = "\n"
        if len(restype_arr) > 0:
            ans += multype + "包括"
        else:
            return "很抱歉,没有" + multype + "的具体信息\n"
        for restype in restype_arr[:-1]:
            ans += restype + ","
        ans += restype_arr[-1] + "\n"
        #print("===",restype_arr)
        for restype in restype_arr:
            #print(restype)
            res = Neo4jPrepare.get_relation_mul(restype, '馆室')
            #print(res)

            room_arr = [r['office_name'] for r in res]
            #print(room_arr)

            if room in room_arr:
                ans += room + "存有" + restype
                return ans

        ans += multype + "不存放在" + room + "\n"
        return ans
Exemple #3
0
    def solve_ttype_area(self, entity):

        area = entity['area'][0]
        ttype = entity['ttype'][0]
        restype_res = Neo4jPrepare.get_reverse_relation(ttype, '资源类型')

        restype_arr_orgin = [x['office_name'] for x in restype_res]
        restype_arr = restype_arr_orgin
        ans = ttype + "包括"

        for restype in restype_arr[:-1]:

            ans += restype + ","

        ans += restype_arr[-1] + "\n"
        yes_restype = []
        for restype in restype_arr:
            res = Neo4jPrepare.get_relation_triple(restype, '馆区')
            area_arr = [x['office_name'] for x in res]
            if area in area_arr:
                yes_restype.append(restype)
        if len(yes_restype) > 0:

            ans += '其中'
            for r in yes_restype[:-1]:
                ans += r + ","
            ans += yes_restype[-1] + "在" + area + "\n"
        else:
            ans += area + "没有" + ttype + "\n"
        return ans
Exemple #4
0
    def solve_restype_area(self, entity):
        ans = "\n"
        area = entity['area'][0]

        restype = entity['restype'][0]

        resource = Neo4jPrepare.get_reverse_relation(restype, '资源')
        resource_arr = [x['office_name'] for x in resource]
        ans += restype + "包括"
        for sub_res in resource_arr:
            ans += sub_res + ","
        res = Neo4jPrepare.get_relation_triple(restype, '馆区')

        area_arr = [r['office_name'] for r in res]

        if area in area_arr:
            ans += area + "存有" + restype + "\n"

        else:
            ans += restype + "不存放在" + area + "\n" + restype + "存放在"
            for r in area_arr[:-1]:
                ans += r + ","
            ans += area_arr[-1] + "\n"

        return ans
Exemple #5
0
 def solve_recommend_book2(self, age, sex):
     kind = self.get_kind(age,sex)
     ans = "猜测您可能喜欢"+kind+"类书籍,图书馆有"
     goods = Neo4jPrepare.get_entity_for_kind('精品',kind)
     for g in goods:
         ans += g['office_name']+",存放在"
         room = Neo4jPrepare.get_relation(g['office_name'],'馆室')
         ans += room[0]['office_name']+"\n"
     return ans
Exemple #6
0
 def solve_recommend_book(self, age, sex):
     kind = self.get_kind(age,sex)
     ans = "猜测您可能喜欢"+kind+"类书籍,图书馆有"
     goods = Neo4jPrepare.get_entity_for_kind('精品', kind)
     good_index = random.randint(0, len(goods) - 1)
     g = goods[good_index]
     ans += g['office_name'] + ",存放在"
     room = Neo4jPrepare.get_relation(g['office_name'], '馆室')
     ans += room[0]['office_name'] + "\n"
     return ans
Exemple #7
0
    def solve_recommend_book_other(self):

        ans = "推荐你借阅图书馆的"
        goods = Neo4jPrepare.get_entity_for_kind('精品','其他')
        good_index = random.randint(0, len(goods)-1)
        g = goods[good_index]
        ans += g['office_name']+",存放在"
        room = Neo4jPrepare.get_relation(g['office_name'],'馆室')
        ans += room[0]['office_name']+"\n"
        return ans
Exemple #8
0
    def solve_restype_read(self, entity):
        restype = entity['restype'][0]
        res = Neo4jPrepare.get_relation(restype, '馆室')

        ans = "\n" + restype + "存放在"
        for r in res[:-1]:
            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
Exemple #9
0
    def solve_library_res_a(self):
        area = Neo4jPrepare.get_entity("馆区")
        area_arr = [sub_area['office_name'] for sub_area in area]
        ans = "三个馆舍在资源和服务方面各有侧重。\n"

        for sub_area in area_arr:
            resource_arr = Neo4jPrepare.get_area_resource_type(sub_area)
            if len(resource_arr) > 0:
                ans += sub_area + ": "
                for r in resource_arr[:-1]:
                    #print(r)
                    ans += r['office_name'] + ","
                ans += resource_arr[-1]['office_name'] + "\n"
        return ans
Exemple #10
0
    def solve_room_res_a(self, entity):
        room = entity['room'][0]
        room_name = room
        if room.find(u"_") != -1:
            room_name = room.split("_")[2]
        res = Neo4jPrepare.get_reverse_relation(room, '资源')
        res_dict = {}
        for r in res:
            res_dict[r['belong']] = []
        res_type = list(res_dict.keys())
        #print(res_type)
        if res_type == []:
            return room_name + "不存放任何资源\n"
        ans = "\n"
        ans += room_name + "存放的资源类型包括:"
        for t in res_type[:-1]:
            ans += t + ","
        ans += res_type[-1] + "\n"

        for r in res:
            res_dict[r['belong']].append(r['office_name'])
        for t in res_type:
            ans += t + ":"
            for r in res_dict[t][:-1]:
                ans += r + ","
            ans += res_dict[t][-1] + "\n"
        return ans
Exemple #11
0
    def solve_floor_borrow(self,entity):
        floor = entity['floor'][0]
        ans = "\n"

        room_res = Neo4jPrepare.get_reverse_relation(floor, '馆室')
        borrow_room = []
        copy_room = []
        for r in room_res:
            # print(r['borrow'])
            if r['borrow'] == '1':
                room_name = r['office_name']
                # print(room_name)
                borrow_room.append(room_name)
            elif r['borrow'] == '2':
                room_name = r['office_name']
                copy_room.append(room_name)
        if len(borrow_room) > 0:
            for b in range(len(borrow_room) - 1):
                ans += borrow_room[b] + ","
            ans += borrow_room[-1] + "的书籍材料资源可以外借\n"
        if len(copy_room) > 0:
            for c in range(len(copy_room) - 1):
                ans += copy_room[c] + ","
            ans += copy_room[-1] + "的书籍材料资源不可以外借,但可以复制或扫描\n"
        if ans == "\n":
            ans += floor+"的资源不可外借与复制\n"
        else:
            ans += "其余馆室不可复制或外借资源\n"
        return ans
Exemple #12
0
    def solve_multype_pos(self, entity):
        multype = entity['multype'][0]

        restype_search = Neo4jPrepare.get_reverse_relation(multype, '资源类型')
        restype_arr = [x['office_name'] for x in restype_search]
        ans = "\n"

        if len(restype_arr) > 0:
            ans += multype + "包括"
        else:
            return "很抱歉,没有" + multype + "的具体信息\n"
        for restype in restype_arr[:-1]:
            ans += restype + ","
        ans += restype_arr[-1] + "\n"
        for restype in restype_arr:
            entity['restype'] = [restype]
            ans += self.solve_restype_pos(entity)[1:]
        '''
        return ans
        restype = entity['multype'][0]
        res = Neo4jPrepare.get_reverse_relation(restype, '资源')
        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
Exemple #13
0
 def solve_count_floor(self, entity):
     area = entity['area'][0]
     res = Neo4jPrepare.get_reverse_relation(area, '楼层')
     #print(res)
     l = len(res)
     ans = "\n" + area + "一共有" + str(l) + "层\n"
     return ans
Exemple #14
0
 def solve_task_describe(self, entity):
     task = entity['task'][0]
     #print(service)
     res = Neo4jPrepare.get_property(task)
     #print(res.keys())
     ans = ''
     if res['discribe'] != 'nan':
         ans = "\n" + task + "指" + res['discribe']
     else:
         room_res = Neo4jPrepare.get_relation(task, '馆室')
         for r in room_res:
             if r['describe'] != 'nan':
                 ans += "\n" + r['office_name'] + r['describe']
     if ans == '':
         ans = "很抱歉,暂时没有" + task + "的描述信息\n"
     return ans
Exemple #15
0
 def solve_library_res(self):
     res = Neo4jPrepare.get_relation("国家图书馆", "馆区")
     ans = ""
     for r in res:
         area_dict = {'area': [r['office_name']]}
         ans += self.solve_area_res_a(area_dict)
     return ans
Exemple #16
0
 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
         ans += self.solve_count_res(entity)
     else:
         ans += resource + "不存放在" + floor + "\n" + resource + "存放在" + des_floor[
             0]['office_name'] + "的" + room_name
     return ans
Exemple #17
0
    def solve_area_res_a(self, entity):
        area = entity['area'][0]
        res = Neo4jPrepare.get_reverse_relation(area, '馆室')
        resource_arr = []
        for r in res:
            res_arr = Neo4jPrepare.get_reverse_relation(r['office_name'], '资源')
            for sub_r in res_arr:
                resource_arr.append(sub_r['belong'])

        resource_arr = np.unique(resource_arr)

        ans = "\n"
        ans += area + "存放有"
        for sub_r in resource_arr[:-1]:
            ans += sub_r + ","
        ans += resource_arr[-1] + "等类型的资源\n"
        return ans
Exemple #18
0
    def solve_service_exit_all(self):

        res = Neo4jPrepare.get_entity('服务')
        ans = "\n国家图书馆提供的服务包括"
        for sub_result in res[:-1]:
            ans += sub_result['office_name'] + ","
        ans += res[-1]['office_name'] + "\n"
        return ans
Exemple #19
0
 def solve_mul_res_a(self, entity):
     multype = entity['multype'][0]
     res = Neo4jPrepare.get_reverse_relation(multype, '资源类型')
     ans = "\n" + multype + "包含的资源有:"
     for r in res[:-1]:
         ans += r['office_name'] + ","
     ans += res[-1]['office_name'] + "\n"
     return ans
Exemple #20
0
 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
Exemple #21
0
 def solve_res_time(self, entity):
     resource = entity['res'][0]
     # print(Neo4jPrepare.get_property(resource))
     room = Neo4jPrepare.get_property(resource)['room']
     res = Neo4jPrepare.get_property(room)
     workday_time = res['work_borrow']
     weekend_time = res['week_borrow']
     if workday_time == 'nan' and weekend_time == 'nan':
         return "很抱歉," + room + "的资源材料不提供借阅\n"
     # ans = "\n" + resource + "的借阅时间为:\n工作日:" + workday_time + "\n周未:" + weekend_time + "\n"
     ans = "\n" + resource + "存放在" + room + ","
     ans += room + "的借阅时间为:"
     if workday_time != 'nan':
         ans += "\n工作日:" + workday_time
     if weekend_time != 'nan':
         ans += "\n周未:" + weekend_time
     return ans + "\n"
Exemple #22
0
    def solve_count_res(self, entity):
        resource = entity['res'][0]
        res = Neo4jPrepare.get_property(resource)
        ans = "\n" + resource + "存放在"
        room = Neo4jPrepare.get_relation(resource, '馆室')
        room_arr = [x['office_name'] for x in room]
        #print(room)

        for room_name in room_arr[:-1]:
            ans += room_name + ","
        ans += room_arr[-1] + "\n"

        if res['count'] != 'nan':
            ans += resource + "的数量是:" + str(res['count']) + "本(份)\n"
        else:
            ans += "很抱歉," + resource + "暂时没有数据信息\n"
        return ans
Exemple #23
0
 def solve_res_topic(self, entity):
     resource = entity['res'][0]
     res = Neo4jPrepare.get_property(resource)
     ans = "\n"
     if res['topic'] != 'nan':
         ans += resource + "涵盖的主题包括" + res['form'] + "\n"
     else:
         ans += "很抱歉,暂时没有" + resource + "的主题信息\n"
     return ans
Exemple #24
0
 def solve_res_form(self, entity):
     resource = entity['res'][0]
     res = Neo4jPrepare.get_property(resource)
     ans = "\n"
     if res['form'] != 'nan':
         ans += " 图书馆收藏的" + resource + "包括" + res['form'] + "\n"
     else:
         ans += "很抱歉,暂时没有" + resource + "的形式信息\n"
     return ans
Exemple #25
0
 def solve_room_phone(self, entity):
     room = entity['room'][0]
     res = Neo4jPrepare.get_property(room)
     ans = "\n"
     if res['phone'] != 'nan':
         ans += room + "的联系电话为:" + res['phone'] + "\n"
     else:
         ans += "很抱歉," + room + "暂无联系电话\n"
     return ans
Exemple #26
0
 def solve_room_card_a(self, entity):
     room = entity['room'][0]
     res = Neo4jPrepare.get_property(room)
     ans = "\n"
     if res['card'] != '':
         ans += "进" + room + "需要满足的条件为:\n"
         if res['card'].find(u",") != -1:
             card_arr = res['card'].split(",")
             for card in card_arr:
                 card_res = Neo4jPrepare.get_property(card)
                 ans += "年龄" + card_res['age'] + "的读者可以持" + card_res[
                     'office_name'] + "进入" + room + "\n"
         else:
             card_res = Neo4jPrepare.get_property(res['card'])
             ans += "年龄" + card_res['age'] + "的读者可以持" + card_res[
                 'office_name'] + "进入" + room + "\n"
     else:
         ans += "进入该馆室无需证件\n"
     return ans
Exemple #27
0
 def solve_money_back_no(self):
     res = Neo4jPrepare.get_property('退押金')
     card = res['card']
     card_arr = card.split(u",")
     ans = "\n请到相应阅览室/服务点还清所借图书,确认无欠款后,持"
     for c in card_arr[:-1]:
         ans += c+","
     ans += card_arr[len(card_arr)-1]
     ans += "到办证处办理退押金手续\n"
     return ans
Exemple #28
0
 def solve_res_res_a(self, entity):
     restype = entity['restype'][0]
     res = Neo4jPrepare.get_reverse_relation(restype, '资源')
     if len(res) <= 0:
         return "很抱歉,暂时没有" + restype + "下属资源的信息\n"
     ans = "\n" + restype + "包含的资源有:\n"
     for r in res[:-1]:
         ans += r['office_name'] + ","
     ans += res[-1]['office_name'] + "\n"
     return ans
Exemple #29
0
    def solve_room_describe(self, entity):
        room = entity['room'][0]
        res = Neo4jPrepare.get_property(room)
        ans = "\n"
        if res['describe'] != 'nan':
            ans += room + ":" + res['describe']
        else:
            ans += "对不起,暂时没有" + room + "的描述信息\n"

        return ans
Exemple #30
0
 def solve_return_back_res(self,entity):
     resource = entity['res'][0]
     ans = "\n"
     res_res = Neo4jPrepare.get_relation(resource,'馆室')
     print(res_res)
     if len(res_res)>0:
         ans += resource+"存放于"+res_res[0]['office_name']+",请前往"+res_res[0]['office_name']+"归还书籍,同时你也可以前往总馆南区24小时自助还书处归还书籍\n"
     else:
         ans += '你可以前往总馆南区24小时自助还书处归还书籍\n'
     return ans