Commit 0c08312d authored by 张彦钊's avatar 张彦钊

change test file

parent 5814566a
......@@ -29,31 +29,28 @@ def get_esmm_users():
def get_user_profile(device_id,top_k = 5):
try:
r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2)
key = "user:portrait_tags:cl_id:" + str(device_id)
if r.exists(key):
tmp = json.loads(r.get(key).decode('utf-8'))
tag_score = {}
for i in tmp:
if i["type"] == "tag":
tag_score[i["content"]] = i["score"]
elif i["content"] in name_tag.keys():
tag_score[name_tag[i["content"]]] = i["score"]
tag_sort = sorted(tag_score.items(), key=lambda x: x[1], reverse=True)
tags = []
if len(tag_sort) > top_k:
for i in range(top_k):
tags.append(i[0])
else:
for i in tag_sort:
tags.append(i[0])
return tags
r = redis.Redis(host="172.16.40.135", port=5379, password="", db=2)
key = "user:portrait_tags:cl_id:" + str(device_id)
if r.exists(key):
tmp = json.loads(r.get(key).decode('utf-8'))
tag_score = {}
for i in tmp:
if i["type"] == "tag":
tag_score[i["content"]] = i["score"]
elif i["content"] in name_tag.keys():
tag_score[name_tag[i["content"]]] = i["score"]
tag_sort = sorted(tag_score.items(), key=lambda x: x[1], reverse=True)
tags = []
if len(tag_sort) > top_k:
for i in range(top_k):
tags.append(i[0])
else:
return []
except:
return []
for i in tag_sort:
tags.append(i[0])
return tags
def get_searchworlds_to_tagid():
......@@ -201,6 +198,7 @@ if __name__ == "__main__":
name_tag = get_searchworlds_to_tagid()
tag_list = get_user_profile("00B75E84-7EFC-40A4-8380-E1AA439A0B0D")
print("用户画像标签:")
print(tag_list)
# queues = get_queues("00C6F623-297E-4608-9988-9774F503639C", "nanchang")
......
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