Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
search_tips
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
rank
search_tips
Commits
d9111408
Commit
d9111408
authored
Jun 11, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
8ebb295a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
34 deletions
+11
-34
auto_tips.py
search/utils/auto_tips.py
+0
-3
words_utils.py
trans2es/commons/words_utils.py
+0
-4
type_info.py
trans2es/type_info.py
+11
-24
wordresemble.py
trans2es/utils/wordresemble.py
+0
-3
No files found.
search/utils/auto_tips.py
View file @
d9111408
...
...
@@ -95,10 +95,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
QUERY_KEY
=
"query:{}:search_tips"
query_base64
=
base64
.
b64encode
(
query
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
key
=
QUERY_KEY
.
format
(
query_base64
)
logging
.
info
(
"get key:
%
s"
%
key
)
labels
=
list
(
map
(
lambda
x
:
x
.
decode
(
"utf8"
),
list
(
redis_client
.
smembers
(
key
))))
logging
.
info
(
"get labels:
%
s"
%
labels
)
for
i
in
labels
:
ori
=
i
.
split
(
":"
)[
0
]
ori_name
=
base64
.
b64decode
(
ori
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
...
...
trans2es/commons/words_utils.py
View file @
d9111408
...
...
@@ -170,7 +170,6 @@ from gm_types.doris import MIND_TYPE
QUERY_KEY
=
"query:{}:set"
LABEL_VALUE
=
{
MIND_TYPE
.
PROJECT
:
8
,
MIND_TYPE
.
HOSPITAL
:
7
,
...
...
@@ -202,8 +201,5 @@ def get_tips_word_type(query=''):
labels
.
append
(
MIND_TYPE
.
UNKNOWN
)
if
query
in
QUERY_WORD_LABEL_NEED_MODIFIED
:
labels
.
append
(
MIND_TYPE
.
PROJECT
)
logging
.
info
(
"get labels:
%
s"
%
labels
)
labels
.
sort
(
key
=
label_key
,
reverse
=
True
)
return
labels
[
0
]
trans2es/type_info.py
View file @
d9111408
...
...
@@ -147,18 +147,6 @@ class TypeInfo(object):
suggest_dict
[
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
suggest_dict
[
"offline_score"
]
=
suggest_item
[
"word_weight"
]
+
suggest_dict
[
"order_weight"
]
suggest_dict
[
"id"
]
=
str
(
suggest_dict
[
"id"
])
+
"_"
+
str
(
suggest_item
[
"cur_index"
])
# if suggest_item["suggest_type"] == 1 and item_dict["tips_name_type"] == 4:
# for resemble in resemble_list:
# suggest_item["input"].append(str(resemble))
#
# suggest_dict["suggest"] = {
# "input": suggest_item["input"],
# "weight": int(suggest_dict["offline_score"]),
# "contexts": {
# "is_online": suggest_dict["is_online"]
# }
# }
# else:
suggest_dict
[
"suggest"
]
=
{
"input"
:
suggest_item
[
"input"
],
"weight"
:
int
(
suggest_dict
[
"offline_score"
]),
...
...
@@ -167,18 +155,17 @@ class TypeInfo(object):
}
}
data_list
.
append
(
suggest_dict
)
# if item_dict["tips_name_type"] != 4:
for
resemble_item
in
resemble_list
:
resemble_dict
=
copy
.
deepcopy
(
suggest_dict
)
resemble_dict
[
"id"
]
=
suggest_dict
[
"id"
]
+
"_"
+
getMd5Digest
(
resemble_item
)
resemble_dict
[
"ori_name"
]
=
resemble_item
resemble_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
resemble_item
)
resemble_dict
[
"offline_score"
]
=
0
resemble_dict
[
"suggest"
][
"weight"
]
=
0
data_list
.
append
(
resemble_dict
)
# else:
# pass
if
item_dict
[
"tips_name_type"
]
!=
4
:
for
resemble_item
in
resemble_list
:
resemble_dict
=
copy
.
deepcopy
(
suggest_dict
)
resemble_dict
[
"id"
]
=
suggest_dict
[
"id"
]
+
"_"
+
getMd5Digest
(
resemble_item
)
resemble_dict
[
"ori_name"
]
=
resemble_item
resemble_dict
[
"results_num"
]
=
QueryWordAttr
.
get_query_results_num
(
resemble_item
)
resemble_dict
[
"offline_score"
]
=
0
resemble_dict
[
"suggest"
][
"weight"
]
=
0
data_list
.
append
(
resemble_dict
)
else
:
pass
except
Exception
:
traceback
.
print_exc
()
logging
.
exception
(
'bulk_get_data for name={}, doc_type={}, pk={}'
.
format
(
...
...
trans2es/utils/wordresemble.py
View file @
d9111408
...
...
@@ -151,11 +151,9 @@ class WordResemble(object):
# result = wordresemble.WordRel.objects.all().values("keyword", "id")
# for wordrm in result:
logging
.
info
(
"get instance:
%
s"
%
instance
.
keyword
)
query_sql_item
=
wordresemble
.
WordRel
.
objects
.
filter
(
keyword
=
instance
.
keyword
)
for
sql_obj
in
query_sql_item
:
words
=
list
(
sql_obj
.
all_resembles
.
all
()
.
values_list
(
'word'
,
flat
=
True
))
logging
.
info
(
"get words:
%
s"
%
words
)
for
items
in
words
:
# 先存储本体词
query_base64
=
base64
.
b64encode
(
instance
.
keyword
.
encode
(
'utf8'
))
.
decode
(
'utf8'
)
...
...
@@ -170,7 +168,6 @@ class WordResemble(object):
total_count
=
int
(
redis_val_dict
[
't'
])
# 存储到Redis
logging
.
info
(
"get items:
%
s"
%
items
)
value
=
value_name
+
str
(
":"
+
str
(
total_count
))
redis_client
.
sadd
(
key
,
value
)
...
...
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