Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
8e14a43a
Commit
8e14a43a
authored
Mar 17, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add merge list
parent
5d5b4817
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
new_tag3_cold_start.py
eda/smart_rank/new_tag3_cold_start.py
+19
-5
No files found.
eda/smart_rank/new_tag3_cold_start.py
View file @
8e14a43a
import
json
from
itertools
import
chain
,
zip_longest
import
redis
from
es_tool
import
es_query
def
merge_lists
(
*
lol
):
a
=
zip_longest
(
*
lol
)
return
[
i
for
i
in
chain
(
*
a
)
if
i
is
not
None
]
keywords
=
[
"瘦脸"
,
"双眼皮"
,
"补水"
,
"美白嫩肤"
,
"瘦小腿"
,
"除皱"
,
"隆鼻"
,
"牙齿矫正"
,
"脱毛"
,
"祛斑"
,
"控油"
,
"面部祛脂"
,
"隆胸"
,
"垫鼻基底"
,
"缩鼻翼"
,
"生头发"
,
"开眼角"
,
"瘦肩"
,
"祛痘"
,
"缩毛孔"
,
"轮廓改善"
,
"除眼底细纹"
,
"眼部修复"
,
"垫下巴"
,
"颧骨内推"
,
"除法令纹"
,
"缩咬肌"
,
"瘦臀部"
,
"丰眼窝"
,
"瘦手臂"
,
"丰唇"
,
"瘦腰腹"
,
"瘦大腿"
,
"填充泪沟"
,
"洁面"
,
"除面部细纹"
,
...
...
@@ -124,15 +131,22 @@ def get_es_diary(keywords, city_tag_id=-1, version=False):
}
q
[
"sort"
]
=
sort_list
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"second_demands"
]}
es_res
=
es_query
(
"diary"
,
q
,
offset
=
0
,
size
=
500
)
diary_
pairs
=
[]
es_res
=
es_query
(
"diary"
,
q
,
offset
=
0
,
size
=
500
0
)
diary_
dict
=
{}
for
diary_info
in
es_res
[
"hits"
][
"hits"
]:
sd
=
""
second_demands
=
diary_info
[
"_source"
]
.
get
(
"second_demands"
,
[])
if
second_demands
and
len
(
second_demands
)
>
0
:
id
=
diary_info
[
"_source"
][
"id"
]
sd
=
second_demands
[
0
]
diary_pairs
.
append
((
diary_info
[
"_source"
][
"id"
],
sd
))
return
diary_pairs
if
sd
not
in
diary_dict
:
diary_dict
[
sd
]
=
[
id
]
else
:
diary_dict
[
sd
]
.
append
(
id
)
res_pair
=
sorted
(
diary_dict
.
items
(),
key
=
lambda
x
:
len
(
x
[
1
]),
reverse
=
True
)
res_list
=
[]
for
_
,
v
in
res_pair
:
res_list
.
append
(
v
)
return
merge_lists
(
res_list
)
if
__name__
==
"__main__"
:
...
...
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