Upload WarBot.py
Browse filesUpdated the WarBot
WarBot.py
CHANGED
@@ -113,13 +113,18 @@ def get_response(quote:str,model,tokenizer,model_punct):
|
|
113 |
response = remove_duplicates(re.sub(r"\d{4,}", "", response)) # Remove the consequent numbers with 4 or more digits
|
114 |
response = re.sub(r'\.\.+', '', response) # Remove the "....." thing
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
response = re.sub(r'[UNK]', '', response) # Remove the [UNK] thing
|
125 |
return response
|
@@ -130,4 +135,4 @@ def get_response(quote:str,model,tokenizer,model_punct):
|
|
130 |
#print('please wait...')
|
131 |
#response = wrap(get_response(quote,model,tokenizer,model_punct),60)
|
132 |
#for phrase in response:
|
133 |
-
# print(phrase)
|
|
|
113 |
response = remove_duplicates(re.sub(r"\d{4,}", "", response)) # Remove the consequent numbers with 4 or more digits
|
114 |
response = re.sub(r'\.\.+', '', response) # Remove the "....." thing
|
115 |
|
116 |
+
maxLen = 170
|
117 |
+
|
118 |
+
try:
|
119 |
+
if len(response)>maxLen: # We shall play with it
|
120 |
+
resps = wrap(response,maxLen)
|
121 |
+
for i in range(len(resps)):
|
122 |
+
resps[i] = model_punct.enhance_text(resps[i], lan='ru')
|
123 |
+
response = ''.join(resps)
|
124 |
+
else:
|
125 |
+
response = model_punct.enhance_text(response, lan='ru')
|
126 |
+
except:
|
127 |
+
pass # sometimes the string is getting too long
|
128 |
|
129 |
response = re.sub(r'[UNK]', '', response) # Remove the [UNK] thing
|
130 |
return response
|
|
|
135 |
#print('please wait...')
|
136 |
#response = wrap(get_response(quote,model,tokenizer,model_punct),60)
|
137 |
#for phrase in response:
|
138 |
+
# print(phrase)
|