in model/mm_dst/utils/evaluate_dst.py [0:0]
def evaluate_from_json(d_true, d_pred):
"""
<list>d_true and <list>d_pred are in the following format:
(Equivalent to "dialogue_data" field in the input data JSON file)
[
{
"dialogue": [
{
"transcript_annotated": {
'act': <str>,
'act_attributes': {
'slot_values': {
SLOT_NAME: SLOT_VALUE,
...
},
'request_slots': [
SLOT_NAME, ...
],
'objects': [ <int> ]
}
},
...
}
[End of a turn]
...
],
}
[End of a dialogue]
...
]
"""
d_true_flattened = []
d_pred_flattened = []
for i in range(len(d_true)):
# Iterate through each dialog
dialog_true = d_true[i]["dialogue"]
dialog_pred = d_pred[i]["dialogue"]
# ** Assumes dialogue_idx and turn_idx are ordered
# exactly the same for `dialog_true` and `dialog_pred`
_ = d_true[i]["dialogue_idx"]
for j in range(len(dialog_true)):
# Iterate through each turn
turn_true = reformat_turn(dialog_true[j]["transcript_annotated"])
turn_pred = reformat_turn(dialog_pred[j]["transcript_annotated"])
d_true_flattened.append(turn_true)
d_pred_flattened.append(turn_pred)
return evaluate_from_flat_list(d_true_flattened, d_pred_flattened)