Commit a8a7bb49 authored by lixiaofang's avatar lixiaofang

add

parents 8ca59f88 77676def
...@@ -24,29 +24,5 @@ ...@@ -24,29 +24,5 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" /> <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings> </formatting-settings>
</DBN-SQL> </DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme> </code_scheme>
</component> </component>
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# !/usr/bin/env python # !/usr/bin/env python
from kafka import KafkaConsumer from kafka import KafkaConsumer
import random
from libs.cache import redis_client from libs.cache import redis_client
import logging import logging
from linucb.views.linucb import LinUCB from linucb.views.linucb import LinUCB
...@@ -73,8 +74,9 @@ class CollectData(object): ...@@ -73,8 +74,9 @@ class CollectData(object):
have_read_topic_id_list = Tools.get_have_read_topic_id_list(device_id,-1,TopicPageType.HOME_RECOMMEND) have_read_topic_id_list = Tools.get_have_read_topic_id_list(device_id,-1,TopicPageType.HOME_RECOMMEND)
recommend_topic_id_list = list() recommend_topic_id_list = list()
for index in range(0,1000): for index in range(0,100):
for tag_id in recommend_tag_list[0:5]: recommend_topic_id_list_random = list()
for tag_id in recommend_tag_list[0:100]:
redis_tag_id_key = self.tag_topic_id_redis_prefix + str(tag_id) redis_tag_id_key = self.tag_topic_id_redis_prefix + str(tag_id)
redis_tag_id_data = redis_client.get(redis_tag_id_key) redis_tag_id_data = redis_client.get(redis_tag_id_key)
tag_topic_id_list = json.loads(redis_tag_id_data) if redis_tag_id_data else [] tag_topic_id_list = json.loads(redis_tag_id_data) if redis_tag_id_data else []
...@@ -86,8 +88,10 @@ class CollectData(object): ...@@ -86,8 +88,10 @@ class CollectData(object):
if len(tag_topic_id_list)>index: if len(tag_topic_id_list)>index:
for topic_id in tag_topic_id_list[index:]: for topic_id in tag_topic_id_list[index:]:
if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list: if topic_id not in have_read_topic_id_list and topic_id not in recommend_topic_id_list:
recommend_topic_id_list.append(topic_id) recommend_topic_id_list_random.append(topic_id)
break break
random.shuffle(recommend_topic_id_list_random)
recommend_topic_id_list.extend(recommend_topic_id_list_random)
topic_recommend_redis_key = self.linucb_recommend_topic_id_prefix + str(device_id) topic_recommend_redis_key = self.linucb_recommend_topic_id_prefix + str(device_id)
redis_data_dict = { redis_data_dict = {
......
...@@ -165,7 +165,7 @@ class TopicUtils(object): ...@@ -165,7 +165,7 @@ class TopicUtils(object):
"language_type": 1 "language_type": 1
} }
}, },
"weight": 6 "weight": 60
}, },
{ {
"gauss": { "gauss": {
...@@ -174,7 +174,7 @@ class TopicUtils(object): ...@@ -174,7 +174,7 @@ class TopicUtils(object):
"decay": 0.99 "decay": 0.99
} }
}, },
"weight": 5 "weight": 60
} }
] ]
...@@ -194,7 +194,7 @@ class TopicUtils(object): ...@@ -194,7 +194,7 @@ class TopicUtils(object):
{ {
"filter": {"bool": { "filter": {"bool": {
"should": {"terms": {"user_id": attention_user_id_list}}}}, "should": {"terms": {"user_id": attention_user_id_list}}}},
"weight": 3, "weight": 30,
} }
) )
# if len(pick_user_id_list) > 0: # if len(pick_user_id_list) > 0:
......
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