Hyacinthax commited on
Commit
c2d90cb
·
verified ·
1 Parent(s): 4c17df7

Upload runCorpus.py

Browse files

Fixed a lot of errors caused by sublime. They were fixed before but file mismanagement; Glad production updates on hugging face

Files changed (1) hide show
  1. runCorpus.py +20 -19
runCorpus.py CHANGED
@@ -15,7 +15,7 @@ from preprocessed_dialogs import dialog_data
15
 
16
  class CorpusTrainer:
17
  def __init__(self):
18
- self.running_trouble = None
19
  self.choices_yes = ["yes", "ya", "yeah", "yessir", "yesir", "y", "ye", "yah"]
20
  self.exit_commands = ["exit", "quit", "stop", "x", "q", ""]
21
 
@@ -146,7 +146,7 @@ class CorpusTrainer:
146
  with open("troubled_speakers.txt", 'a') as f:
147
  f.write(f"{speaker}\n")
148
 
149
- self.allTogether = self.resetTogether(self.speakerList, self.troubleList)
150
  topConvo = len(self.allTogether)
151
  self.bad_count = len(self.troubleList)
152
 
@@ -158,7 +158,7 @@ class CorpusTrainer:
158
  percent_running = self.runningPercent(len(self.troubleList), self.counter)
159
  self.failure_history.append(len(self.troubleList))
160
  if percent_running is None:
161
- percent_self.running = 0.0
162
  self.chatbot_trainer.logger.info(f"self.Running Percentage Failure: {percent_running}%")
163
 
164
  # We check for speaker vs top num achieved successfully in self.speakerList
@@ -169,8 +169,8 @@ class CorpusTrainer:
169
 
170
  if percent_running is not None:
171
  # Note: The run adds to the trained speaker list which is successful trainings. If it's not in that list, when it comes up again it will be trained another time.
172
- if percent_running > percent_reset:
173
- print("Logging Failures... Resetting... Failure Rate is Greater than {percent_reset}%...")
174
  answer_1 = input("Show Failures for this Run? \n>")
175
  if answer_1 in self.exit_commands:
176
  quit()
@@ -211,7 +211,7 @@ class CorpusTrainer:
211
  f.write(f"{speaker}\n")
212
 
213
  # Find Top Convo
214
- self.allTogether = self.resetTogether(self.speakerList, self.troubleList)
215
  topConvo = len(self.allTogether)
216
  self.bad_count = len(self.troubleList)
217
 
@@ -222,41 +222,42 @@ class CorpusTrainer:
222
  print(f"Number of Conversations Combined: {topConvo}")
223
  print(f"self.Running Trouble: {len(self.runningTrouble)}")
224
 
225
- percent_self.running = self.runningPercent(len(self.troubleList), topConvo)
226
  self.failure_history.append(len(self.troubleList))
227
- if percent_self.running is None:
228
- percent_self.running = 0.0
229
- self.chatbot_trainer.logger.info(f"self.Running Percentage Failure: {percent_self.running}%")
230
 
231
  print(f"Now is the time to quit if need be... ")
232
  if play_notification == 1:
233
  playsound(notification_sound)
234
- for x in range(time_sleep):
235
  # time.sleep(1)
236
- print(f"Next convo in:{time_sleep-x}")
237
 
238
- if percent_self.running is not None:
239
  # Note: The self.run adds to the trained speaker list which is successful trainings. If it's not in that list, when it comes up again it will be trained another time.
240
- if percent_self.running > percent_reset:
241
  self.log_failures(len(self.troubleList), log_file)
242
  print("Plotting Failures... See failures_plot.png for more information... ")
243
  self.plot_failures(log_file)
244
  if play_notification == 1:
245
  playsound(notification_sound)
246
- print(f"Resetting... Failure Rate is Greater than {percent_reset}%... For this self.run.")
247
- # time.sleep(time_sleep * 3)
248
  return self.main(self.chatbot_trainer, user_choice, dialog_data, topConvo, self.top_num)
249
 
250
- def resetTogether():
251
  for speakers in self.speakerList:
252
  if speakers not in self.allTogether:
