修复BUG
This commit is contained in:
parent
d0785ae9b9
commit
49bfc52caa
4
main.py
4
main.py
|
@ -220,9 +220,11 @@ def print_max_group(all_idiom, group, num):
|
|||
print(item)
|
||||
|
||||
def get_max_group(all_idiom, group, num):
|
||||
result = list()
|
||||
if(len(group) == 0):
|
||||
return result
|
||||
group['pinyin_c'] = group.apply(lambda x: (math.log(x['frequency'], 2)/16 + 1) * len(set(trim_space(x['pinyin_r']))), axis=1)
|
||||
ret_list = group.nlargest(num, ['pinyin_c', 'frequency']).index.tolist()
|
||||
result = list()
|
||||
for i in ret_list:
|
||||
result.append(json.loads(all_idiom.loc[i].to_json(orient = 'index',force_ascii=False)))
|
||||
return result
|
||||
|
|
|
@ -82,8 +82,13 @@
|
|||
text = result.result.map(function(item){
|
||||
return item.word + '\t' + item.pinyin
|
||||
}).join('\n')
|
||||
if(!text){
|
||||
$('#result').val('无匹配结果')
|
||||
}
|
||||
else{
|
||||
$('#result').val(text)
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#result').val(result)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue