From 144145eac1b027d745e17fd8dee14bcfc2846cb7 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Dec 2020 06:53:44 +0000 Subject: [PATCH] fix code --- data/make_persona_file.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/data/make_persona_file.py b/data/make_persona_file.py index 47a2e94..7f28ed4 100644 --- a/data/make_persona_file.py +++ b/data/make_persona_file.py @@ -65,6 +65,18 @@ def generate_dialogs(dialog_holder): +def preprocess_line(text): + #add space for ( and ) chars + ##else everthing sucks + + text = text.replace("("," ( ") + text = text.replace(")"," ( ") + + #remove "-" if exists + text = text.replace("-"," ") + + return text + def get_chat_dialog(dialog): ##we have the dialogues #now generate utterances. @@ -91,11 +103,13 @@ def get_chat_dialog(dialog): continue talk = " ".join(splitted[1:]).strip() + + talk = preprocess_line(talk) ##TODO check name starts with in participants ##if name (VO) name (..) or name/Something than assume same ##as voice over are here too. - + if name not in participants: participants[name] = participant_number participant_number += 1 @@ -111,6 +125,7 @@ def get_chat_dialog(dialog): return chat_dialog + def generate_dialog_from_file(filename): with open(filename) as f: lines = f.readlines() @@ -215,7 +230,7 @@ def get_random_line_not_said_by_char(name,dialogs,current_recursion=0): current_recursion += 1 if current_recursion > 5: ##enough already - return ["I could not find anything to say."] + return "I could not find anything to say." else: ##2th has line return get_random_line_not_said_by_char(name,dialogs,current_recursion)