MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / output_schema

Function output_schema

data_convert/utils.py:38–62  ·  view source on GitHub ↗
(event_schema_set, output_file)

Source from the content-addressed store, hash-verified

36
37
38def output_schema(event_schema_set, output_file):
39 event_type_list = list(set([schema[0] for schema in event_schema_set]))
40 argument_role_list = list(set([schema[1] for schema in event_schema_set]))
41
42 if None in argument_role_list:
43 # Same Event only Type without argument
44 argument_role_list.remove(None)
45
46 event_type_set_dict = defaultdict(set)
47
48 for event_type, arg_role in event_schema_set:
49 if arg_role is None:
50 continue
51 event_type_set_dict[event_type].add(arg_role)
52
53 event_type_list_dict = defaultdict(list)
54
55 for event_type in event_type_set_dict:
56 event_type_list_dict[event_type] = list(
57 event_type_set_dict[event_type])
58
59 with codecs.open(output_file, 'w', 'UTF-8') as output:
60 output.write(json.dumps(event_type_list, ensure_ascii=False) + '\n')
61 output.write(json.dumps(argument_role_list, ensure_ascii=False) + '\n')
62 output.write(json.dumps(event_type_list_dict, ensure_ascii=False) + '\n')

Callers 1

convert_file_tupleFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected