Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,24 +21,30 @@ def contains_chinese(text):
|
|
21 |
return False
|
22 |
|
23 |
def insert_sentence(text, sentence, interval):
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
count += 1
|
37 |
|
38 |
-
|
39 |
-
new_words.append(sentence)
|
40 |
|
41 |
-
return
|
42 |
|
43 |
# 定义Reviewer类
|
44 |
class Reviewer:
|
@@ -81,7 +87,7 @@ class Reviewer:
|
|
81 |
result = ''
|
82 |
for choice in response.choices:
|
83 |
result += choice.message.content
|
84 |
-
result = insert_sentence(result, '**Generated by ChatGPT, no copying allowed!**',
|
85 |
result += "\n\n⚠伦理声明/Ethics statement:\n--禁止直接复制生成的评论用于任何论文审稿工作!\n--Direct copying of generated comments for any paper review work is prohibited!"
|
86 |
print("********"*10)
|
87 |
print(result)
|
|
|
21 |
return False
|
22 |
|
23 |
def insert_sentence(text, sentence, interval):
|
24 |
+
lines = text.split('\n')
|
25 |
+
new_lines = []
|
26 |
+
|
27 |
+
for line in lines:
|
28 |
+
if contains_chinese(line):
|
29 |
+
words = list(jieba.cut(line))
|
30 |
+
separator = ''
|
31 |
+
else:
|
32 |
+
words = line.split()
|
33 |
+
separator = ' '
|
34 |
+
|
35 |
+
new_words = []
|
36 |
+
count = 0
|
37 |
|
38 |
+
for word in words:
|
39 |
+
new_words.append(word)
|
40 |
+
count += 1
|
41 |
|
42 |
+
if count % interval == 0:
|
43 |
+
new_words.append(sentence)
|
|
|
44 |
|
45 |
+
new_lines.append(separator.join(new_words))
|
|
|
46 |
|
47 |
+
return '\n'.join(new_lines)
|
48 |
|
49 |
# 定义Reviewer类
|
50 |
class Reviewer:
|
|
|
87 |
result = ''
|
88 |
for choice in response.choices:
|
89 |
result += choice.message.content
|
90 |
+
result = insert_sentence(result, '**Generated by ChatGPT, no copying allowed!**', 15)
|
91 |
result += "\n\n⚠伦理声明/Ethics statement:\n--禁止直接复制生成的评论用于任何论文审稿工作!\n--Direct copying of generated comments for any paper review work is prohibited!"
|
92 |
print("********"*10)
|
93 |
print(result)
|