-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventsMatcher.py
59 lines (49 loc) · 2.46 KB
/
EventsMatcher.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pandas as pd
import string
class Matcher(object):
def __init__(self, path):
df = pd.read_csv(path, sep=';')
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
event_list = df['event'].tolist()
transition_id_list = df['transition_id'].tolist()
transition_names = df['transition_name'].tolist()
self.events_to_transitions = dict(zip(event_list, transition_id_list))
self.trans_to_ev = dict(zip(transition_id_list, transition_names))
self.transition_id = (list(set(transition_id_list)))
self.transitions_to_symbols = {}
# __transition_to_symbol(self):
list_of_transitions = self.transition_id
# add hidden transitions
list_of_transitions.append('t2.2')
list_of_transitions.append('t3.1')
list_of_transitions.append('t5.1.1')
list_of_transitions.append('t5.1.2')
list_of_symbols = list(string.ascii_letters)[:len(list_of_transitions)]
self.transitions_to_symbols = dict(zip(list_of_transitions, list_of_symbols)) # encode
self.symbols_to_transitions = dict(zip(list_of_symbols, list_of_transitions)) # decode
def event_to_transition(self, evname):
return self.events_to_transitions[evname]
def places_to_text(self):
places_dict = {
'p1_1': 'Сообщение о происшествии',
'p2_1': 'Сообщение о преступлении',
'p3_1': 'Результат доследственной проверки',
'p4_1': 'Отказано в возбуждении уголовного дела',
'p4_2': 'Возбуждено уголовное дело',
'p5_0': 'Отказ отменен',
'p5_1': 'Дело в производстве',
'p6_1': 'Дело приостановлено',
'p6_2': 'Делопроизводство прекращено',
'p6_3': 'Дело на рассмотрении у прокурора',
'p7_1': 'Дело в суде',
'p8_1': 'Решение суда'
}
return places_dict
def transition_to_symbol(self, transition_name):
return self.transitions_to_symbols[transition_name]
def get_trans_to_symb(self):
return self.transitions_to_symbols
def get_symbols_to_trans(self):
return self.symbols_to_transitions
def decode_transitions(self):
return self.trans_to_ev