添加简单搜索模式

This commit is contained in:
zhiyang7 2022-02-11 09:19:18 +08:00
parent 49bfc52caa
commit 2f40fe95a6
2 changed files with 28 additions and 6 deletions

12
main.py
View File

@ -48,7 +48,7 @@ def main(argv):
# parameter = '2134'
mode = '3'
parameter = '行之有效 2134,00 11 10 00 0100 1101;各执一词 4212,00 11 12 22 0010 1022'
num = 3
num = 6
try:
opts, args = getopt.getopt(argv, "hm:p:n:", ["mode=", "parameter=", "num="])
except getopt.GetoptError:
@ -170,6 +170,14 @@ def filter_logic(mode, parameter):
else:
break
return four_idiom, group
elif mode == '4':
four_idiom = all_idiom[all_idiom['word'].str.len() == 4]
group = four_idiom[four_idiom['word'].str.count(parameter) > 0].copy()
return four_idiom, group
elif mode == '5':
four_idiom = all_idiom[all_idiom['word'].str.len() == 4]
group = four_idiom[four_idiom['pinyin_r'].str.count(parameter) > 0].copy()
return four_idiom, group
return None, None
def filter_group_model2(parameter, group, hits, tones, tone_hits, word_hits):
@ -266,7 +274,7 @@ def predict():
mode = request.args.get('mode')
parameter = request.args.get('parameter')
all_idiom, group = filter_logic(mode, parameter)
result = get_max_group(all_idiom, group, 3)
result = get_max_group(all_idiom, group, 6)
return jsonify({'status': 0, 'message': 'success', 'result': result})
@app.route('/', methods=['GET'])

View File

@ -18,19 +18,27 @@
<div class="col-sm-8">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode0" value="0" checked>
<label class="form-check-label" for="mode0">0</label>
<label class="form-check-label" for="mode0">拼音1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode1" value="1">
<label class="form-check-label" for="mode1">1</label>
<label class="form-check-label" for="mode1">拼音2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode2" value="2">
<label class="form-check-label" for="mode2">2</label>
<label class="form-check-label" for="mode2">汉兜1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode3" value="3">
<label class="form-check-label" for="mode3">3</label>
<label class="form-check-label" for="mode3">汉兜2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode4" value="4">
<label class="form-check-label" for="mode4">文字正则</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" id="mode5" value="5">
<label class="form-check-label" for="mode5">拼音正则</label>
</div>
</div>
</div>
@ -73,6 +81,12 @@
case '3':
$("#parameter").attr('placeholder', '各执一词 4212,00 11 12 22 0010 1022')
break
case '4':
$("#parameter").attr('placeholder', '^..之急$')
break
case '5':
$("#parameter").attr('placeholder', '^.+zhi ji$')
break
}
$("#parameter").val('')
})