-
Notifications
You must be signed in to change notification settings - Fork 1
/
event_summary.py
25 lines (21 loc) · 956 Bytes
/
event_summary.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
from tabulate import tabulate
from meta_graph_stat import MetaGraphStat
def summary(events, tablefmt, summary_kws):
date_format = '%Y-%m-%d'
table = []
for i, e in enumerate(events):
d = MetaGraphStat(e, summary_kws).summary_dict()
row = ["**#{},**".format(i+1),
d['basic_structure_stats']['#nodes'],
"{} {}".format(
d['time_span']['start_time'].strftime(date_format),
d['time_span']['end_time'].strftime(date_format)
),
# next(s for s in d['email_content']['subjects(top5)'] if s), # get first non-empty
'\n'.join(d['email_content']['subjects(top5)']),
' '.join(d['topics']['topic_terms'])
]
table.append(row)
return tabulate(table, headers=["", "#nodes", "time",
"subject(root)", "terms"],
tablefmt=tablefmt)