1
0
Fork 0

Compare commits

..

5 Commits

Author SHA1 Message Date
顾涵 708a6a2821 Merge pull request 'WIP:Bug529-GuHan' (#88) from Bug529-GuHan into master
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/88
2023-06-04 12:39:34 +08:00
顾涵 688a198768 已经与Alpha-snapshot20230525 分支同步,重新提交 2023-05-28 16:31:12 +08:00
顾涵 030b89706e special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个“-”字符对程序的过滤过程不会造成问题。 2023-05-20 15:29:12 +08:00
顾涵 acd8db6e3e special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个对“1-”字符的过滤不会造成问题。 2023-05-15 19:24:43 +08:00
顾涵 9f3f5b43e1 special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' 用于过滤字符,我将其中的“-”删去,使连字符没有被过滤,实现录入例如fifty-six等组合词的功能。另外对于删除过滤是否会引发字符bug,答案是肯定的,但是这段代码中的过滤字符虽然多,但是并没有完全过滤掉所有字符,(过滤的只是键盘上能打出的字符,不包括输入法中能打出的特殊字符),所以字符bug本身就一直存在,我认为减少一个对“-”字符的过滤不会造成问题。 2023-05-15 19:15:30 +08:00
4 changed files with 1 additions and 45 deletions

View File

@ -11,7 +11,6 @@ from Article import *
import Yaml import Yaml
from user_service import userService from user_service import userService
from account_service import accountService from account_service import accountService
from wordCMD import show_bp
from admin_service import adminService, ADMIN_NAME from admin_service import adminService, ADMIN_NAME
app = Flask(__name__) app = Flask(__name__)
app.secret_key = 'lunch.time!' app.secret_key = 'lunch.time!'
@ -20,7 +19,6 @@ app.secret_key = 'lunch.time!'
app.register_blueprint(userService) app.register_blueprint(userService)
app.register_blueprint(accountService) app.register_blueprint(accountService)
app.register_blueprint(adminService) app.register_blueprint(adminService)
app.register_blueprint(show_bp)
path_prefix = '/var/www/wordfreq/wordfreq/' path_prefix = '/var/www/wordfreq/wordfreq/'
path_prefix = './' # comment this line in deployment path_prefix = './' # comment this line in deployment

View File

@ -1,9 +0,0 @@
<h1>Here are {{ name }}'s words:</h1>
<table border="2">
<tr>
<th>WORDS</th>
</tr>
{% for word in results %}
<tr><td>{{ word }}</td></tr>
{% endfor %}
</table>

View File

@ -1,33 +0,0 @@
from flask import Flask, request, Blueprint, render_template
from UseSqlite import InsertQuery, RecordQuery
TKTK = 'token' # set token
show_bp = Blueprint(
'site',
__name__,
)
# The following function is replaced by the template show.html.
# And can be safely deleted.
# def make_html_paragraph(s): # build the word's table
# if s.strip() == '':
# return ''
# lst = s.split(',')
# word = lst[1].strip()
# result = '<tr><td>' + word + '</td></tr>'
# return result
@show_bp.route('/show/<name>/') # set route for show page <name> means the var name to search
def show(name):
token = request.args.get("token")
# when token is wrong
if token != TKTK:
return "token is wrong, please try again"
rq = RecordQuery('./static/wordfreqapp.db')
# search the user's words in db
rq.instructions_with_parameters("SELECT * FROM words WHERE user = ?", (name,))
rq.do_with_parameters()
results = [row.split(",")[1].strip() for row in rq.format_results().split("\n\n")]
return render_template("show.html", name=name, results=results)

View File

@ -39,7 +39,7 @@ def file2str(fname):#文件转字符
def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。
special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉 special_characters = '\_©~<=>+/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉
for c in special_characters: for c in special_characters:
s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
s = s.replace('--', ' ') s = s.replace('--', ' ')