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
0b096784
Commit
0b096784
authored
Jan 28, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
41fde29d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
commons.py
trans2es/commons/commons.py
+12
-15
No files found.
trans2es/commons/commons.py
View file @
0b096784
...
@@ -40,17 +40,15 @@ def get_tips_suggest_list(instance_cn_name):
...
@@ -40,17 +40,15 @@ def get_tips_suggest_list(instance_cn_name):
cur_index
=
0
cur_index
=
0
# 中文
# 中文
for
i
in
range
(
len
(
ch_full_word
)):
for
i
in
range
(
len
(
ch_full_word
)):
for
j
in
range
(
i
,
len
(
ch_full_word
)
+
1
):
#
for j in range(i, len(ch_full_word) + 1):
ch_name_term
=
ch_full_word
[
i
:
j
]
.
strip
()
ch_name_term
=
ch_full_word
[
i
]
.
strip
()
if
ch_name_term
:
if
ch_name_term
:
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
prefix_weight
=
ch_prefix_weight
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
ch_full_weight
ch_full_word
)
else
ch_full_weight
suggest_type
=
0
if
len
(
ch_name_term
)
!=
len
(
ch_full_word
)
else
1
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
=
{
suggest_item
=
{
"input"
:
[
ch_name_term
],
"input"
:
[
ch_name_term
],
"word_weight"
:
(
1.0
*
len
(
ch_name_term
)
/
len
(
"word_weight"
:
(
1.0
*
len
(
ch_name_term
)
/
len
((
ch_full_word
)))
*
prefix_weight
,
(
ch_full_word
)))
*
prefix_weight
*
term_begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
@@ -59,17 +57,16 @@ def get_tips_suggest_list(instance_cn_name):
...
@@ -59,17 +57,16 @@ def get_tips_suggest_list(instance_cn_name):
# 拼音
# 拼音
for
i
in
range
(
len
(
py_full_word
)):
for
i
in
range
(
len
(
py_full_word
)):
for
j
in
range
(
i
,
len
(
py_full_word
)
+
1
):
#
for j in range(i, len(py_full_word) + 1):
py_name_term
=
py_full_word
[
i
:
j
]
.
strip
()
py_name_term
=
py_full_word
[
i
]
.
strip
()
if
py_name_term
:
if
py_name_term
:
prefix_weight
=
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
prefix_weight
=
py_prefix_weight
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
py_full_weight
py_full_word
)
else
py_full_weight
suggest_type
=
2
if
len
(
py_name_term
)
!=
len
(
py_full_word
)
else
3
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
=
{
suggest_item
=
{
"input"
:
[
py_name_term
],
"input"
:
[
py_name_term
],
"word_weight"
:
(
1.0
*
len
(
py_name_term
)
/
len
(
"word_weight"
:
(
1.0
*
len
(
py_name_term
)
/
len
(
py_full_word
))
*
prefix_weight
,
py_full_word
))
*
prefix_weight
*
term_begin_prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
@@ -78,17 +75,17 @@ def get_tips_suggest_list(instance_cn_name):
...
@@ -78,17 +75,17 @@ def get_tips_suggest_list(instance_cn_name):
# 简写
# 简写
for
i
in
range
(
len
(
py_acronym_full_word
)):
for
i
in
range
(
len
(
py_acronym_full_word
)):
for
j
in
range
(
i
,
len
(
py_acronym_full_word
)
+
1
):
#
for j in range(i, len(py_acronym_full_word) + 1):
py_acronym_term
=
py_acronym_full_word
[
i
:
j
]
.
strip
()
py_acronym_term
=
py_acronym_full_word
[
i
:
j
]
.
strip
()
if
py_acronym_term
:
if
py_acronym_term
:
prefix_weight
=
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
prefix_weight
=
py_acronym_prefix_weight
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
py_acronym_full_weight
py_acronym_full_word
)
else
py_acronym_full_weight
suggest_type
=
4
if
len
(
py_acronym_term
)
!=
len
(
py_acronym_full_word
)
else
5
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
=
{
suggest_item
=
{
"input"
:
[
py_acronym_term
],
"input"
:
[
py_acronym_term
],
"word_weight"
:
(
1.0
*
len
(
py_acronym_term
)
/
len
(
"word_weight"
:
(
1.0
*
len
(
py_acronym_term
)
/
len
(
py_acronym_full_word
))
*
prefix_weight
*
term_begin_
prefix_weight
,
py_acronym_full_word
))
*
prefix_weight
,
"suggest_type"
:
suggest_type
,
"suggest_type"
:
suggest_type
,
"cur_index"
:
cur_index
"cur_index"
:
cur_index
}
}
...
...
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