Commit 7d0cbfa6 authored by 段英荣's avatar 段英荣

modify

parent a96c34ef
......@@ -87,10 +87,10 @@ class LinUCB:
for top_score_index in np_score_dict[top_score]:
tag_id = str(tag_list[top_score_index], encoding="utf-8")
top_tag_dict[tag_id] = top_score
if len(top_tag_dict) >= 50:
if len(top_tag_dict) >= 3:
break
if len(top_tag_dict) >= 50:
if len(top_tag_dict) >= 3:
break
logging.info("duan add,device_id:%s,sorted_np_score_list:%s,np_score_dict:%s" % (str(device_id), str(sorted_np_score_list), str(np_score_dict)))
......
......@@ -121,7 +121,7 @@ class TopicUtils(object):
@classmethod
def get_recommend_topic_ids(cls,user_id,tag_id,offset,size,single_size,query=None,query_type=TopicPageType.FIND_PAGE,
filter_topic_id_list=[],test_score=False,must_topic_id_list=[],recommend_tag_dict={},
filter_topic_id_list=[],test_score=False,must_topic_id_list=[],recommend_tag_list=[],
user_similar_score_list=[],index_type="topic"):
"""
:需增加打散逻辑
......@@ -224,14 +224,22 @@ class TopicUtils(object):
"weight": 1
}
)
for tag_id in recommend_tag_dict:
if len(recommend_tag_list)>0:
functions_list.append(
{
"filter": {"term": {"tag_list": tag_id}},
"weight": 3+recommend_tag_dict[tag_id]
"filter": {"terms": {"tag_list": recommend_tag_list}},
"weight": 3
}
)
# for tag_id in recommend_tag_dict:
# functions_list.append(
# {
# "filter": {"term": {"tag_list": tag_id}},
# "weight": recommend_tag_dict[tag_id]
# }
# )
low_content_level = 4 if query_type == TopicPageType.FIND_PAGE else 3
query_function_score = {
"query": {
......
......@@ -58,10 +58,15 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
tag_recommend_redis_key = "physical:linucb:tag_recommend:device_id:" + str(device_id)
recommend_tag_dict = dict()
# recommend_tag_dict = dict()
# tag_recommend_val = redis_client.get(tag_recommend_redis_key)
# if tag_recommend_val:
# recommend_tag_dict = json.loads(str(tag_recommend_val, encoding="utf-8"))
recommend_tag_list = list()
tag_recommend_val = redis_client.get(tag_recommend_redis_key)
if tag_recommend_val:
recommend_tag_dict = json.loads(str(tag_recommend_val, encoding="utf-8"))
recommend_tag_list = json.loads(str(tag_recommend_val, encoding="utf-8"))
recommend_topic_ids = []
have_read_topic_id_list = list()
......@@ -81,7 +86,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
topic_id_list = TopicUtils.get_recommend_topic_ids(user_id=user_id, tag_id=tag_id, offset=offset, size=size,
single_size=size,query=query, query_type=query_type,
filter_topic_id_list=have_read_topic_id_list,
recommend_tag_dict=recommend_tag_dict,
recommend_tag_list=recommend_tag_list,
user_similar_score_list=user_similar_score_redis_list,index_type="topic-high-star")
have_read_group_id_set = set()
have_read_user_id_set = set()
......
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