Compare commits

...

18 Commits

Author SHA1 Message Date
田其鹭 4cf201095d fixBug 2023-05-14 21:20:16 +08:00
田其鹭 654fd52c44 1 2023-05-14 21:17:24 +08:00
田其鹭 a5c792b782 重构 2023-05-14 21:10:19 +08:00
田其鹭 0549bd9035 try 2023-05-14 14:43:16 +08:00
田其鹭 705aa5efcb bug修改,前面提交的first commit是重构 2023-04-27 16:00:46 +08:00
田其鹭 61f46f7d58 first commit 2023-04-27 15:43:11 +08:00
dktea b9a6e4407e Bug493-Fix 2022-12-20 12:19:06 +08:00
dktea 0962d95ce1 Merge branch 'Bug422-XuXing' of http://121.4.94.30:3000/mrlan/EnglishPal into SPM2022F-CONTRIBUTORS-GONGKE 2022-12-11 01:07:52 +08:00
dktea 071d1c968b init me again 2022-12-10 19:40:54 +08:00
dktea 68b254f96c init me 2022-12-10 19:18:56 +08:00
Lan Hui 4fb1cad745 Use a better variable name (fix session variable name error). 2022-07-21 22:28:22 +08:00
Lan Hui 2a553e0f8f Use a better variable name. 2022-07-21 22:17:50 +08:00
Lan Hui 4513a80bdd Remove unused code. 2022-07-21 22:15:07 +08:00
Lan Hui e73c66edd3 Re-arrange button positions (put Next Article before Previous Article). 2022-07-21 22:12:35 +08:00
Lan Hui 69835c7f8d Merge branch 'Bug422-XuXing' into Bug422-XuXing 2022-07-21 22:05:48 +08:00
徐幸 71cc627aad 更新 'app/templates/userpage_get.html' 2022-06-15 11:42:46 +08:00
徐幸 22775f9797 上传文件至 'app' 2022-06-14 15:58:21 +08:00
徐幸 9e36644215 增加返回上一篇按钮 2022-06-14 15:56:12 +08:00
5 changed files with 65 additions and 10 deletions

View File

@ -180,6 +180,10 @@ Demo video link: https://b23.tv/QuB77m
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=215
<<<<<<< HEAD
龚科丞
*Last modified on 2021-10-17*
=======
@ -194,3 +198,4 @@ Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=489
*Last modified on 2023-01-30*
>>>>>>> d9f6df7fbe585395a19b9a08c411d841b6b89fd4

View File

@ -84,6 +84,10 @@ def mainpage():
content = escape(request.form['content'])
f = WordFreq(content)
lst = f.get_freq()
for i in lst:
if '&' in i[0]:
i[0].replace('&','\'')
#此处由于找不到输出的所以对其输入的格式进行重新规范
# save history
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
lst_history = pickle_idea.dict2lst(d)

View File

@ -37,6 +37,16 @@
<body>
<div class="container-fluid">
<p><b>English Pal for <font id="username" color="red">{{ username }}</font></b>
<a class="btn btn-secondary" href="/logout" role="button">退出</a>
<a class="btn btn-secondary" href="/reset" role="button">重设密码</a>
</p>
{% if flashed_messages != [] %}
<div class="alert alert-warning" role="alert" id="warn_info">
{{ flashed_messages|safe }}
</div>
{% endif %}
{% if username == admin_name %}
<a class="btn btn-secondary" href="/admin" role="button" onclick="stopRead()">管理</a>
@ -113,7 +123,7 @@
{% if d_len > 0 %}
<p>
<b>我的生词簿</b>
<b>我的生词簿</b>
<label for="move_dynamiclly">
<input type="checkbox" name="move_dynamiclly" id="move_dynamiclly" checked>
允许动态调整顺序

View File

@ -102,8 +102,7 @@ def deleteword(username, word):
'''
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
pickle_idea2.deleteRecord(user_freq_record, word)
# 模板userpage_get.html中删除单词是异步执行而flash的信息后续是同步执行的所以注释这段代码同时如果这里使用flash但不提取信息则会影响 signup.html的显示。bug复现删除单词后点击退出点击注册注册页面就会出现提示信息
# flash(f'{word} is no longer in your word list.')
flash(f'{word} is no longer in your word list.')
return "success"
@ -151,7 +150,7 @@ def userpage(username):
admin_name=ADMIN_NAME,
username=username,
session=session,
# flashed_messages=get_flashed_messages(), 仅有删除单词的时候使用到flash而删除单词是异步执行这里的信息提示是同步执行所以就没有存在的必要了
flashed_messages=get_flashed_messages(),
today_article=today_article,
result_of_generate_article=result_of_generate_article,
d_len=len(d),
@ -188,3 +187,13 @@ def get_time():
'''
return datetime.now().strftime('%Y%m%d%H%M') # upper to minutes
def get_flashed_messages_if_any():
'''
在用户界面显示黄色提示信息
:return: 包含HTML标签的提示信息
'''
messages = get_flashed_messages
s = ''
for message in messages:
s += message
return s

View File

@ -38,20 +38,46 @@ def file2str(fname):#文件转字符
return s
def str2chararray(str): # 字符串转字符数组
chararray = []
for i in range(len(str)):
chararray.append(str[i])
return chararray
def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。
# carr = str2chararray(s) # 字符串转字符数组
# print(carr)
special_characters = '&_~=+[]%^@.,?!:;#()"“”—‘’|/\\<>{}' # 把里面的字符都去掉
special_words = ('$lt', '$gt', '$') # 特殊词汇
special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉
for c in special_characters:
s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况
carr = str2chararray(s) # 字符串转字符数组
for i, value in enumerate(carr):
if value == '&': # 遍历替换
carr[i] = '\''
print('sss' + s)
for j in range(1,5):
if carr[i+j] in [' ','3','9']:
carr[i + j]=''
s = ''.join(carr) # 字符数组转字符串
print('sss'+s)
for w in special_words: # 替换字符串中的剩余特殊字符
s = s.replace(w, ' ')
s = s.replace('--', ' ')
s = s.strip() # 去除前后的空格
s = s.strip() # 去除前后的空格
if '\'' in s:
n = len(s)
t = '' # 用来收集我需要保留的字符
for i in range(n): # 只有单引号前后都有英文字符,才保留
t = '' # 用来收集我需要保留的字符
for i in range(n): # 只有单引号前后都有英文字符,才保留
if s[i] == '\'':
i_is_ok = i - 1 >= 0 and i + 1 < n
if i_is_ok and s[i-1] in string.ascii_letters and s[i+1] in string.ascii_letters:
if i_is_ok and s[i - 1] in string.ascii_letters and s[i + 1] in string.ascii_letters:
t += s[i]
else:
t += s[i]
@ -60,6 +86,7 @@ def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用
return s
def sort_in_descending_order(lst):# 单词按频率降序排列
lst2 = sorted(lst, reverse=True, key=lambda x: (x[1], x[0]))
return lst2