forked from mrlan/EnglishPal
				
			Merge pull request 'main.py: fix Bug 511' (#182) from Bug511-Hui into Alpha-snapshot20240618
Reviewed-on: mrlan/EnglishPal#182Bug501-Hui
						commit
						e478217343
					
				|  | @ -4,6 +4,7 @@ | |||
| ########################################################################### | ||||
| from flask import abort, jsonify | ||||
| from markupsafe import escape | ||||
| from collections import Counter | ||||
| from Login import * | ||||
| from Article import * | ||||
| import Yaml | ||||
|  | @ -58,6 +59,12 @@ def appears_in_test(word, d): | |||
|     else: | ||||
|         return ','.join(d[word]) | ||||
| 
 | ||||
| 
 | ||||
| def good_word(word): | ||||
|     return len(word) < len('Pneumonoultramicroscopicsilicovolcanoconiosis') \ | ||||
|         and Counter(word).most_common(1)[0][1] <= 4 | ||||
| 
 | ||||
| 
 | ||||
| @app.route("/mark", methods=['GET', 'POST']) | ||||
| def mark_word(): | ||||
|     ''' | ||||
|  | @ -99,7 +106,7 @@ def mainpage(): | |||
|     if request.method == 'POST':  # when we submit a form | ||||
|         content = escape(request.form['content']) | ||||
|         f = WordFreq(content) | ||||
|         lst = f.get_freq() | ||||
|         lst = [ t for t in f.get_freq() if good_word(t[0]) ] # only keep normal words | ||||
|         # save history | ||||
|         d = load_freq_history(path_prefix + 'static/frequency/frequency.p') | ||||
|         lst_history = pickle_idea.dict2lst(d) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue