Commit 03529e9a authored by 张彦钊's avatar 张彦钊

change test file

parent 18fd035c
...@@ -18,16 +18,24 @@ def get_esmm_users(): ...@@ -18,16 +18,24 @@ def get_esmm_users():
return result return result
def get_user_profile(): def get_user_profile(device_id = "9C5E7C73-380C-4623-8F48-A64C8034E315"):
r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2) r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2)
cl_id = "9C5E7C73-380C-4623-8F48-A64C8034E315" key = "user:portrait_tags:cl_id:" + str(device_id)
key = "user:portrait_tags:cl_id:" + str(cl_id)
tmp = json.loads(r.get(key).decode('utf-8')) tmp = json.loads(r.get(key).decode('utf-8'))
# todo 找赵晨把search word映射成tag print(tmp)
tags = {} search_tag = {}
for i in tmp: for i in tmp:
tags[i["content"]] = i["score"] if i["content"] in name_tag.keys():
tag_sort = sorted(tags.items(), key=lambda x: x[1], reverse=True) search_tag[i["content"]] = i["score"]
tmp.pop(i)
print(search_tag)
print("filter")
print(tmp)
tag_score = {}
for i in tmp:
tag_score[i["content"]] = i["score"]
tag_score.update(search_tag)
tag_sort = sorted(tag_score.items(), key=lambda x: x[1], reverse=True)
tags = [] tags = []
if len(tag_sort) > 5: if len(tag_sort) > 5:
for i in range(5): for i in range(5):
...@@ -36,6 +44,8 @@ def get_user_profile(): ...@@ -36,6 +44,8 @@ def get_user_profile():
for i in tag_sort: for i in tag_sort:
tags.append(tag_sort[i][0]) tags.append(tag_sort[i][0])
print(tags)
return tags return tags
def get_searchworlds_to_tagid(): def get_searchworlds_to_tagid():
...@@ -51,7 +61,7 @@ def get_searchworlds_to_tagid(): ...@@ -51,7 +61,7 @@ def get_searchworlds_to_tagid():
for i in tag_id: for i in tag_id:
searchworlds_to_tagid[i[1]] = i[0] searchworlds_to_tagid[i[1]] = i[0]
print(searchworlds_to_tagid)
return searchworlds_to_tagid return searchworlds_to_tagid
except Exception as e: except Exception as e:
print(e) print(e)
...@@ -85,6 +95,8 @@ def make_sample(uid,city_id,native_queue,nearby_queue,megacity_queue,nation_queu ...@@ -85,6 +95,8 @@ def make_sample(uid,city_id,native_queue,nearby_queue,megacity_queue,nation_queu
if __name__ == "__main__": if __name__ == "__main__":
# users_list = get_esmm_users() # users_list = get_esmm_users()
# total_samples = list() # total_samples = list()
name_tag = get_searchworlds_to_tagid()
get_user_profile()
# for i in users_list: # for i in users_list:
# tag_score = get_user_profile(i[0]) # tag_score = get_user_profile(i[0])
# native,nearby,megacity,nation = get_queues(i[0],i[1]) # native,nearby,megacity,nation = get_queues(i[0],i[1])
...@@ -97,7 +109,7 @@ if __name__ == "__main__": ...@@ -97,7 +109,7 @@ if __name__ == "__main__":
# #
# total_samples.todf # total_samples.todf
# to_data_base(df) # to_data_base(df)
get_searchworlds_to_tagid()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment