Compare commits
14 Commits
master
...
Bug493-Gon
Author | SHA1 | Date |
---|---|---|
田其鹭 | 705aa5efcb | |
田其鹭 | 61f46f7d58 | |
dktea | b9a6e4407e | |
dktea | 0962d95ce1 | |
dktea | 071d1c968b | |
dktea | 68b254f96c | |
Lan Hui | 4fb1cad745 | |
Lan Hui | 2a553e0f8f | |
Lan Hui | 4513a80bdd | |
Lan Hui | e73c66edd3 | |
Lan Hui | 69835c7f8d | |
徐幸 | 71cc627aad | |
徐幸 | 22775f9797 | |
徐幸 | 9e36644215 |
|
@ -180,5 +180,5 @@ Demo video link: https://b23.tv/QuB77m
|
||||||
|
|
||||||
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=215
|
Bug report: http://118.25.96.118/bugzilla/show_bug.cgi?id=215
|
||||||
|
|
||||||
|
龚科丞
|
||||||
*Last modified on 2021-10-17*
|
*Last modified on 2021-10-17*
|
|
@ -85,6 +85,10 @@ def mainpage():
|
||||||
content = escape(request.form['content'])
|
content = escape(request.form['content'])
|
||||||
f = WordFreq(content)
|
f = WordFreq(content)
|
||||||
lst = f.get_freq()
|
lst = f.get_freq()
|
||||||
|
for i in lst:
|
||||||
|
if '&' in i[0]:
|
||||||
|
i[0].replace('&','\'')
|
||||||
|
#此处由于找不到输出的所以对其输入的格式进行重新规范
|
||||||
# save history
|
# save history
|
||||||
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
d = load_freq_history(path_prefix + 'static/frequency/frequency.p')
|
||||||
lst_history = pickle_idea.dict2lst(d)
|
lst_history = pickle_idea.dict2lst(d)
|
||||||
|
|
|
@ -26,7 +26,10 @@
|
||||||
<a class="btn btn-secondary" href="/logout" role="button">退出</a>
|
<a class="btn btn-secondary" href="/logout" role="button">退出</a>
|
||||||
<a class="btn btn-secondary" href="/reset" role="button">重设密码</a>
|
<a class="btn btn-secondary" href="/reset" role="button">重设密码</a>
|
||||||
</p>
|
</p>
|
||||||
{{ flashed_messages|safe }}
|
{% if flashed_messages != "" %}
|
||||||
|
<div class="alert alert-warning" role="alert" id="warn_info">{{ flashed_messages|safe }}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<a class="btn btn-success" href="/{{ username }}/reset" role="button"> 下一篇 Next Article </a>
|
<a class="btn btn-success" href="/{{ username }}/reset" role="button"> 下一篇 Next Article </a>
|
||||||
{% if session.get('articleID') != session.get('old_articleID') %}
|
{% if session.get('articleID') != session.get('old_articleID') %}
|
||||||
|
|
|
@ -181,7 +181,5 @@ def get_flashed_messages_if_any():
|
||||||
messages = get_flashed_messages()
|
messages = get_flashed_messages()
|
||||||
s = ''
|
s = ''
|
||||||
for message in messages:
|
for message in messages:
|
||||||
s += '<div class="alert alert-warning" role="alert">'
|
s += message
|
||||||
s += f'Congratulations! {message}'
|
|
||||||
s += '</div>'
|
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -38,20 +38,42 @@ def file2str(fname):#文件转字符
|
||||||
return s
|
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赋值。
|
def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。
|
||||||
special_characters = '_©~=+[]*&$%^@.,?!:;#()"“”—‘’' # 把里面的字符都去掉
|
# carr = str2chararray(s) # 字符串转字符数组
|
||||||
|
# print(carr)
|
||||||
|
special_characters = '&_~=+[]%^@.,?!:;#()"“”—‘’|/\\<>{}' # 把里面的字符都去掉
|
||||||
|
special_words = ('$lt', '$gt', '$') # 特殊词汇
|
||||||
for c in 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.replace('--', ' ')
|
||||||
s = s.strip() # 去除前后的空格
|
s = s.strip() # 去除前后的空格
|
||||||
|
|
||||||
if '\'' in s:
|
if '\'' in s:
|
||||||
n = len(s)
|
n = len(s)
|
||||||
t = '' # 用来收集我需要保留的字符
|
t = '' # 用来收集我需要保留的字符
|
||||||
for i in range(n): # 只有单引号前后都有英文字符,才保留
|
for i in range(n): # 只有单引号前后都有英文字符,才保留
|
||||||
if s[i] == '\'':
|
if s[i] == '\'':
|
||||||
i_is_ok = i - 1 >= 0 and i + 1 < n
|
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]
|
t += s[i]
|
||||||
else:
|
else:
|
||||||
t += s[i]
|
t += s[i]
|
||||||
|
@ -60,6 +82,7 @@ def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sort_in_descending_order(lst):# 单词按频率降序排列
|
def sort_in_descending_order(lst):# 单词按频率降序排列
|
||||||
lst2 = sorted(lst, reverse=True, key=lambda x: (x[1], x[0]))
|
lst2 = sorted(lst, reverse=True, key=lambda x: (x[1], x[0]))
|
||||||
return lst2
|
return lst2
|
||||||
|
|
Loading…
Reference in New Issue