Update preprocess.py
Browse filesfix sgd state annotation
- preprocess.py +12 -7
preprocess.py
CHANGED
@@ -187,9 +187,9 @@ def preprocess():
|
|
187 |
"turns": []
|
188 |
}
|
189 |
cnt += 1
|
190 |
-
|
191 |
for domain in dialogue['domains']:
|
192 |
-
|
193 |
|
194 |
for utt_idx, t in enumerate(d['turns']):
|
195 |
speaker = t['speaker'].lower()
|
@@ -306,17 +306,22 @@ def preprocess():
|
|
306 |
assert value == 'dontcare', f'{action}-{slot_info}'
|
307 |
|
308 |
if speaker == 'user':
|
309 |
-
state = deepcopy(
|
310 |
active_intent = {}
|
311 |
requested_slots = {}
|
312 |
for frame in t['frames']:
|
313 |
domain = frame['service']
|
314 |
active_intent[domain] = frame['state']['active_intent']
|
315 |
requested_slots[domain] = frame['state']['requested_slots']
|
316 |
-
for slot
|
317 |
-
|
318 |
-
|
319 |
-
state[domain][slot]
|
|
|
|
|
|
|
|
|
|
|
320 |
turn['state'] = state
|
321 |
turn['active_intent'] = active_intent
|
322 |
turn['requested_slots'] = requested_slots
|
|
|
187 |
"turns": []
|
188 |
}
|
189 |
cnt += 1
|
190 |
+
prev_state = {}
|
191 |
for domain in dialogue['domains']:
|
192 |
+
prev_state.setdefault(domain, deepcopy(ontology['state'][domain]))
|
193 |
|
194 |
for utt_idx, t in enumerate(d['turns']):
|
195 |
speaker = t['speaker'].lower()
|
|
|
306 |
assert value == 'dontcare', f'{action}-{slot_info}'
|
307 |
|
308 |
if speaker == 'user':
|
309 |
+
state = deepcopy(prev_state)
|
310 |
active_intent = {}
|
311 |
requested_slots = {}
|
312 |
for frame in t['frames']:
|
313 |
domain = frame['service']
|
314 |
active_intent[domain] = frame['state']['active_intent']
|
315 |
requested_slots[domain] = frame['state']['requested_slots']
|
316 |
+
for slot in state[domain]:
|
317 |
+
if slot in frame['state']['slot_values']:
|
318 |
+
value_list = frame['state']['slot_values'][slot]
|
319 |
+
state[domain][slot] = value_list[0]
|
320 |
+
for value in value_list[1:]:
|
321 |
+
state[domain][slot] += '|' + value
|
322 |
+
else:
|
323 |
+
state[domain][slot] = ''
|
324 |
+
prev_state = state
|
325 |
turn['state'] = state
|
326 |
turn['active_intent'] = active_intent
|
327 |
turn['requested_slots'] = requested_slots
|