-
Notifications
You must be signed in to change notification settings - Fork 43
/
mat_rnn_run.py
58 lines (51 loc) · 1.6 KB
/
mat_rnn_run.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
from sortedcontainers import SortedList
import time
from mat_rnn2 import rnn
strs = ['RNUSSLSTGNNZOMSOMSNMTAOOKPPSXWNLTC',
'RNYSSCSTGNNZOMOOMONMTAOSKPXSXKNLTC',
'ROPSSLSRRNPPOOHOOHNOIANTKNZSZMNODC',
'ROXSSCSRINPXOOMOOMNORANTKNZSZHNOQC',
'RPOSQNSRRNPPONIONINOIAOSKPXSWPNODC',
'RPSSQNSRINPXONRONRNORAOOKPPSWXNOQC',
'RNUSOLSTGNNZOHSOHSNHTASOKXPSPWNCTC',
'RNYSOCSTGNNZOHOOHONHTASSKXXSPKNCTC',
'ROPSNQSRRNPPOINOINNIOASOKXPSPWNDOC',
'ROXSNDSRINPXOINOINNISASSKXXSPKNDSC',
'RPOSLSSRRNPPOHOOHONIOATNKZNSMZNDOC',
'RPSSLOSRINPXOHSOHSNISATNKZNSMZNDSC',
'RSPSOLSIRNXPOSHOSHNSIANTKNZSZMNSDC',
'RSXSOCSIINXXOSMOSMNSRANTKNZSZHNSQC',
'RSPSNQSIRNXPORNORNNROAOOKPPSXWNQOC',
'RSXSNDSIINXXORNORNNRSAOSKPXSXKNQSC',
'RUNSLSSGTNZNOSMOSMNTMAOOKPPSWXNTLC',
'RUNSLOSGTNZNOSHOSHNTHAOSKPXSWPNTCC',
'RXOSDNSIRNXPONIONINSIASSKXXSKPNSDC',
'RXSSDNSIINXXONRONRNSRASOKXPSKXNSQC',
'RXOSCSSIRNXPOMOOMONROATNKZNSHZNQOC',
'RXSSCOSIINXXOMSOMSNRSATNKZNSHZNQSC',
'RYNSCSSGTNZNOOMOOMNTMASOKXPSKXNTLC',
'RYNSCOSGTNZNOOHOOHNTHASSKXXSKPNTCC']
def rev(st):
temp = list(st)
temp.reverse()
return ''.join(temp)
rstrs = [rev(s) for s in strs]
strs = strs + rstrs
from word_score import word_score
fitness = word_score()
r = rnn()
for count,string in enumerate(strs):
fname = "bstr%d.txt" % count
print 'working on '+fname + ' - ' + time.asctime()
fw = open(fname,'wb')
res = r.solve(string,N=20000)
res2 = []
for score,text in res:
f = fitness.score(text)
res2.append((f[0],' '.join(f[1]),text,score))
res2.sort()
for i in res2:
fw.write(str(i)+'\n')
last = str(i)
fw.close()
print last