-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.py
48 lines (47 loc) · 1.38 KB
/
middleware.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
import stru
import main
lst = 0
def assign():
lst = 0
stru.mk1 = [0 for i in range(len(stru.pred))]
for nw in stru.act:
for cu in nw.prec: # type of cu is predi
if stru.mk1[cu.id] == 1:
continue
stru.mk1[cu.id] = 1
stru.argc.append([])
tmp = 1
for i in range(len(cu.arg)):
stru.argc[-1].append(nw.par2[cu.arg[i]])
tmp *= stru.cnt[nw.par2[cu.arg[i]]]
stru.st.append(lst)
lst += tmp
print("pred name :", stru.pred)
print(stru.argc)
print(stru.st)
for nw in stru.feat:
stru.sta.add(convert2(nw.id, nw.arg))
print(convert2(nw.id, nw.arg))
print(stru.sta)
def convert(a, b):
ret = a[0]
for i in range(1, len(b)):
ret = ret * b[i-1] + a[i]
return ret
def convert2(id, a):
tmp = []
tmp2 = []
for i in a:
tmp.append(stru.var3[i])
tmp2.append(stru.cnt[stru.var2[i]])
return stru.st[id]+convert(tmp, tmp2)
def check(id, a):
if main.debug_2 == 1:
print("Checking ", stru.act[id].nam, end='')
for it in a:
print(stru.vari[a],' ', sep='', end='')
print(' ')
for it in stru.act[id].prec:
tmp = []
for i in it.arg:
tmp.append(a[i])