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
ca91e80d
Commit
ca91e80d
authored
Jan 29, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
2007a2e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
auto_tips.py
search/utils/auto_tips.py
+1
-1
commons.py
trans2es/commons/commons.py
+47
-46
No files found.
search/utils/auto_tips.py
View file @
ca91e80d
...
...
@@ -15,7 +15,7 @@ from libs.tools import point_distance
def
get_suggest_tips
(
query
,
lat
,
lng
,
offset
=
0
,
size
=
50
):
try
:
# ios输入法在某些情况下会携带\\u2006
query
=
query
.
replace
(
"
\
\
u2006"
,
''
)
query
=
query
.
replace
(
"
\u2006
"
,
''
)
q
=
{
"suggest"
:{
"tips-suggest"
:
{
...
...
trans2es/commons/commons.py
View file @
ca91e80d
...
...
@@ -62,54 +62,55 @@ def get_tips_suggest_list(instance_cn_name):
suggest_dict
[
ch_name_term
[
0
]][
"suggest_type"
]
=
suggest_item
[
"suggest_type"
]
# 拼音
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
:]
.
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
suggest_item
=
{
"input"
:
[
py_name_term
],
"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_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_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
:]
.
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
suggest_item
=
{
"input"
:
[
py_name_term
],
"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_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"
]
# 简写
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
:]
.
strip
()
if
py_acronym_term
:
prefix_weight
=
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
p
y_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
suggest_item
=
{
"input"
:
[
py_acronym_term
],
"word_weight"
:
(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
}
if
py_acronym_term
[
0
]
not
in
suggest_dict
:
cur_index
+=
1
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"
]
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
:]
.
strip
()
if
py_acronym_term
:
p
refix_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
suggest_item
=
{
"input"
:
[
py_acronym_term
],
"word_weight"
:
(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
,
"suggest_type"
:
suggest_type
}
if
py_acronym_term
[
0
]
not
in
suggest_dict
:
cur_index
+=
1
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_dict
.
values
()
except
:
...
...
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