-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemotionx_result.py
36 lines (28 loc) · 1.11 KB
/
emotionx_result.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
import sys
import json
import os
def process_result(data_path, source_file_name, result_file_name):
with open(os.path.join(data_path, source_file_name), 'r') as source_file:
source = json.load(source_file)
dialogs = []
for diag in source:
newDiag = []
for item in diag:
newItem = {}
newItem['speaker'] = item['speaker']
newItem['utterance'] = item['origin']
newItem['emotion'] = item['emotion']
newDiag.append(newItem)
dialogs.append(newDiag)
result = []
result.append({
"name": "Meena Alfons",
"email": "[email protected]"
})
result.append(dialogs)
with open(os.path.join(data_path, result_file_name), 'w') as result_file:
json.dump(result, result_file, indent=4)
if __name__ == '__main__':
DATA_PATH = sys.argv[1]
process_result(DATA_PATH, 'result_friends_others_dev.json', 'friends_pred.json')
process_result(DATA_PATH, 'result_emotionpush_others_dev.json', 'emotionpush_pred.json')