kertser commited on
Commit
9045dc1
1 Parent(s): 17e09e4

Upload WarBot.py

Browse files

Updated the WarBot

Files changed (1) hide show
  1. WarBot.py +13 -8
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
- if len(response)>200:
117
- resps = wrap(response,200)
118
- for i in range(len(resps)):
119
- resps[i] = model_punct.enhance_text(resps[i], lan='ru')
120
- response = ''.join(resps)
121
- else:
122
- response = model_punct.enhance_text(response, lan='ru')
 
 
 
 
 
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)