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
alpha
physical
Commits
44aabeea
Commit
44aabeea
authored
Mar 11, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'similar_sort' into 'master'
Similar sort See merge request
!156
parents
01f3273d
ae9414e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
30 deletions
+52
-30
linucb.py
linucb/views/linucb.py
+1
-1
topic.py
search/utils/topic.py
+18
-18
type_info.py
trans2es/type_info.py
+17
-0
topic_transfer.py
trans2es/utils/topic_transfer.py
+16
-11
No files found.
linucb/views/linucb.py
View file @
44aabeea
...
@@ -59,7 +59,7 @@ class LinUCB:
...
@@ -59,7 +59,7 @@ class LinUCB:
AaI_tmp
=
np
.
array
(
Aa_list
)
AaI_tmp
=
np
.
array
(
Aa_list
)
theta_tmp
=
np
.
array
(
theta_list
)
theta_tmp
=
np
.
array
(
theta_list
)
top_tag_list_len
=
len
(
tag_list
)
/
3
top_tag_list_len
=
int
(
len
(
tag_list
)
/
3
)
top_np_ind
=
np
.
argpartition
(
np
.
dot
(
xaT
,
theta_tmp
)
+
cls
.
alpha
*
np
.
sqrt
(
np
.
dot
(
np
.
dot
(
xaT
,
AaI_tmp
),
xa
)),
-
top_tag_list_len
)[
-
top_tag_list_len
:]
top_np_ind
=
np
.
argpartition
(
np
.
dot
(
xaT
,
theta_tmp
)
+
cls
.
alpha
*
np
.
sqrt
(
np
.
dot
(
np
.
dot
(
xaT
,
AaI_tmp
),
xa
)),
-
top_tag_list_len
)[
-
top_tag_list_len
:]
top_tag_list
=
list
()
top_tag_list
=
list
()
...
...
search/utils/topic.py
View file @
44aabeea
...
@@ -240,24 +240,24 @@ class TopicUtils(object):
...
@@ -240,24 +240,24 @@ class TopicUtils(object):
{
"term"
:
{
"has_image"
:
True
}},
{
"term"
:
{
"has_image"
:
True
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}}
{
"term"
:
{
"is_deleted"
:
False
}}
]
]
,
#
"should": [
"should"
:
[
#
{
{
#
"bool":{
"bool"
:{
#
"must":[
"must"
:[
#
{"term":{"has_image":True}},
{
"term"
:{
"has_image"
:
True
}},
#
{"term": {"has_video": False}}
{
"term"
:
{
"has_video"
:
False
}}
#
]
]
#
}
}
#
},{
},{
#
"bool":{
"bool"
:{
#
"must":{
"must"
:{
#
"term":{"has_video":True}
"term"
:{
"has_video"
:
True
}
#
}
}
#
}
}
#
}
}
#
],
],
#
"minimum_should_match":1
"minimum_should_match"
:
1
}
}
},
},
"score_mode"
:
"sum"
,
"score_mode"
:
"sum"
,
...
...
trans2es/type_info.py
View file @
44aabeea
...
@@ -171,18 +171,35 @@ class TypeInfo(object):
...
@@ -171,18 +171,35 @@ class TypeInfo(object):
)
)
def
insert_table_by_pk_list
(
self
,
sub_index_name
,
pk_list
,
es
=
None
,
use_batch_query_set
=
False
):
def
insert_table_by_pk_list
(
self
,
sub_index_name
,
pk_list
,
es
=
None
,
use_batch_query_set
=
False
):
begin
=
time
.
time
()
if
use_batch_query_set
:
if
use_batch_query_set
:
qs
=
self
.
queryset
qs
=
self
.
queryset
else
:
else
:
qs
=
self
.
model
.
objects
.
all
()
qs
=
self
.
model
.
objects
.
all
()
end
=
time
.
time
()
time0
=
end
-
begin
begin
=
time
.
time
()
instance_list
=
qs
.
filter
(
pk__in
=
pk_list
)
instance_list
=
qs
.
filter
(
pk__in
=
pk_list
)
end
=
time
.
time
()
time1
=
end
-
begin
begin
=
time
.
time
()
data_list
=
self
.
bulk_get_data
(
instance_list
)
data_list
=
self
.
bulk_get_data
(
instance_list
)
end
=
time
.
time
()
time2
=
end
-
begin
begin
=
time
.
time
()
self
.
elasticsearch_bulk_insert_data
(
self
.
elasticsearch_bulk_insert_data
(
sub_index_name
=
sub_index_name
,
sub_index_name
=
sub_index_name
,
data_list
=
data_list
,
data_list
=
data_list
,
es
=
es
,
es
=
es
,
)
)
end
=
time
.
time
()
time3
=
end
-
begin
logging
.
info
(
"duan add,insert_table_by_pk_list time cost:
%
ds,
%
ds,
%
ds,
%
ds"
%
(
time0
,
time1
,
time2
,
time3
))
def
insert_table_chunk
(
self
,
sub_index_name
,
table_chunk
,
es
=
None
):
def
insert_table_chunk
(
self
,
sub_index_name
,
table_chunk
,
es
=
None
):
try
:
try
:
...
...
trans2es/utils/topic_transfer.py
View file @
44aabeea
...
@@ -34,31 +34,36 @@ class TopicTransfer(object):
...
@@ -34,31 +34,36 @@ class TopicTransfer(object):
res
[
"group_id"
]
=
-
1
res
[
"group_id"
]
=
-
1
res
[
"share_num"
]
=
instance
.
share_num
res
[
"share_num"
]
=
instance
.
share_num
begin
=
time
.
time
()
res
[
"pick_id_list"
]
=
instance
.
get_pick_id_info
()
res
[
"pick_id_list"
]
=
instance
.
get_pick_id_info
()
end
=
time
.
time
()
time0
=
(
end
-
begin
)
begin
=
datetime
.
datetime
.
now
()
begin
=
time
.
time
()
(
topic_tag_id_list
,
edit_tag_id_list
)
=
instance
.
get_topic_tag_id_list
()
(
topic_tag_id_list
,
edit_tag_id_list
)
=
instance
.
get_topic_tag_id_list
()
res
[
"tag_list"
]
=
topic_tag_id_list
res
[
"tag_list"
]
=
topic_tag_id_list
res
[
"edit_tag_list"
]
=
edit_tag_id_list
res
[
"edit_tag_list"
]
=
edit_tag_id_list
end
=
datetime
.
datetime
.
now
()
end
=
time
.
time
()
time1
=
(
end
-
begin
)
.
seconds
time1
=
(
end
-
begin
)
begin
=
datetime
.
datetime
.
now
()
begin
=
time
.
time
()
res
[
"tag_name_list"
]
=
instance
.
get_tag_name_list
(
res
[
"tag_list"
])
res
[
"tag_name_list"
]
=
instance
.
get_tag_name_list
(
res
[
"tag_list"
])
end
=
datetime
.
datetime
.
now
()
end
=
time
.
time
()
time2
=
(
end
-
begin
)
.
seconds
time2
=
(
end
-
begin
)
begin
=
datetime
.
datetime
.
now
()
begin
=
time
.
time
()
res
[
"offline_score"
]
=
instance
.
get_topic_offline_score
()
res
[
"offline_score"
]
=
instance
.
get_topic_offline_score
()
end
=
datetime
.
datetime
.
now
()
end
=
time
.
time
()
time3
=
(
end
-
begin
)
.
seconds
time3
=
(
end
-
begin
)
begin
=
time
.
time
()
res
[
"manual_score"
]
=
instance
.
drop_score
res
[
"manual_score"
]
=
instance
.
drop_score
res
[
"has_image"
]
=
instance
.
topic_has_image
()
res
[
"has_image"
]
=
instance
.
topic_has_image
()
res
[
"has_video"
]
=
instance
.
has_video
res
[
"has_video"
]
=
instance
.
has_video
res
[
"language_type"
]
=
instance
.
language_type
res
[
"language_type"
]
=
instance
.
language_type
end
=
time
.
time
()
time4
=
(
end
-
begin
)
# # 片假名
# # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
...
@@ -85,7 +90,7 @@ class TopicTransfer(object):
...
@@ -85,7 +90,7 @@ class TopicTransfer(object):
res
[
"update_time"
]
=
tzlc_update_time
res
[
"update_time"
]
=
tzlc_update_time
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
tzlc_update_time
.
timetuple
()))
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
tzlc_update_time
.
timetuple
()))
logging
.
info
(
"test topic transfer time cost,time
1:
%
d,time2:
%
d,time3:
%
d"
%
(
time1
,
time2
,
time3
))
logging
.
info
(
"test topic transfer time cost,time
0:
%
d,time1:
%
d,time2:
%
d,time3:
%
d,time4:
%
d"
%
(
time0
,
time1
,
time2
,
time3
,
time4
))
return
res
return
res
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
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