-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_domains.py
201 lines (164 loc) · 9.6 KB
/
all_domains.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import os
import json
import shutil
import importlib
domains = []
with open("dataset\meta_woz_by_domain.json", "r") as file:
data = json.load(file)
# get keys in file
for key in data.keys():
domains.append(key)
for domain in domains:
# Set the original folder path and name
original_folder = "order_pizza"
original_folder_name = "order_pizza"
# Set the new folder name
new_folder_name = domain.lower()
# Set the path where you want to create the new folder
path = "./"
if not os.path.exists(os.path.join(path, new_folder_name)):
# Use shutil.copytree() to copy the original folder to the new folder
shutil.copytree(original_folder, os.path.join(path, new_folder_name))
# Rename the copied folder
# os.rename(os.path.join(path, new_folder_name, original_folder_name), os.path.join(path, new_folder_name, new_folder_name))
# change the domain name in config.py of the new folder
with open(os.path.join(path, new_folder_name, "config.py"), "r") as file:
data = file.readlines()
data[0] = f"domain_name = '{domain}'\n"
with open(os.path.join(path, new_folder_name, "config.py"), "w") as file:
file.writelines(data)
# open all folders and change the domain name in config.py
for domain in domains:
if domain == "ORDERING_PIZZA":
continue
if domain == "PET_ADVICE":
continue
module_name = domain.lower() + ".config"
my_module = importlib.import_module(module_name)
my_module.domain_name = domain
with open(os.path.join(domain.lower(), "config.py"), "w") as file:
# write all of this
# domain_name = "ordering_pizza"
# domain_label = "ordering pizza"
# domain = "ORDERING_PIZZA"
# args_embedding_bot = {
# 'dataset': 'meta_woz',
# 'df_file_name' : 'df_bot.txt',
# 'output_file_name' : 'embedded_sent_bot.csv',
# 'output_dir': 'output\sent'
# }
# args_embedding_user = {
# 'dataset': 'meta_woz',
# 'df_file_name' : 'df_user.txt',
# 'output_file_name' : 'embedded_sent_user.csv',
# 'output_dir': 'output\sent'
# }
# args_clustering_bot = {
# 'data_path': 'output\sent\embedded_sent_bot.csv',
# 'embeddings_path': 'output\sent\embeddings_sent_bot.json',
# 'clusters_path': 'output\sent\clusters_sent_bot.json',
# 'cluster_dict_path': 'output\sent\sent_bot_dict_bot.json',
# 'distance_threshold': 10.0,
# 'centroids_path': 'output\sent\centroids_sent_bot.json',
# 'closest_utterance_indices_path': 'output\sent\closest_utterance_indices_sent_bot.json',
# 'closest_utterances_path': 'output\closest_utterances_sent_bot.json',
# }
# args_clustering_user = {
# 'data_path': 'output\sent\embedded_sent_user.csv',
# 'embeddings_path': 'output\sent\embeddings_sent_user.json',
# 'clusters_path': 'output\sent\clusters_sent_user.json',
# 'cluster_dict_path': 'output\sent\sent_user_dict_user.json',
# 'distance_threshold': 10.0,
# 'centroids_path': 'output\sent\centroids_sent_user.json',
# 'closest_utterance_indices_path': 'output\sent\closest_utterance_indices_sent_user.json',
# 'closest_utterances_path': 'output\closest_utterances_sent_user.json',
# }
# args_labeling_bot = {
# "user_instruction": f'You are given a set of utterances of a task-oriented bot interacting with a user for {domain_label}. You need to output a high-level dialog action that the bot intends in the given utterances.\n\nThe dialog action you output must satisfy these constraints:\n1) It should be a short phrase\n2) It should not have any specific entity names\n3)Begin with Dialog Action:\nUtterances:\n',
# "output_labels": 'output\chatgpt_response_sent_bot.json',
# "closest_utterances_file": 'output\closest_utterances_sent_bot.json'
# }
# args_labeling_user = {
# "user_instruction": f'You are given a set of utterances of a user interacting with a task-oriented bot for {domain_label}. You need to output a high-level dialog action that the user intends in the given utterances.\n\nThe dialog action you output must satisfy these constraints:\n1) It should be a short phrase\n2) It should not have any specific entity names\n3)Begin with Dialog Action:\nUtterances:\n',
# "output_labels": 'output\chatgpt_response_sent_user.json',
# "closest_utterances_file": 'output\closest_utterances_sent_user.json',
# }
# configs = {
# 'embedding_bot': args_embedding_bot,
# 'embedding_user': args_embedding_user,
# 'clustering_bot': args_clustering_bot,
# 'clustering_user': args_clustering_user,
# 'labeling_bot': args_labeling_bot,
# 'labeling_user': args_labeling_user,
# 'domain': domain,
# 'domain_name': domain_name,
# }
file.write(f"domain_name = '{domain.lower()}'\n")
file.write(f"domain_label = '{domain.lower()}'\n")
file.write(f"domain = '{domain.upper()}'\n")
file.write("\n")
file.write("args_embedding_bot = {\n")
file.write(f"\t'dataset': 'meta_woz',\n")
file.write(f"\t'df_file_name' : 'df_bot.txt',\n")
file.write(f"\t'output_file_name' : 'embedded_sent_bot.csv',\n")
file.write(f"\t'output_dir': 'output\sent'\n")
file.write("}\n")
file.write("\n")
file.write("args_embedding_user = {\n")
file.write(f"\t'dataset': 'meta_woz',\n")
file.write(f"\t'df_file_name' : 'df_user.txt',\n")
file.write(f"\t'output_file_name' : 'embedded_sent_user.csv',\n")
file.write(f"\t'output_dir': 'output\sent'\n")
file.write("}\n")
file.write("\n")
file.write("args_clustering_bot = {\n")
file.write(f"\t'data_path': 'output\sent\embedded_sent_bot.csv',\n")
file.write(f"\t'embeddings_path': 'output\sent\embeddings_sent_bot.json',\n")
file.write(f"\t'clusters_path': 'output\sent\clusters_sent_bot.json',\n")
file.write(f"\t'cluster_dict_path': 'output\sent\sent_bot_dict_bot.json',\n")
file.write(f"\t'distance_threshold': 10.0,\n")
file.write(f"\t'centroids_path': 'output\sent\centroids_sent_bot.json',\n")
file.write(f"\t'closest_utterance_indices_path': 'output\sent\closest_utterance_indices_sent_bot.json',\n")
file.write(f"\t'closest_utterances_path': 'output\closest_utterances_sent_bot.json',\n")
file.write("\n")
file.write("}\n")
file.write("\n")
file.write("args_clustering_user = {\n")
file.write(f"\t'data_path': 'output\sent\embedded_sent_user.csv',\n")
file.write(f"\t'embeddings_path': 'output\sent\embeddings_sent_user.json',\n")
file.write(f"\t'clusters_path': 'output\sent\clusters_sent_user.json',\n")
file.write(f"\t'cluster_dict_path': 'output\sent\sent_user_dict_user.json',\n")
file.write(f"\t'distance_threshold': 10.0,\n")
file.write(f"\t'centroids_path': 'output\sent\centroids_sent_user.json',\n")
file.write(f"\t'closest_utterance_indices_path': 'output\sent\closest_utterance_indices_sent_user.json',\n")
file.write(f"\t'closest_utterances_path': 'output\closest_utterances_sent_user.json',\n")
file.write("}\n")
file.write("\n")
file.write("args_labeling_bot = {\n")
file.write(f"\t\"user_instruction\": f'You are given a set of utterances of a task-oriented bot interacting with a user for {domain.lower()}. You need to output a high-level dialog action that the bot intends in the given utterances.\\n\\nThe dialog action you output must satisfy these constraints:\\n1) It should be a short phrase\\n2) It should not have any specific entity names\\n3)Begin with Dialog Action:\\nUtterances:\\n',\n")
file.write(f"\t\"output_labels\": 'output\chatgpt_response_sent_bot.json',\n")
file.write(f"\t\"closest_utterances_file\": 'output\closest_utterances_sent_bot.json',\n")
file.write("}\n")
file.write("\n")
file.write("args_labeling_user = {\n")
file.write(f"\t\"user_instruction\": f'You are given a set of utterances of a user interacting with a task-oriented bot for {domain.lower()}. You need to output a high-level dialog action that the user intends in the given utterances.\\n\\nThe dialog action you output must satisfy these constraints:\\n1) It should be a short phrase\\n2) It should not have any specific entity names\\n3)Begin with Dialog Action:\\nUtterances:\\n',\n")
file.write(f"\t\"output_labels\": 'output\chatgpt_response_sent_user.json',\n")
file.write(f"\t\"closest_utterances_file\": 'output\closest_utterances_sent_user.json',\n")
file.write("}\n")
file.write("\n")
file.write("configs = {\n")
file.write("\t'embedding_bot': args_embedding_bot,\n")
file.write("\t'embedding_user': args_embedding_user,\n")
file.write("\t'clustering_bot': args_clustering_bot,\n")
file.write("\t'clustering_user': args_clustering_user,\n")
file.write("\t'labeling_bot': args_labeling_bot,\n")
file.write("\t'labeling_user': args_labeling_user,\n")
file.write("\t 'domain': domain,\n")
file.write("\t'domain_name': domain_name,\n")
file.write("}\n")
file.write("\n")
file.write("\n")
file.write("\n")
file.write("\n")
file.write("\n")
file.close()