forked from constanzafierro/syllable-aware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperplexity100.py
62 lines (37 loc) · 1.35 KB
/
perplexity100.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
62
from src.CheckModel import CheckModel
def main():
'''
print("="*50)
print("Loading files ...")
path_model = "../models/lstm_model_train2_experimentT10000Tw100Ts2850180312.0830_2.17_2.12_30.h5"
path_experiment = "../models/experiment/train2_experimentT10000Tw100Ts2850_setting_tokenize.txt"
path_tokenselector = "../models/experiment/train2_experimentT10000Tw100Ts2850_setting_tokenSelector.txt"
path_test = "./data/test2.txt"
checkmodel = CheckModel(path_model, path_experiment, path_tokenselector)
print("="*50)
print("computing perplexity per word using file '{}'".format(path_test))
ppl = checkmodel.perplexity(path_test)
print("perplexity per word was '{}'".format(ppl))
'''
def separate_files():
# ls ~/ribanez/models >> ~/models_IDs.txt
# cat ~/models_IDs.txt
# ls ~/ribanez/models/experiment >> ~/experiments_IDs.txt
# cat ~/experiments_IDs.txt
file = open('/home/nlp/experiments_IDs.txt', 'r')
lines = file.readlines()
##
file_1 = open('/home/nlp/file_tokenize.txt', 'w')
file_2 = open('/home/nlp/file_tokenSelector.txt', 'w')
i = 0
for line in lines:
if i == 0:
file_1.write(line)
i += 1
else:
file_2.write(line)
i -= 1
##
if __name__ == '__main__':
# main()
separate_files()