-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_creator.py
61 lines (37 loc) · 1.17 KB
/
model_creator.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
60
61
import _pickle as pickle
import numpy as np
# from dictionary_words import dictio,dictio1
dictionary = {} # insert your dictionary
with open('ru.sent.pkl', 'rb') as f:
u = pickle.Unpickler(f, encoding="latin1")
# u.encoding = 'latin1'
p = u.load()
first_list_of_words = [i for i in p[0]]
# print(first_list_of_words)
items = [i for i in dictionary.keys() if dictionary[i] != '0' and i not in first_list_of_words]
# print(len(first_list_of_words))
# print(len(items))
list_of_words = first_list_of_words + items
# list_of_words = items
a = 0
for i in items:
if items.count(i) > 1:
a += 1
print(a)
# print(list_of_words)
values = [int(dictionary[key]) for key in dictionary.keys() if
dictionary[key] != '0' and key not in first_list_of_words]
# print(values)
# print('-----------------------------------------')
a = p[1].tolist()
a = [i[0] for i in a]
list_of_values = a + values
# list_of_values = values
list_of_values = [[i] for i in list_of_values]
values = np.array(list_of_values)
np.reshape(values, (1, len(values)))
# print(values)
out = (list_of_words, values)
output = open('myfile.pkl', 'wb')
pickle.dump(out, output)
output.close()