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
957f5c0c
Commit
957f5c0c
authored
Jan 29, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!4
parents
79bb15a3
ca91e80d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
33 deletions
+107
-33
Dockerfile
Dockerfile
+54
-0
auto_tips.py
search/utils/auto_tips.py
+5
-3
commons.py
trans2es/commons/commons.py
+47
-30
type_info.py
trans2es/type_info.py
+1
-0
No files found.
Dockerfile
0 → 100644
View file @
957f5c0c
FROM
harbor.test.gengmei/base/gm-alpine:v1.3
COPY
./requirements.txt /tmp
RUN
apk add
--no-cache
--virtual
.build-deps
\
bzip2-dev
\
coreutils
\
dpkg-dev dpkg
\
expat-dev
\
findutils
\
gcc
\
gdbm-dev
\
libc-dev
\
libffi-dev
\
libnsl-dev
\
libressl-dev
\
libtirpc-dev
\
linux-headers
\
make
\
ncurses-dev
\
pax-utils
\
readline-dev
\
sqlite-dev
\
tcl-dev
\
tk
\
tk-dev
\
xz-dev
\
zlib-dev
\
# 业务相关依赖和安装工具
linux-headers \
python3-dev \
librdkafka-dev \
mariadb-client \
mariadb-dev \
git \
openssh \
\
&& apk add --no-cache jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
# 取消ssh第一次链接的确认
&& echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config \
&& apk add --no-cache mariadb-connector-c-dev libxml2-dev libxslt-dev librdkafka-dev \
&& pip install --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /tmp/requirements.txt \
&& apk del .build-deps \
&& mkdir -p /data/log/search_tips/app
ENV
GM_RPCD_DEPLOY_CONF_PATH "/srv/apps/search_tips/app_conf.xml" \
DJANGO_SETTINGS_MODULE=search_tips.settings
COPY
. /srv/apps/search_tips/
WORKDIR
/srv/apps/search_tips/
CMD
gunicorn search_tips.wsgi:application -w 1 -k gevent -b 0.0.0.0:8000
search/utils/auto_tips.py
View file @
957f5c0c
...
...
@@ -12,15 +12,17 @@ from libs.tools import g_hospital_pos_dict
from
libs.tools
import
point_distance
def
get_suggest_tips
(
query
,
lat
,
lng
,
offset
=
0
,
size
=
10
0
):
def
get_suggest_tips
(
query
,
lat
,
lng
,
offset
=
0
,
size
=
5
0
):
try
:
# ios输入法在某些情况下会携带\\u2006
query
=
query
.
replace
(
"
\u2006
"
,
''
)
q
=
{
"suggest"
:{
"tips-suggest"
:
{
"prefix"
:
query
,
"completion"
:
{
"field"
:
"suggest"
,
"size"
:
size
"size"
:
size
}
}
},
...
...
@@ -47,7 +49,7 @@ def get_suggest_tips(query,lat,lng,offset=0,size=100):
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
distance
)
+
"米"
else
:
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
1.0
*
distance
/
1000
)
+
"km"
hit_item
[
"_source"
][
"describe"
]
=
"约"
+
str
(
round
(
1.0
*
distance
/
1000
,
1
)
)
+
"km"
else
:
hit_item
[
"_source"
][
"describe"
]
=
">1000km"
else
:
...
...
trans2es/commons/commons.py
View file @
957f5c0c
...
...
@@ -21,81 +21,98 @@ def uuid4():
def
get_tips_suggest_list
(
instance_cn_name
):
try
:
ch_full_weight
=
6.0
*
1000
0
py_full_weight
=
3.0
*
1000
0
py_acronym_full_weight
=
3.0
*
1000
0
ch_full_weight
=
6.0
*
1000
py_full_weight
=
3.0
*
1000
py_acronym_full_weight
=
3.0
*
1000
py_acronym_prefix_weight
=
2
ch_prefix_weight
=
1.5
py_prefix_weight
=
1.0
# 命中开始部分加权
begin_prefix_weight
=
1.2
*
1000
0
begin_prefix_weight
=
1.2
*
1000
ch_full_word
=
instance_cn_name
.
strip
()
py_full_word
=
''
.
join
(
lazy_pinyin
(
ch_full_word
))
py_acronym_full_word
=
''
.
join
(
lazy_pinyin
(
ch_full_word
,
style
=
pypinyin
.
FIRST_LETTER
))
suggest_
list
=
lis
t
()
suggest_
dict
=
dic
t
()
cur_index
=
0
# 中文
for
i
in
range
(
len
(
ch_full_word
)):
for
j
in
range
(
i
,
len
(
ch_full_word
)
+
1
):
ch_name_term
=
ch_full_word
[
i
:
j
]
.
strip
()
#
for j in range(i, len(ch_full_word) + 1):
ch_name_term
=
ch_full_word
[
i
:
]
.
strip
()
if
ch_name_term
:
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
ch_full_weight
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
ch_full_weight
suggest_type
=
0
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
1
term_begin_prefix_weight
=
begin_prefix_weight
if
i
==
0
else
1.0
#
term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0
suggest_item
=
{
"input"
:
[
ch_name_term
],
"word_weight"
:
(
1.0
*
len
(
ch_name_term
)
/
len
(
(
ch_full_word
)))
*
prefix_weight
*
term_begin_prefix_weight
,
"word_weight"
:
(
1.0
*
len
(
ch_name_term
)
/
len
((
ch_full_word
)))
*
prefix_weight
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
}
if
ch_name_term
[
0
]
not
in
suggest_dict
:
cur_index
+=
1
suggest_list
.
append
(
suggest_item
)
suggest_item
[
"cur_index"
]
=
cur_index
suggest_dict
[
ch_name_term
[
0
]]
=
suggest_item
else
:
suggest_dict
[
ch_name_term
[
0
]][
"input"
]
.
append
(
ch_name_term
)
if
suggest_item
[
"word_weight"
]
>
suggest_dict
[
ch_name_term
[
0
]][
"word_weight"
]:
suggest_dict
[
ch_name_term
[
0
]][
"word_weight"
]
=
suggest_item
[
"word_weight"
]
suggest_dict
[
ch_name_term
[
0
]][
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
# 拼音
if
py_full_word
!=
ch_full_word
:
for
i
in
range
(
len
(
py_full_word
)):
for
j
in
range
(
i
,
len
(
py_full_word
)
+
1
):
py_name_term
=
py_full_word
[
i
:
j
]
.
strip
()
#
for j in range(i, len(py_full_word) + 1):
py_name_term
=
py_full_word
[
i
:]
.
strip
()
if
py_name_term
:
prefix_weight
=
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
py_full_weight
suggest_type
=
2
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
3
term_begin_prefix_weight
=
begin_prefix_weight
if
i
==
0
else
1.0
#
term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0
suggest_item
=
{
"input"
:
[
py_name_term
],
"word_weight"
:
(
1.0
*
len
(
py_name_term
)
/
len
(
py_full_word
))
*
prefix_weight
*
term_begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"word_weight"
:
(
1.0
*
len
(
py_name_term
)
/
len
(
py_full_word
))
*
prefix_weight
,
"suggest_type"
:
suggest_type
}
if
py_name_term
[
0
]
not
in
suggest_dict
:
cur_index
+=
1
suggest_list
.
append
(
suggest_item
)
suggest_item
[
"cur_index"
]
=
cur_index
suggest_dict
[
py_name_term
[
0
]]
=
suggest_item
else
:
suggest_dict
[
py_name_term
[
0
]][
"input"
]
.
append
(
py_name_term
)
if
suggest_item
[
"word_weight"
]
>
suggest_dict
[
py_name_term
[
0
]][
"word_weight"
]:
suggest_dict
[
py_name_term
[
0
]][
"word_weight"
]
=
suggest_item
[
"word_weight"
]
suggest_dict
[
py_name_term
[
0
]][
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
# 简写
if
py_acronym_full_word
!=
py_full_word
:
for
i
in
range
(
len
(
py_acronym_full_word
)):
for
j
in
range
(
i
,
len
(
py_acronym_full_word
)
+
1
):
py_acronym_term
=
py_acronym_full_word
[
i
:
j
]
.
strip
()
#
for j in range(i, len(py_acronym_full_word) + 1):
py_acronym_term
=
py_acronym_full_word
[
i
:]
.
strip
()
if
py_acronym_term
:
prefix_weight
=
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
py_acronym_full_weight
suggest_type
=
4
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
5
term_begin_prefix_weight
=
begin_prefix_weight
if
i
==
0
else
1.0
#
term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0
suggest_item
=
{
"input"
:
[
py_acronym_term
],
"word_weight"
:
(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
*
term_begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
py_acronym_full_word
))
*
prefix_weight
,
"suggest_type"
:
suggest_type
}
if
py_acronym_term
[
0
]
not
in
suggest_dict
:
cur_index
+=
1
suggest_list
.
append
(
suggest_item
)
suggest_item
[
"cur_index"
]
=
cur_index
suggest_dict
[
py_acronym_term
[
0
]]
=
suggest_item
else
:
suggest_dict
[
py_acronym_term
[
0
]][
"input"
]
.
append
(
py_acronym_term
)
if
suggest_item
[
"word_weight"
]
>
suggest_dict
[
py_acronym_term
[
0
]][
"word_weight"
]:
suggest_dict
[
py_acronym_term
[
0
]][
"word_weight"
]
=
suggest_item
[
"word_weight"
]
suggest_dict
[
py_acronym_term
[
0
]][
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
return
suggest_
list
return
suggest_
dict
.
values
()
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
...
...
trans2es/type_info.py
View file @
957f5c0c
...
...
@@ -133,6 +133,7 @@ class TypeInfo(object):
continue
data
=
self
.
get_data_func
(
instance
)
(
item_dict
,
suggest_list
)
=
data
for
suggest_item
in
suggest_list
:
suggest_dict
=
copy
.
deepcopy
(
item_dict
)
suggest_dict
[
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
...
...
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