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
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