253
  self.allTogether.append(str(speakers))
254
  for speakers in self.troubleListData:
255
  if speakers not in self.allTogether:
256
  self.allTogether.append(str(speakers))
257
- self.allTogetherSorted = sorted(self.allTogether)
 
258
 
259
- return self.allTogetherSorted
260
 
261
  def cleanupTrained(self, speakerList):
262
  for data in self.speakerList:
 
15
 
16
  class CorpusTrainer:
17
  def __init__(self):
18
+ self.runningTrouble = []
19
  self.choices_yes = ["yes", "ya", "yeah", "yessir", "yesir", "y", "ye", "yah"]
20
  self.exit_commands = ["exit", "quit", "stop", "x", "q", ""]
21
 
 
146
  with open("troubled_speakers.txt", 'a') as f:
147
  f.write(f"{speaker}\n")
148
 
149
+ self.allTogether = self.resetTogether()
150
  topConvo = len(self.allTogether)
151
  self.bad_count = len(self.troubleList)
152
 
 
158
  percent_running = self.runningPercent(len(self.troubleList), self.counter)
159
  self.failure_history.append(len(self.troubleList))
160
  if percent_running is None:
161
+ percent_running = 0.0
162
  self.chatbot_trainer.logger.info(f"self.Running Percentage Failure: {percent_running}%")
163
 
164
  # We check for speaker vs top num achieved successfully in self.speakerList
 
169
 
170
  if percent_running is not None:
171
  # Note: The run adds to the trained speaker list which is successful trainings. If it's not in that list, when it comes up again it will be trained another time.
172
+ if percent_running > self.percent_reset:
173
+ print("Logging Failures... Resetting... Failure Rate is Greater than {self.percent_reset}%...")
174
  answer_1 = input("Show Failures for this Run? \n>")
175
  if answer_1 in self.exit_commands:
176
  quit()
 
211
  f.write(f"{speaker}\n")
212
 
213
  # Find Top Convo
214
+ self.allTogether = self.resetTogether()
215
  topConvo = len(self.allTogether)
216
  self.bad_count = len(self.troubleList)
217
 
 
222
  print(f"Number of Conversations Combined: {topConvo}")
223
  print(f"self.Running Trouble: {len(self.runningTrouble)}")
224
 
225
+ percent_running = self.runningPercent(len(self.troubleList), topConvo)
226
  self.failure_history.append(len(self.troubleList))
227
+ if percent_running is None:
228
+ percent_running = 0.0
229
+ self.chatbot_trainer.logger.info(f"self.Running Percentage Failure: {percent_running}%")
230
 
231
  print(f"Now is the time to quit if need be... ")
232
  if play_notification == 1:
233
  playsound(notification_sound)
234
+ for x in range(self.time_sleep):
235
  # time.sleep(1)
236
+ print(f"Next convo in:{self.time_sleep-x}")
237
 
238
+ if percent_running is not None:
239
  # Note: The self.run adds to the trained speaker list which is successful trainings. If it's not in that list, when it comes up again it will be trained another time.
240
+ if percent_running > self.percent_reset:
241
  self.log_failures(len(self.troubleList), log_file)
242
  print("Plotting Failures... See failures_plot.png for more information... ")
243
  self.plot_failures(log_file)
244
  if play_notification == 1:
245
  playsound(notification_sound)
246
+ print(f"Resetting... Failure Rate is Greater than {self.percent_reset}%... For this self.run.")
247
+ # time.sleep(self.time_sleep * 3)
248
  return self.main(self.chatbot_trainer, user_choice, dialog_data, topConvo, self.top_num)
249
 
250
+ def resetTogether(self):
251
  for speakers in self.speakerList:
252
  if speakers not in self.allTogether:
253
  self.allTogether.append(str(speakers))
254
  for speakers in self.troubleListData:
255
  if speakers not in self.allTogether:
256
  self.allTogether.append(str(speakers))
257
+
258
+ allTogetherSorted = sorted(self.allTogether)
259
 
260
+ return allTogetherSorted
261
 
262
  def cleanupTrained(self, speakerList):
263
  for data in self.speakerList: