From 6d69d05e50773f333eb13898740a15918cc578e3 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Dec 2020 21:21:45 +0000 Subject: [PATCH] finally a good one --- data/make_persona_file.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/data/make_persona_file.py b/data/make_persona_file.py index 3ef618b..43c3503 100644 --- a/data/make_persona_file.py +++ b/data/make_persona_file.py @@ -475,8 +475,7 @@ def get_utterance_list(chat, dialogs, char_opening_lines=None, num_candidates=10 - -def get_persona_from_file(file): +def get_persona_from_file(file, all_chats=False, max_num_chatter=3): dialogs = generate_dialog_and_personality(file) @@ -484,18 +483,25 @@ def get_persona_from_file(file): #number of chats containing only 2 participants two_person_chats = [] for id, chat in enumerate( dialogs["dialogs"] ) : + if all_chats: + two_person_chats.append([id,chat]) + continue + num_chatter= len ( chat['participants'] ) #print(num_chatter) - if num_chatter==2: + if num_chatter<=max_num_chatter: two_person_chats.append([id,chat]) - - print("Two person chat count:{}".format(len(two_person_chats))) + if all_chats: + print("Multi user chat count:{}".format(len(two_person_chats))) + else: + print("Max {} person chat count:{}".format(max_num_chatter, len(two_person_chats))) + all_utterances = [] char_opening_lines = collections.defaultdict(list) for chats in two_person_chats: chat = chats[1]['chat'] - utterances, char_opening_lines= get_utterance_list(chat,dialogs, char_opening_lines=char_opening_lines, num_cadidates=10) + utterances, char_opening_lines= get_utterance_list(chat,dialogs, char_opening_lines=char_opening_lines, num_candidates=10) all_utterances.append(utterances)