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
a4538334
Commit
a4538334
authored
Jul 01, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotword_tag' into 'master'
修改标签 See merge request
!378
parents
165a5238
10baf678
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
28 deletions
+56
-28
Project.xml
.idea/codeStyles/Project.xml
+25
-0
tasks.py
injection/data_sync/tasks.py
+10
-4
search_hotword.py
search/views/search_hotword.py
+13
-17
pictorial.json
trans2es/mapping/pictorial.json
+3
-3
tag.py
trans2es/models/tag.py
+5
-4
No files found.
.idea/codeStyles/Project.xml
View file @
a4538334
...
@@ -24,5 +24,29 @@
...
@@ -24,5 +24,29 @@
<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
injection/data_sync/tasks.py
View file @
a4538334
...
@@ -15,7 +15,7 @@ from libs.es import ESPerform
...
@@ -15,7 +15,7 @@ from libs.es import ESPerform
from
libs.cache
import
redis_client
from
libs.cache
import
redis_client
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
,
UserSimilarScore
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
,
UserSimilarScore
from
linucb.utils.register_user_tag
import
RegisterUserTag
from
linucb.utils.register_user_tag
import
RegisterUserTag
from
trans2es.models.tag
import
RegisterShowTa
g
,
Tag
from
trans2es.models.tag
import
SettingsConfi
g
,
Tag
@shared_task
@shared_task
...
@@ -113,16 +113,22 @@ def sync_user_similar_score():
...
@@ -113,16 +113,22 @@ def sync_user_similar_score():
def
get_tag_count
():
def
get_tag_count
():
try
:
try
:
# 获取搜索推荐热词
# 获取搜索推荐热词
results_registr_tag
=
list
(
set
(
RegisterShowTag
.
objects
.
filter
(
is_deleted
=
False
,
is_online
=
1
)
.
values_list
(
"tag_id"
,
flat
=
True
)))
# results_registr_tag = list(set(SettingsConfig.objects.filter(is_deleted=False).values_list("val", flat=True)))
# tag_val_list =set()
# for item in results_registr_tag:
# for word in item.split():
# tag_val_list.add(word)
# 获取符合条件的核心词
# 获取符合条件的核心词
results_tag
=
list
(
set
(
Tag
.
objects
.
filter
(
is_online
=
True
,
is_deleted
=
False
,
collection
=
1
)
.
values_list
(
"id"
,
flat
=
True
)))
results_tag
=
list
(
set
(
Tag
.
objects
.
filter
(
is_online
=
True
,
is_deleted
=
False
,
collection
=
1
)
.
values_list
(
"id"
,
flat
=
True
)))
redis_registr_tag
=
"physical:search_hotword:results_registr_tag"
redis_registr_tag
=
"physical:search_hotword:results_registr_tag"
redis_tag
=
"physical:search_hotword:results_tag"
redis_tag
=
"physical:search_hotword:results_tag"
redis_client
.
set
(
redis_registr_tag
,
list
(
results_registr_tag
))
#
redis_client.set(redis_registr_tag, list(results_registr_tag))
redis_client
.
set
(
redis_tag
,
list
(
results_tag
))
redis_client
.
set
(
redis_tag
,
list
(
results_tag
))
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
search/views/search_hotword.py
View file @
a4538334
...
@@ -12,7 +12,7 @@ from search.utils.group import GroupUtils
...
@@ -12,7 +12,7 @@ from search.utils.group import GroupUtils
from
search.utils.common
import
GroupSortTypes
from
search.utils.common
import
GroupSortTypes
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.tag
import
RegisterShowTa
g
,
Tag
from
trans2es.models.tag
import
SettingsConfi
g
,
Tag
from
libs.cache
import
redis_client
from
libs.cache
import
redis_client
...
@@ -33,25 +33,20 @@ def search_hotword(device_id=-1):
...
@@ -33,25 +33,20 @@ def search_hotword(device_id=-1):
"""
"""
try
:
try
:
all_tag_name_list
=
set
()
all_tag_name_list
=
set
()
results_registr_tag
=
json
.
loads
(
redis_client
.
get
(
"physical:search_hotword:results_registr_tag"
))
#
results_registr_tag = json.loads(redis_client.get("physical:search_hotword:results_registr_tag"))
results_tag
=
json
.
loads
(
redis_client
.
get
(
"physical:search_hotword:results_tag"
))
results_tag
=
json
.
loads
(
redis_client
.
get
(
"physical:search_hotword:results_tag"
))
# 先获取搜索推荐热词
# 先获取搜索推荐热词
for
num
in
range
(
0
,
len
(
results_registr_tag
)
-
1
):
results_registr_tag
=
list
(
set
(
SettingsConfig
.
objects
.
filter
(
is_deleted
=
False
)
.
values_list
(
"val"
,
flat
=
True
)))
tag_id
=
random
.
randint
(
0
,
len
(
results_registr_tag
)
-
1
)
tag_val_list
=
set
()
results_tag_chose
=
list
(
for
item
in
results_registr_tag
:
set
(
RegisterShowTag
.
objects
.
filter
(
tag_id
=
results_registr_tag
[
tag_id
],
is_online
=
True
)
.
values_list
(
for
word
in
item
.
split
():
"tag_id"
,
flat
=
True
)))
tag_val_list
.
add
(
word
)
if
results_tag_chose
:
tag_id_list
=
random
.
sample
(
range
(
0
,
len
(
tag_val_list
)),
6
)
results_tag_recommend
=
list
(
for
tag_id
in
tag_id_list
:
set
(
Tag
.
objects
.
filter
(
id
=
results_tag_chose
[
0
],
is_online
=
True
)
.
values_list
(
"name"
,
tag_val
=
list
(
tag_val_list
)[
tag_id
]
flat
=
True
)))
all_tag_name_list
.
add
(
tag_val
)
if
results_tag_recommend
:
all_tag_name_list
.
add
(
results_tag_recommend
[
0
])
if
len
(
all_tag_name_list
)
==
6
or
num
==
results_tag
:
break
logging
.
info
(
"get all_tag_name_list:
%
s"
%
all_tag_name_list
)
logging
.
info
(
"get all_tag_name_list:
%
s"
%
all_tag_name_list
)
# 获取个性化标签
# 获取个性化标签
linucb_recommend_redis_prefix
=
"physical:linucb:tag_recommend:device_id:"
linucb_recommend_redis_prefix
=
"physical:linucb:tag_recommend:device_id:"
tag_recommend_redis_key
=
linucb_recommend_redis_prefix
+
str
(
device_id
)
tag_recommend_redis_key
=
linucb_recommend_redis_prefix
+
str
(
device_id
)
...
@@ -84,3 +79,4 @@ def search_hotword(device_id=-1):
...
@@ -84,3 +79,4 @@ def search_hotword(device_id=-1):
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"recommend_tag_name"
:
[]}
return
{
"recommend_tag_name"
:
[]}
trans2es/mapping/pictorial.json
View file @
a4538334
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"is_deleted"
:{
"type"
:
"boolean"
},
"is_recommend"
:{
"type"
:
"boolean"
},
"is_recommend"
:{
"type"
:
"boolean"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
index
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
search
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
index
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
search
"
},
"topic_num"
:{
"type"
:
"long"
},
"topic_num"
:{
"type"
:
"long"
},
"creator_id"
:{
"type"
:
"long"
},
"creator_id"
:{
"type"
:
"long"
},
"icon"
:{
"type"
:
"text"
},
"icon"
:{
"type"
:
"text"
},
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"create_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"create_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"tag_id"
:{
"type"
:
"long"
},
"tag_id"
:{
"type"
:
"long"
},
"tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
index
"
},
"tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_
search
"
},
"topic_id_list"
:{
"type"
:
"long"
},
"topic_id_list"
:{
"type"
:
"long"
},
"effective"
:{
"type"
:
"boolean"
},
"effective"
:{
"type"
:
"boolean"
},
"offline_score"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"long"
},
...
...
trans2es/models/tag.py
View file @
a4538334
...
@@ -96,13 +96,14 @@ class CommunityTagType(models.Model):
...
@@ -96,13 +96,14 @@ class CommunityTagType(models.Model):
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
RegisterShowTa
g
(
models
.
Model
):
class
SettingsConfi
g
(
models
.
Model
):
class
Meta
:
class
Meta
:
verbose_name
=
"搜索热词"
verbose_name
=
"搜索热词"
db_table
=
"
register_show_ta
g"
db_table
=
"
settingsconfi
g"
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
is_deleted
=
models
.
IntegerField
(
verbose_name
=
u"是否删除"
)
is_deleted
=
models
.
IntegerField
(
verbose_name
=
u"是否删除"
)
is_online
=
models
.
IntegerField
(
verbose_name
=
u"是否在线"
)
key
=
models
.
IntegerField
(
verbose_name
=
u"值"
)
tag_id
=
models
.
IntegerField
(
verbose_name
=
"标签ID"
)
val
=
models
.
IntegerField
(
verbose_name
=
"标签内容"
)
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