From d58dacd71cc4a0a693b9d8a123f5ea24375dd8c1 Mon Sep 17 00:00:00 2001 From: ShumTin <970206989@qq.com> Date: Tue, 6 Dec 2022 14:40:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug508,=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6|?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E8=AF=8D=E5=9C=A8=E6=96=87=E7=AB=A0=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=AB=98=E4=BA=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/highlight.js | 2 ++ app/wordfreqCMD.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 1003918..7b3cab2 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -29,6 +29,8 @@ function highLight() { const list = allWords.split(" "); for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符 + list[i] = list[i].replace('|', ""); + list[i] = list[i].replace('?', ""); if (list[i] !== "" && "".indexOf(list[i]) === -1 && "".indexOf(list[i]) === -1) { //将文章中所有出现该单词word的地方改为:" " + word + " "。 正则表达式RegExp()中,"\\s"代表单词前后必须要有空格,以防止只对单词中的部分字符高亮的情况出现。 articleContent = articleContent.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " " + list[i] + " "); diff --git a/app/wordfreqCMD.py b/app/wordfreqCMD.py index 9ee7e56..7c3f186 100644 --- a/app/wordfreqCMD.py +++ b/app/wordfreqCMD.py @@ -39,7 +39,7 @@ def file2str(fname):#文件转字符 def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 - special_characters = '_©~=+[]*&$%^@.,?!:;#()"“”—‘’' # 把里面的字符都去掉 + special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}' # 把里面的字符都去掉 for c in special_characters: s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 s = s.replace('--', ' ') From f37ea182f64e0484541b0a27fb317acb97e4ea07 Mon Sep 17 00:00:00 2001 From: ShumTin <970206989@qq.com> Date: Tue, 6 Dec 2022 17:02:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=94=9F=E8=AF=8D?= =?UTF-8?q?=E5=BA=93=E8=BF=87=E6=BB=A4|?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/wordfreqCMD.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/wordfreqCMD.py b/app/wordfreqCMD.py index 7c3f186..c4f8a63 100644 --- a/app/wordfreqCMD.py +++ b/app/wordfreqCMD.py @@ -39,7 +39,7 @@ def file2str(fname):#文件转字符 def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 - special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}' # 把里面的字符都去掉 + special_characters = '\_©~<=>+-/[]*&$%^@.,?!:;#()"“”—‘’{}|' # 把里面的字符都去掉 for c in special_characters: s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 s = s.replace('--', ' ')