Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
7d0cbfa6
Commit
7d0cbfa6
authored
Mar 28, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
a96c34ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
9 deletions
+22
-9
linucb.py
linucb/views/linucb.py
+2
-2
topic.py
search/utils/topic.py
+12
-4
topic.py
search/views/topic.py
+8
-3
No files found.
linucb/views/linucb.py
View file @
7d0cbfa6
...
...
@@ -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
)))
...
...
search/utils/topic.py
View file @
7d0cbfa6
...
...
@@ -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"
:
{
"term
s"
:
{
"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"
:
{
...
...
search/views/topic.py
View file @
7d0cbfa6
...
...
@@ -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_
dic
t
=
json
.
loads
(
str
(
tag_recommend_val
,
encoding
=
"utf-8"
))
recommend_tag_
lis
t
=
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_dic
t
,
recommend_tag_
list
=
recommend_tag_lis
t
,
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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment