-
Notifications
You must be signed in to change notification settings - Fork 0
/
categ.py
49 lines (44 loc) · 1.49 KB
/
categ.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
#fp = open('/home/harikrishnan-midhun/Desktop/MainPro/keywords/battery.txt', 'r')
rootpath='/home/harikrishnan-midhun/Desktop/MainPro/'
sndfl=open(rootpath+'sound.txt', 'w')
camfl=open(rootpath+'camera.txt', 'w')
batfl=open(rootpath+'batery.txt', 'w')
disfl=open(rootpath+'display.txt', 'w')
perfl=open(rootpath+'performance.txt', 'w')
prifl=open(rootpath+'price.txt', 'w')
c=0;
def lsmake(path):
abls=[]
with open(path) as fp:
line = fp.readline()
while line:
#print("Line {}: {}".format(cnt, line.strip()))
if(not(line.isspace())):
abls.append(line.strip());
line = fp.readline()
return abls
filepathtest = '/home/harikrishnan-midhun/Desktop/MainPro/phone_reviews.txt' #Testset.txt phone_reviews.txt'
with open(filepathtest) as fp2:
line = fp2.readline()
#line=line.decode('utf-8')
while line:
if(not(line.isspace())):
for i in lsmake(rootpath+'keywords/sound.txt' ):
if(i in line):
sndfl.write(line);
for i in lsmake(rootpath+'keywords/camera.txt' ):
if(i in line):
camfl.write(line);
for i in lsmake(rootpath+'keywords/battery.txt' ):
if(i in line):
batfl.write(line);
for i in lsmake(rootpath+'keywords/display.txt' ):
if(i in line):
disfl.write(line);
for i in lsmake(rootpath+'keywords/performance.txt' ):
if(i in line):
perfl.write(line);
for i in lsmake(rootpath+'keywords/price.txt' ):
if(i in line):
prifl.write(line);
line = fp2.readline()