Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
    def solve_service_room_exit(self, entity):
        room = entity['room'][0]
        service = entity['service'][0]
        res = Neo4jPrepare.get_reverse_relation(room, '服务')
        ans = "\n"
        for r in res:
            if r['office_name'] == service:
                ans += room + "提供" + service + "\n"
                return ans

        ans += room + "不提供" + service + "\n"
        return ans
Ejemplo n.º 12
0
 def solve_service_room_all(self, entity):
     room = entity['room'][0]
     res = Neo4jPrepare.get_reverse_relation(room, '服务')
     ans = "\n"
     if len(res) > 0:
         ans += room + "提供的服务包括"
         for r in res[:-1]:
             ans += r['office_name'] + ","
         ans += res[-1]['office_name'] + "\n"
     else:
         ans += room + "不提供任何服务\n"
     return ans
Ejemplo n.º 13
0
    def solve_area_borrow(self,entity):
        area = entity['area'][0]
        ans = "\n"

        room_res = Neo4jPrepare.get_reverse_relation(area,'馆室')
        borrow_room = []
        borrow_floor = []
        copy_room = []
        copy_floor=[]
        copy = []
        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)
                borrow_floor.append(r['floor'])
            elif r['borrow'] == '2':
                room_name = r['office_name']
                copy_room.append(room_name)
                copy_floor.append(r['floor'])
            elif '复制处' in r['variant_name']:
                if r['floor'] in copy:
                    continue
                if r['floor'].find(",")!=-1:
                    floor_arr = r['floor'].split(",")
                    for sub_floor in floor_arr:
                        copy.append(sub_floor)
                else:
                    copy.append(r['floor'])
        copy = np.unique(copy)
        if len(borrow_room)>0:
            for b in range(len(borrow_room)-1):
                ans += borrow_floor[b]+"的"+borrow_room[b]+","
            ans += borrow_floor[-1]+"的"+borrow_room[-1]+"的书籍材料资源可以外借\n"
        if len(copy_room)>0:
            for c in range(len(copy_room)-1):
                ans += copy_floor[c]+"的"+copy_room[c]+","
            ans += copy_floor[-1]+"的"+copy_room[-1]+"的书籍材料资源不可以外借,但可以复制或扫描\n"

            for f in copy[:-1]:
                #print(f)
                ans += f + ","
            ans += copy[-1]
            ans += "提供复制处,可携带读者卡前往该楼层复制处复制或扫描\n"
        if ans == "\n":
            ans += area + "的资源不可外借或复制\n"
        else:
            ans += "剩余馆室的资源不可复制或外借\n"
        #print(ans)

        return ans
Ejemplo n.º 14
0
    def solve_mul_res_h(self, entity):
        restype = entity['restype'][0]
        multype = entity['multype'][0]
        res_arr = []
        res = Neo4jPrepare.get_reverse_relation(multype, '资源类型')
        ans = "\n"
        for r in res[:-1]:
            res_arr.append(r['office_name'])
        if restype in res_arr:

            ans += "是的," + restype + "属于" + multype + "\n"
        else:
            ans += "很抱歉," + restype + "不属于" + multype + "\n"
        return ans
Ejemplo n.º 15
0
    def solve_floor_room_a(self, entity):
        floor = entity['floor'][0]
        res = Neo4jPrepare.get_reverse_relation(floor, '馆室')
        ans = "\n" + floor + "有馆室"
        for r in res[:-1]:
            room_name = r['office_name']
            if room_name.find(u"_") != -1:
                room_name = room_name.split("_")[2]
            ans += room_name + ","
        room_name = res[-1]['office_name']
        if room_name.find(u"_") != -1:
            room_name = room_name.split("_")[2]
            ans += room_name + "\n"

        return ans
Ejemplo n.º 16
0
 def solve_multype_describe(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_describe(entity)[1:]
     return ans
Ejemplo n.º 17
0
    def solve_restype_describe(self, entity):

        restype = entity['restype'][0]

        restype_search = Neo4jPrepare.get_property(restype)

        res = Neo4jPrepare.get_reverse_relation(restype, '资源')
        res_arr = []
        yes_res = []
        no_res = []
        describe = []
        ans = "\n"

        if restype_search['count'] != 'nan':
            ans += restype + "在国家图书馆的馆藏数量为:" + restype_search['count'] + "\n"
        if restype_search['describe'] != 'nan':
            ans += restype_search['describe'] + "\n"
            return ans
        for r in res:
            sub_res = Neo4jPrepare.get_property(r['office_name'])

            res_arr.append(sub_res['office_name'])

            if sub_res['describe'] != 'nan':

                yes_res.append(sub_res['office_name'])
                describe.append(sub_res['describe'])

            else:
                no_res.append(sub_res['office_name'])
        if len(res) > 0:
            ans += restype + "包括"
            for r in res_arr[:-1]:
                ans += r + ","
            ans += res_arr[-1]
            for y in range(len(yes_res)):
                ans += yes_res[y] + ":" + describe[y] + "\n"
        return ans
Ejemplo n.º 18
0
    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
Ejemplo n.º 19
0
 def solve_floor_count_room(self, entity):
     floor = entity['floor'][0]
     res = Neo4jPrepare.get_reverse_relation(floor, '馆室')
     l = len(res)
     ans = "\n" + floor + "一共有" + str(l) + "间馆室\n"
     return ans