Esempio n. 1
0
    def solve_room_res_a(self, entity):
        room = entity['room'][0]
        room_name = room
        if room.find("_")!=-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
Esempio n. 2
0
    def solve_restype_describe(self, entity):
        restype = entity['restype'][0]

        res = Neo4jPrepare.get_reverse_relation(restype, '资源')
        res_arr = []
        yes_room = []
        no_room = []
        describe = []
        ans = "\n"
        for r in res:
            #print(r)

            sub_res = Neo4jPrepare.get_property(r['office_name'])
            res_arr.append(sub_res['office_name'])

            if sub_res['describe'] != '':
                yes_room.append(sub_res['office_name'])
                describe.append(sub_res['describe'])

            else:
                no_room.append(sub_res['office_name'])
        ans += restype + "包括"
        for r in res_arr[:-1]:
            ans += r + ","
        ans += res_arr[-1]
        #ans+=res_arr[-1]+"\n很抱歉,没有"

        for y in range(len(yes_room)):
            ans += yes_room[y] + ":" + describe[y] + "\n"

        return ans
Esempio n. 3
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
Esempio n. 4
0
 def solve_floor_count_room(self, entity):
     #print("<<<")
     floor = entity['floor'][0]
     res = Neo4jPrepare.get_reverse_relation(floor, '馆室')
     # print(res)
     l = len(res)
     ans = "\n" + floor + "一共有" + str(l) + "间馆室\n"
     return ans
Esempio n. 5
0
 def solve_res_res_a(self, entity):
     restype = entity['restype'][0]
     res = Neo4jPrepare.get_reverse_relation(restype,'资源')
     ans = "\n"+restype+"包含的资源有:\n"
     for r in res[:-1]:
         ans += r['office_name']+","
     ans += res[-1]['office_name'] + "\n"
     return ans
Esempio n. 6
0
    def solve_res_floor_a(self, entity):

        floor = entity['floor'][0]
        res = Neo4jPrepare.get_reverse_relation(floor,'馆室')
        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 += floor+"存放有"
        for sub_r in resource_arr[:-1]:
            ans += sub_r+","
        ans += resource_arr[-1]+"等类型的资源\n"
        return ans
Esempio n. 7
0
 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
Esempio n. 8
0
    def solve_count_restype(self, entity):
        restype = entity['restype'][0]
        #res = Neo4jPrepare.get_property(restype)
        ans = "\n"
        describe = ""
        num = 0

        type = Neo4jPrepare.get_reverse_relation(restype,'资源类型')
        #print(type)
        for t in type:
            type_num = 0
            res_r = Neo4jPrepare.get_reverse_relation(t['office_name'],'资源')
            for r in res_r:
                if r['count'] =='':
                    continue
                type_num += int(r['count'])
                num += int(r['count'])
            if type_num != 0:
                describe = "其中包括:\n"+t['office_name'] + str(type_num) + "份\n"

        res_res = Neo4jPrepare.get_reverse_relation(restype, '资源')
        #print(res_res)
        other_num = 0
        for r in res_res:
            if r['count'] == '':
                continue
            num += int(r['count'])
            other_num += int(r['count'])
        if other_num != 0 and describe != '':
            describe += "以及其他" + restype + str(other_num) + "份\n"

        # print(num)
        if num!=0:
            ans += restype+"的数量是:"+str(num)+"本(份)\n"
            ans += describe
        else:
            ans += "很抱歉,"+restype+"暂时没有数据信息\n"
        return ans
Esempio n. 9
0
    def solve_res_res_h(self, entity):
        restype = entity['restype'][0]
        resource = entity['res'][0]
        res_arr = []
        res = Neo4jPrepare.get_reverse_relation(restype,'资源')
        ans = "\n"
        for r in res[:-1]:
            res_arr.append(r['office_name'])
        if resource in res_arr:

            ans += "是的,"+resource + "属于"+restype+"\n"
        else:
            ans += "很抱歉," + resource + "不属于" + restype + "\n"
        return ans
Esempio n. 10
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("_")!=-1:
             room_name = room_name.split("_")[2]
         ans += room_name+","
     room_name = res[-1]['office_name']
     if room_name.find("_") != -1:
         room_name = room_name.split("_")[2]
         ans += room_name + "\n"
     #print(ans)
     return ans
Esempio n. 11
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:
            if r['borrow'] == 1:
                room_name = r['office_name']
                if r['office_name'].find("_")!=-1:
                    room_name = r['office_name'].split("_")[2]
                borrow_room.append(room_name)
                borrow_floor.append(r['floor'])
            elif r['borrow'] == 2:
                room_name = r['office_name']
                if r['office_name'].find("_") != -1:
                    room_name = r['office_name'].split("_")[2]
                copy_room.append(room_name)
                copy_floor.append(r['floor'])
            elif '复制处' in r['variant_name']:
                if r['floor'] in copy:
                    continue

                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]:
                ans += f + ","
            ans += copy[-1]
            ans += "提供复制处,可携带读者卡前往该楼层复制处复制或扫描\n"

        return ans
Esempio n. 12
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