-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRT.py
79 lines (60 loc) · 1.83 KB
/
SRT.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#disclaimer: File paths are system dependent, change code according to your location and name for subs.
#run this file and then run Plotter.py
import os
import fileinput
from collections import Counter
from Replacer import Rep
from Counter import Count
punc = list("{()}\\<—-—...,>-./;?&-..!0123456789:%\"")
cnt = 1
#path where subs are stored
path = 'C:\South\S'
N = path+'onetoEighteenModified' #replace this for every test, will modify this part later on so that if file name exists it automatically changes to a different name by appending a digit at the end.
while cnt != 19:
#N = input('Name of Processing Text File? ')
#N = path+str(cnt)
#print(N)
for file in os.listdir(path+str(cnt)):
#print(file)
str_link = open(path+str(cnt)+'\\'+file,'r').read()
#print(str_link)
f2 = open(N+'.txt','a')
#f2 is final file with all processed data
# print('opened')
#str_link = "ffff, hhhh, & tommorow home, Have you from gone?"
for line in str_link:
if line in punc:
str_link = str_link.replace(line," ")
str_link = str_link.lower()
f2.write(str_link)
# print('written')
f2.close()
# Rep(N)
# # #print('called Replacer')
# Count(N)
# # #print('called Counter')
cnt += 1
#may not be required for your subs
Rep(N) #to replace [br] with spaces
#may not be required for your subs
#
# # print('called Replacer')
Count(N) #for frequency mapping in descending order and putting data in a csv file.
'''
for i in str_link.split(' '):
if '[br]' in i:
#print(i)
print(i.index('['))
x = i.index('[')
i = i[:x] + ' ' + i[x + 4:]
print(i)
'''
# print(i)
# f2.write(str_link)
# f2.close()
#
# print(str_link)
# for i in str_link.split(' '):
# l.append(i)
#
# print(l)