forked from apeeyush/Mail-Classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode
More file actions
35 lines (34 loc) · 898 Bytes
/
Code
File metadata and controls
35 lines (34 loc) · 898 Bytes
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
import sys
import re
import os
f=open("2","r")
w=[]
subl=[]
subd={}
fr=f.read()
match=re.search('subject:(.+)\n',fr.lower())
if match:
subl=subl+[w for w in re.split('\W',match.group(1)) if w]
print (subl)
for element in subl:
if element in subd:
subd[element]+=1
else:
subd[element]=1
print (subd.items())
f.close()
f=open("2","rU")
words=[]
flag=0
for line in f:
if flag==0 and not re.search(r'x-filename',line.lower()):
continue
elif flag==0 and re.search(r'x-filename',line.lower()):
flag=1
continue
elif not ( re.search(r'forwarded by',line.lower()) or re.search(r'original message',line.lower()) ):
print line
words=words+[w for w in re.split('\W',line) if w]
elif re.search(r'forwarded by',line.lower()) or re.search(r'original message',line.lower()):
break
print words