-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·29 lines (22 loc) · 1.68 KB
/
test.py
File metadata and controls
executable file
·29 lines (22 loc) · 1.68 KB
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
from paylmodel import PaylModel#, ByteFrequency
gram1 = {'A':0.1818181818, 'B':0.0909090909, 'C':0, 'D':0.0909090909, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0.0909090909, 'J':0, 'K':0.0909090909, 'L':0, 'M':0.0909090909, 'N':0.0909090909, 'O':0, 'P':0, 'Q':0, 'R':0, 'S':0, 'T':0, 'U':0.1818181818, 'V':0, 'W':0, 'X':0, 'Y':0, 'Z':0, ' ':0.0909090909}
# gram2 = {'A':0.1333333333, 'B':0.1333333333, 'C':0, 'D':0.0666666667, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0.2, 'J':0, 'K':0.0666666667, 'L':0, 'M':0, 'N':0.0666666667, 'O':0, 'P':0.0666666667, 'Q':0, 'R':0, 'S':0, 'T':0, 'U':0.0666666667, 'V':0, 'W':0, 'X':0, 'Y':0, 'Z':0, ' ':0.1333333333 }
# gram3 = {'A':0.1333333333, 'B':0.1333333333, 'C':0, 'D':0.0666666667, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0.2, 'J':0, 'K':0.0666666667, 'L':0, 'M':0, 'N':0.0666666667, 'O':0, 'P':0.0666666667, 'Q':0, 'R':0, 'S':0, 'T':0, 'U':0.0666666667, 'V':0, 'W':0, 'X':0, 'Y':0, 'Z':0, ' ':0.1333333333 }
# gram3 = {'A':0.1818181818, 'B':0.0909090909, 'C':0, 'D':0.0909090909, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0.0909090909, 'J':0, 'K':0.0909090909, 'L':0, 'M':0.0909090909, 'N':0.0909090909, 'O':0, 'P':0, 'Q':0, 'R':0, 'S':0, 'T':0, 'U':0.1818181818, 'V':0, 'W':0, 'X':0, 'Y':0, 'Z':0, ' ':0.0909090909}
gram3 = {'A':0.1}
ngram1 = {}
# ngram2 = {}
ngram3 = {}
for key, value in gram1.iteritems():
if type(key) is str:
ngram1[str(ord(key))] = gram1[key]
# for key, value in gram2.iteritems():
# if type(key) is str:
# ngram2[str(ord(key))] = gram2[key]
for key, value in gram3.iteritems():
if type(key) is str:
ngram3[str(ord(key))] = gram3[key]
models = PaylModel(20, 200)
models.add_grams(ngram1)
# models.add_grams(ngram2)
print models.distance(ngram3)