Commit ca91e80d authored by 段英荣's avatar 段英荣

modify

parent 2007a2e9
...@@ -15,7 +15,7 @@ from libs.tools import point_distance ...@@ -15,7 +15,7 @@ from libs.tools import point_distance
def get_suggest_tips(query,lat,lng,offset=0,size=50): def get_suggest_tips(query,lat,lng,offset=0,size=50):
try: try:
# ios输入法在某些情况下会携带\\u2006 # ios输入法在某些情况下会携带\\u2006
query = query.replace("\\u2006", '') query = query.replace("\u2006", '')
q = { q = {
"suggest":{ "suggest":{
"tips-suggest": { "tips-suggest": {
......
...@@ -62,54 +62,55 @@ def get_tips_suggest_list(instance_cn_name): ...@@ -62,54 +62,55 @@ def get_tips_suggest_list(instance_cn_name):
suggest_dict[ch_name_term[0]]["suggest_type"] = suggest_item["suggest_type"] suggest_dict[ch_name_term[0]]["suggest_type"] = suggest_item["suggest_type"]
# 拼音 # 拼音
for i in range(len(py_full_word)): if py_full_word != ch_full_word:
#for j in range(i, len(py_full_word) + 1): for i in range(len(py_full_word)):
py_name_term = py_full_word[i:].strip() #for j in range(i, len(py_full_word) + 1):
if py_name_term: py_name_term = py_full_word[i:].strip()
prefix_weight = py_prefix_weight if len(py_name_term) != len( if py_name_term:
py_full_word) else py_full_weight prefix_weight = py_prefix_weight if len(py_name_term) != len(
suggest_type = 2 if len(py_name_term) != len(py_full_word) else 3 py_full_word) else py_full_weight
#term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0 suggest_type = 2 if len(py_name_term) != len(py_full_word) else 3
suggest_item = { #term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0
"input": [py_name_term], suggest_item = {
"word_weight": (1.0 * len(py_name_term) / len(py_full_word)) * prefix_weight, "input": [py_name_term],
"suggest_type": suggest_type "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 if py_name_term[0] not in suggest_dict:
suggest_item["cur_index"] = cur_index cur_index += 1
suggest_dict[py_name_term[0]] = suggest_item suggest_item["cur_index"] = cur_index
else: suggest_dict[py_name_term[0]] = suggest_item
suggest_dict[py_name_term[0]]["input"].append(py_name_term) else:
if suggest_item["word_weight"] > suggest_dict[py_name_term[0]]["word_weight"]: suggest_dict[py_name_term[0]]["input"].append(py_name_term)
suggest_dict[py_name_term[0]]["word_weight"] = suggest_item["word_weight"] if suggest_item["word_weight"] > suggest_dict[py_name_term[0]]["word_weight"]:
suggest_dict[py_name_term[0]]["suggest_type"] = suggest_item["suggest_type"] 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)): if py_acronym_full_word != py_full_word:
#for j in range(i, len(py_acronym_full_word) + 1): for i in range(len(py_acronym_full_word)):
py_acronym_term = py_acronym_full_word[i:].strip() #for j in range(i, len(py_acronym_full_word) + 1):
if py_acronym_term: py_acronym_term = py_acronym_full_word[i:].strip()
prefix_weight = py_acronym_prefix_weight if len(py_acronym_term) != len( if py_acronym_term:
py_acronym_full_word) else py_acronym_full_weight prefix_weight = py_acronym_prefix_weight if len(py_acronym_term) != len(
suggest_type = 4 if len(py_acronym_term) != len(py_acronym_full_word) else 5 py_acronym_full_word) else py_acronym_full_weight
#term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0 suggest_type = 4 if len(py_acronym_term) != len(py_acronym_full_word) else 5
suggest_item = { #term_begin_prefix_weight = begin_prefix_weight if i == 0 else 1.0
"input": [py_acronym_term], suggest_item = {
"word_weight": (1.0 * len(py_acronym_term) / len( "input": [py_acronym_term],
py_acronym_full_word)) * prefix_weight, "word_weight": (1.0 * len(py_acronym_term) / len(
"suggest_type": suggest_type, py_acronym_full_word)) * prefix_weight,
"cur_index": cur_index "suggest_type": suggest_type
} }
if py_acronym_term[0] not in suggest_dict: if py_acronym_term[0] not in suggest_dict:
cur_index += 1 cur_index += 1
suggest_item["cur_index"] = cur_index suggest_item["cur_index"] = cur_index
suggest_dict[py_acronym_term[0]] = suggest_item suggest_dict[py_acronym_term[0]] = suggest_item
else: else:
suggest_dict[py_acronym_term[0]]["input"].append(py_acronym_term) suggest_dict[py_acronym_term[0]]["input"].append(py_acronym_term)
if suggest_item["word_weight"] > suggest_dict[py_acronym_term[0]]["word_weight"]: 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]]["word_weight"] = suggest_item["word_weight"]
suggest_dict[py_acronym_term[0]]["suggest_type"] = suggest_item["suggest_type"] suggest_dict[py_acronym_term[0]]["suggest_type"] = suggest_item["suggest_type"]
return suggest_dict.values() return suggest_dict.values()
except: except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment