ShiwenNi commited on
Commit
630579b
1 Parent(s): 4e9b859

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -21,24 +21,30 @@ def contains_chinese(text):
21
  return False
22
 
23
  def insert_sentence(text, sentence, interval):
24
- if contains_chinese(text):
25
- words = list(jieba.cut(text))
26
- separator = ''
27
- else:
28
- words = text.split()
29
- separator = ' '
 
 
 
 
 
 
 
30
 
31
- new_words = []
32
- count = 0
 
33
 
34
- for word in words:
35
- new_words.append(word)
36
- count += 1
37
 
38
- if count % interval == 0:
39
- new_words.append(sentence)
40
 
41
- return separator.join(new_words)
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!**', 10)
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)